Cross-validation of a Linear Regression Model
Provides cross-validation of a linear regression model
cvlm(form.lm, data, m=10, seed = NULL)
form.lm
: formula of the regression model.data
: data including outcome and covaraites.m
: the number of folds to be used in cross-validation.seed
: random starting number used to replicate cross-validation.This function finds the optimal order of the covariates power series through cross-validation.
sumres: Sum of residual squares divided by degree of freedom.
df: Degree of freedom which equals to the number of valid predictions minus the number of parameters.
m: the number of folds to be used in cross-validation.
seed: The random seed.
In making the code, we adopted part of the CVlm
in DAAG
(Maindonald and Braun, 2015).
https://cran.r-project.org/package=DAAG
Weihua An, Departments of Sociology and Statistics, Indiana University Bloomington, weihuaan@indiana.edu .
Xuefu Wang, Department of Statistics, Indiana University Bloomington, wangxuef@umail.iu.edu .
larf
, npse
Useful links