Computes some common model accuracy indices, such as the R squared, mean absolute error, mean absolute percent error and root mean square error.
accuracy(model, na.rm = FALSE) # S3 method for default accuracy(model, na.rm = FALSE) # S3 method for lvmisc_cv accuracy(model, na.rm = FALSE) # S3 method for lm accuracy(model, na.rm = FALSE) # S3 method for lmerMod accuracy(model, na.rm = FALSE)
model | An object of class |
---|---|
na.rm | A logical value indicating whether or not to strip |
An object of class lvmisc_accuracy
. See "Details" for more
information.
The method for the lm
class (or for the lvmisc_cv
class of a lm
) returns a data frame with the columns AIC
(Akaike information criterion), BIC
(Bayesian information
criterion), R2
(R squared), R2_adj
(adjusted R squared),
MAE
(mean absolute error), MAPE
(mean absolute percent
error) and RMSE
(root mean square error).
The method for the lmerMod
(or for the lvmisc_cv
class of a
lmerMod
) returns a data frame with the columns R2_marg
and
R2_cond
instead of the columns R2
and R2_adj
.
All the other columns are the same as the method for lm
.
R2_marg
is the marginal R squared, which considers only the variance
by the fixed effects of a mixed model, and R2_cond
is the
conditional R squared, which considers both fixed and random effects
variance.
mtcars <- tibble::as_tibble(mtcars, rownames = "car") m <- stats::lm(disp ~ mpg, mtcars) cv <- loo_cv(m, mtcars, car, keep = "used") accuracy(m)#> AIC BIC R2 R2_adj MAE MAPE RMSE #> 1 363.72 368.11 0.72 0.71 53.21 31.81% 64.74accuracy(cv)#> AIC BIC R2 R2_adj MAE MAPE RMSE #> 1 363.72 368.11 0.72 0.71 56.8 34.57% 68.84