Measures of Accuracy
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).
MAE(x, ...) ## Default S3 method: MAE(x, ref, na.rm = FALSE, ...) ## S3 method for class 'lm' MAE(x, ...) MAPE(x, ...) ## Default S3 method: MAPE(x, ref, na.rm = FALSE, ...) ## S3 method for class 'lm' MAPE(x, ...) SMAPE(x, ...) ## Default S3 method: SMAPE(x, ref, na.rm = FALSE, ...) ## S3 method for class 'lm' SMAPE(x, ...) MSE(x, ...) ## Default S3 method: MSE(x, ref, na.rm = FALSE, ...) ## S3 method for class 'lm' MSE(x, ...) RMSE(x, ...) ## Default S3 method: RMSE(x, ref, na.rm = FALSE, ...) ## S3 method for class 'lm' RMSE(x, ...) NMAE(x, ref, train.y) NMSE(x, ref, train.y)
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 |
The function will remove NA
values first (if requested).
MAE calculates the mean absolute error:
1/n sum( | ref_i-x_i | )
MAPE calculates the mean absolute percentage error:
1/n sum( | (ref_i-x_i) / ref_i | )
SMAPE calculates the symmetric mean absolute percentage error:
1/n sum(| ref_i-x_i | / (|ref_i| + |x_i|))
MSE calculates mean squared error:
1/n sum( (ref_i-x_i)^2 )
RMSE calculates the root mean squared error:
sqrt(1/n sum( (ref_i-x_i)^2))
the specific numeric value
Andri Signorell <andri@signorell.net>
Armstrong, J. S. (1985) Long-range Forecasting: From Crystal Ball to Computer, 2nd. ed. Wiley. ISBN 978-0-471-82260-8
https://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
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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.