DescTools (version 0.99.32)

Measures of Accuracy: Measures of Accuracy

Description

Some measures of model accuracy like mean absolute error (MAE), mean absolute percentage error (MAPE), symmetric mean absolute percentage error (SMAPE), mean squared error (MSE) and root mean squared error (RMSE).

Usage

MAE(x, ...)
# S3 method for default
MAE(x, ref, na.rm = FALSE, ...)
# S3 method for lm
MAE(x, ...)

MAPE(x, ...) # S3 method for default MAPE(x, ref, na.rm = FALSE, ...) # S3 method for lm MAPE(x, ...)

SMAPE(x, ...) # S3 method for default SMAPE(x, ref, na.rm = FALSE, ...) # S3 method for lm SMAPE(x, ...)

MSE(x, ...) # S3 method for default MSE(x, ref, na.rm = FALSE, ...) # S3 method for lm MSE(x, ...)

RMSE(x, ...) # S3 method for default RMSE(x, ref, na.rm = FALSE, ...) # S3 method for lm RMSE(x, ...)

NMAE(x, ref, train.y) NMSE(x, ref, train.y)

Arguments

x

the predicted values of a model or a model-object itself.

ref

the observed true values.

train.y

the observed true values in a train dataset.

na.rm

a logical value indicating whether or not missing values should be removed. Defaults to FALSE.

further arguments

Value

the specific numeric value

Details

The function will remove NA values first (if requested). MAE calculates the mean absolute error: $$\frac{1}{n} \cdot \sum_{i=1}^{n}\left | ref_{i}-x_{i} \right |$$

MAPE calculates the mean absolute percentage error: $$\frac{1}{n} \cdot \sum_{i=1}^{n}\left | \frac{ref_{i}-x_{i}}{ref_{i}} \right |$$

SMAPE calculates the symmetric mean absolute percentage error: $$\frac{1}{n} \cdot \sum_{i=1}^{n}\frac{2 \cdot \left | ref_{i}-x_{i} \right |}{\left | ref_{i} \right | + \left | x_{i} \right |}$$

MSE calculates mean squared error: $$\frac{1}{n} \cdot \sum_{i=1}^{n}\left ( ref_{i}-x_{i} \right )^2$$

RMSE calculates the root mean squared error: $$\sqrt{\frac{1}{n} \cdot \sum_{i=1}^{n}\left ( ref_{i}-x_{i} \right )^2}$$

References

Armstrong, J. S. (1985) Long-range Forecasting: From Crystal Ball to Computer, 2nd. ed. Wiley. ISBN 978-0-471-82260-8 http://en.wikipedia.org/wiki/Symmetric_mean_absolute_percentage_error

Torgo, L. (2010) Data Mining with R: Learning with Case Studies, Chapman and Hall/CRC Press

See Also

lm, resid

Examples

Run this code
# NOT RUN {
r.lm <- lm(Fertility ~ ., data=swiss)

MAE(r.lm)

# the same as:
MAE(predict(r.lm), swiss$Fertility)

MAPE(r.lm)
MSE(r.lm)
RMSE(r.lm)
# }

Run the code above in your browser using DataCamp Workspace