mae {staccuracy} | R Documentation |
Regression error and deviation measures
Description
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 |
na.rm |
logical(1). |
x |
numeric vector. Values for which to calculate the MAD. |
version |
character(1). By default ( |
... |
Arguments to pass to |
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.
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.
Examples
a <- c(3, 5, 2, 7, 9, 4, 6, 8, 1, 10)
p <- c(2.5, 5.5, 2, 6.5, 9.5, 3.5, 6, 7.5, 1.5, 9.5)
mae(a, p)
rmse(a, p)
mad(a)