I try to find a model using logistic regression. More precisely, what I did so far, is using stepwise regression and subset selection (although I know, it is often a bad idea) to find the "best" model. Clearly, depending on the information criteria I used, I got different results.
Now, I found an interesting example on page 250 in the book "An Introduction to Statistical Learning". They chose among the models of different sizes using cross-validation, that is they make predictions for each model and compute the test errors. Eventually, the compute the cross validation error and choose the model corresponding to the minimal average cross-validation error.
However, the function regsubsets
of the R package "leaps" is only working for linear models. How can I implement this for logistic regression or glm models in general?
My idea was, to just estimate the models within a cross-validation using the step
function of the "stats" package and then kind of take the average number of features (which is determined by minimum AIC, for example). Is this a legitimate approach?
feature-selection
for additional insight. $\endgroup$