Root Mean Squared Error (RMSE)

Description

Compute root mean squared error of fitted linear (mixed effects) models.

Usage

1
rmse(fit, normalized = FALSE)

Arguments

fit

Fitted linear model of class lm, merMod (lme4) or lme (nlme).

normalized

Logical, use TRUE if normalized rmse should be returned.

Value

The root mean squared error of fit; or the normalized root mean squared error of fit if normalized = TRUE.

Note

The RMSE is the square root of the variance of the residuals and indicates the absolute fit of the model to the data (difference between observed data to model's predicted values). “RMSE can be interpreted as the standard deviation of the unexplained variance, and has the useful property of being in the same units as the response variable. Lower values of RMSE indicate better fit. RMSE is a good measure of how accurately the model predicts the response, and is the most important criterion for fit if the main purpose of the model is prediction.” (Grace-Martin K: Assessing the Fit of Regression Models)

The normalized RMSE is the proportion of the RMSE related to the range of the response variable. Hence, lower values indicate less residual variance.

References

See Also

cv for the coefficient of variation, and rse for the residual standard error.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data(efc)
fit <- lm(barthtot ~ c160age + c12hour, data = efc)
rmse(fit)

library(lme4)
fit <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
rmse(fit)

# normalized RMSE
library(nlme)
fit <- lme(distance ~ age, data = Orthodont)
rmse(fit, normalized = TRUE)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.