loo_cv {lvmisc} | R Documentation |
Leave-one-out cross-validation
Description
Cross-validates the model using the leave-one-out approach. In this method each subject's data is separated into a testing data set, and all other subject's are kept in the training data set, with as many resamples as the number of subjects in the original data set. It computes the model's predicted value in the testing data set for each subject.
Usage
loo_cv(model, data, id, keep = "all")
## Default S3 method:
loo_cv(model, data, id, keep = "all")
## S3 method for class 'lm'
loo_cv(model, data, id, keep = "all")
## S3 method for class 'lmerMod'
loo_cv(model, data, id, keep = "all")
Arguments
model |
An object containing a model. |
data |
A data frame. |
id |
The bare (unquoted) name of the column which identifies subjects. |
keep |
A character string which controls which columns are present in the output. Can be one of three options:
|
Value
Returns an object of class lvmisc_cv
. A tibble containing the
".actual"
and ".predicted"
columns.
Examples
mtcars$car <- row.names(mtcars)
m <- stats::lm(disp ~ mpg, mtcars)
loo_cv(m, mtcars, car, keep = "used")