Backward stepwise regression with cross validation in R

I would like to do model selection using backward stepwise procedure and cross validation. https://www.otexts.org/fpp/5/3

I have used stepAIC in MASS package for predictors selection and I would like to see whether cross validation is a better criteria. In other words, I am trying to use cross-validation as a criterion in backward selection procedure instead of AIC.

The procedure should start with a full model, drop one predictor at a time, keep the variable if it improves CV and continue until no improvements can be made.

I think that the rfe function in the caret package may be able to do the job. I would also like to do bootstrapping if possible. If so, how should I specify it? Or are there any functions that can do that? I have tried writing my own function, but it seems to be beyond my ability. Many thanks.

• validate in the rms package has the option of allowing backwards selection based on AIC. Do read some of the many posts here on why stepwise methods aren't so good & consider whether (a) you need to do post-hoc model selection, & (b) you ought to apply shrinkage e.g. lasso. – Scortchi - Reinstate Monica Feb 21 '14 at 12:03
• As @Scortchi alluded, the method you proposed is not based on any good statistical principles. If you really need to do model selection (which is not obvious why this is helpful; weak variables don't hurt models), then you should combine model selection with shrinkage using a method such as elastic net. – Frank Harrell Feb 21 '14 at 12:34
• Sorry, I misread the question (despite its being pretty clear) - you want to use a performance measure calibrated by cross-validation as a criterion in the backward selection procedure instead of AIC. Note that you'll still want to validate this procedure: see here. And that it's still stepwise, with all its faults. – Scortchi - Reinstate Monica Feb 21 '14 at 12:35
• In addition to what Frank Harrell and Scortchi say, you should definitively read Dikran Marsupial's paper about overfitting during such massive model comparison situations: Cawley, G. C. & Talbot, N. L. C.: On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation, Journal of Machine Learning Research, 11, 2079-2107 (2010). – cbeleites supports Monica Feb 21 '14 at 13:19
• Thanks for the comments. As @Scortch clarified, I am trying to use cross-validation as a criterion in backward selection procedure instead of AIC. I have used backwards selection based on AIC and I would to see whether cross-validation is a better criteria. – AdrienS Feb 24 '14 at 3:00