stepwise regression using caret in R [closed]

混江龙づ霸主 提交于 2020-01-03 06:43:01

问题


I have used leaps package in R to perform forward and backward feature elimination. However, I want automate the cross validation and prediction operations. Therefore, how can I use forward/backward selection in caret?

in leaps package you could do it this way

forward <- regsubsets(x ~ ., data, nvmax = 20, 
                         method = "forward")  

回答1:


You should be able to run a stepwise regression in caret::train() with method=glmStepAIC from the MASS package. For details, see the list of models supported by caret on the caret documentation website.

The caret test cases for this model are accessible on the caret GitHub repository.



来源:https://stackoverflow.com/questions/47855807/stepwise-regression-using-caret-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!