reg_crossval: K-fold cross-validation of regression models estimated with...

View source: R/regression.R

reg_crossvalR Documentation

K-fold cross-validation of regression models estimated with lm()

Description

K-fold cross-validation of regression models estimated with lm()

Usage

reg_crossval(formula, data, nfolds, obs_order = "random")

Arguments

formula

an object of class "formula": a symbolic description of the model to be fitted.

data

a data frame with the data used for fitting the models.

nfolds

the number of folds in the cross-validation.

obs_order

order of the observations when splitting the data. obs_order = "random" gives a random order.

Value

RMSE Root mean squared prediction error on test data

Examples

library(regkurs)
RMSE_CV = reg_crossval(mpg ~ hp, data = mtcars, nfolds = 4, obs_order = 1:32)
print(RMSE_CV)

StatisticsSU/regkurs documentation built on Jan. 29, 2023, 4:54 p.m.