loo_cv | R Documentation |
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.
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")
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:
|
Returns an object of class lvmisc_cv
. A tibble containing the
".actual"
and ".predicted"
columns.
mtcars$car <- row.names(mtcars)
m <- stats::lm(disp ~ mpg, mtcars)
loo_cv(m, mtcars, car, keep = "used")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.