Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorporating cross validation in stepwise regression in R

I have a dataset of 162 observations with a 151 different variables and I would like to perform stepwise regression on it, but to also do 10 fold cross validation on it. I have used the package DAAG before in order to perform 10 fold cross validation with multiple linear regression and was able to use one of its formulas:-

CVlm(df = data, seed=1500, m = 10, form.lm = formula(RT..seconds.~.,), printit=TRUE)

I was wondering whether the package supported the same thing but with stepwise regression? I've had a look through it's pdf but was unable to find anything.

I know that I can perform stepwise regression using the MASS package by doing

step <- stepAIC(fit, direction="both")

but can't see how I can incorporate 10-fold CV into the equation.

Thanks

like image 573
user2062207 Avatar asked Dec 05 '13 20:12

user2062207


1 Answers

The SuperLearner package supports v-fold cross validation of stepwise regression.

like image 128
Michael Avatar answered Oct 17 '22 13:10

Michael