accuracy {lvmisc} | R Documentation |
Model accuracy
Description
Computes some common model accuracy indices, such as the R squared, mean absolute error, mean absolute percent error and root mean square error.
Usage
accuracy(model, na.rm = FALSE)
## Default S3 method:
accuracy(model, na.rm = FALSE)
## S3 method for class 'lvmisc_cv'
accuracy(model, na.rm = FALSE)
## S3 method for class 'lm'
accuracy(model, na.rm = FALSE)
## S3 method for class 'lmerMod'
accuracy(model, na.rm = FALSE)
Arguments
model |
An object of class |
na.rm |
A logical value indicating whether or not to strip |
Details
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.
Value
An object of class lvmisc_accuracy
. See "Details" for more
information.
Examples
mtcars <- tibble::as_tibble(mtcars, rownames = "car")
m <- stats::lm(disp ~ mpg, mtcars)
cv <- loo_cv(m, mtcars, car, keep = "used")
accuracy(m)
accuracy(cv)