user2062207
user2062207

Reputation: 955

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

Upvotes: 4

Views: 3247

Answers (1)

Michael
Michael

Reputation: 13914

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

Upvotes: 5

Related Questions