These are standard error and deviation measures for numeric data. "Deviation" means the natural variation of the values of a numeric vector around its central tendency (usually the mean or median). "Error" means the average discrepancy between the actual values of a numeric vector and its predicted values.
Usage
mae(actual, pred, na.rm = FALSE)
rmse(actual, pred, na.rm = FALSE)
mad(x, na.rm = FALSE, version = "mean", ...)
Arguments
- actual
numeric vector. Actual (true) values of target outcome data.
- pred
numeric vector. Predictions corresponding to each respective element in
actual
.- na.rm
logical(1).
TRUE
if missing values should be removed;FALSE
if they should be retained. IfTRUE
, then if any element of eitheractual
orpred
is missing, its paired element will be also removed.- x
numeric vector. Values for which to calculate the MAD.
- version
character(1). By default (
version = 'mean'
),mad()
returns the mean absolute deviation (MAD) of values relative to their mean. Ifversion = 'median'
, it calls thestats::mad()
function instead, the median absolute deviation relative to their median (MedAD, sometimes also called MAD). Any other value gives an error. See details.- ...
Arguments to pass to
stats::mad()
ifversion = 'median'
. See theversion
argument for details.
Value
In all cases, if any value in actual
or pred
is NA
and na.rm = FALSE
, then the function returns NA
.
mae()
returns the mean absolute error (MAE) of predicted values pred
compared to the actual
values.
rmse()
returns the root mean squared error (RMSE) of predicted values pred
compared to the actual
values.
mad()
returns either the mean absolute deviation (MAD) of values relative to their mean (default) or the median absolute deviation relative to their median. See details.
Details
Mean absolute deviation (MAD)
mad()
returns the mean absolute deviation (MAD) of values relative to their mean. This is useful as a default benchmark for the mean absolute error (MAE), as the standard deviation (SD) is a default benchmark for the root mean square error (RMSE).
NOTE: This function name overrides stats::mad()
(median absolute deviation relative to their median). To maintain the functionality of stats::mad()
, specify the version
argument.