I am fitting a stepwise logistic regression on a set of data in SPSS. In the procedure, I am fitting my model to a random subset that is approx. 60% of the total sample, which is about 330 cases.

What I find interesting is that every time I re-sample my data, I am getting different variables popping in and out in the final model. A few predictors are always present in the final model, but others pop in and out depending on the sample.

My question is this. What is the best way to handle this? I was hoping to see the convergence of predictor variables, but that isn't the case. Some models make much more intuitive sense from an operational view (and would be easier to explain to the decision makers), and others fit the data slightly better.

In short, since variables are shuffling around, how would you recommend dealing with my situation?

Many thanks in advance.


5 Answers 5


If you're going to use a stepwise procedure, don't resample. Create one random subsample once and for all. Perform your analysis on it. Validate the results against the held-out data. It's likely most of the "significant" variables will turn out not to be significant.

(Edit 12/2015: You can indeed go beyond such a simple approach by resampling, repeating the stepwise procedure, and re-validating: this will lead you into a form of cross-validation. But in such a case more sophisticated methods of variable selection, such as ridge regression, the Lasso, and the Elastic Net are likely preferable to stepwise regression.)

Focus on the variables that make sense, not those that fit the data a little better. If you have more than a handful of variables for 330 records, you're at great risk of overfitting in the first place. Consider using fairly severe entering and leaving criteria for the stepwise regression. Base it on AIC or $C_p$ instead of thresholds for $F$ tests or $t$ tests.

(I presume you have already carried out the analysis and exploration to identify appropriate re-expressions of the independent variables, that you have identified likely interactions, and that you have established that there really is an approximately linear relationship between the logit of the dependent variable and the regressors. If not, do this essential preliminary work and only then return to the stepwise regression.)

Be cautious about following generic advice like I just gave, by the way :-). Your approach should depend on the purpose of the analysis (prediction? extrapolation? scientific understanding? decision making?) as well as the nature of the data, the number of variables, etc.

  • 2
    $\begingroup$ +1 for highlighting the importance of model interpretation. I won't add anything about the uninformed ML approach (or ensemble methods) with more complex cross-validation schemes, because I feel you already said what's really matter here: (1) feature selection through resampling is hardly interpretable in isolation (i.e., by comparing one result after the other), and (2) it all depends if we are seeking for a predictive or an explanatory model. $\endgroup$
    – chl
    Dec 10, 2010 at 21:03
  • $\begingroup$ Thanks for your insight. I have done some pre-screening to narrow my search space and simply want to find the best model for prediction with the fewest variables. I am only throwing 7 predictors into the model, which as I understand it, should be ok. I understand the idea of sticking with a sample, but on the flip side, my model was fundamentally different and shows that the results are entirely sample-dependent, which made me pause. $\endgroup$
    – Btibert3
    Dec 10, 2010 at 21:30
  • $\begingroup$ @Btibert3 Right: when the results vary among random subsets of your data, you can take that as evidence that the independent variables are not strong or consistent predictors of the independent variable. $\endgroup$
    – whuber
    Dec 10, 2010 at 22:03

An important question is "why do why do you want a model with as few variables a possible?". If you want to have as few variables as possible to minimize the cost of data collection for the operational use of your model, then the answers given by whuber and mbq are an excellent start.

If predictive performance is what is really important, then you are probably better off not doing any feature selection at all and use regularized logistic regression instead (c.f. ridge regression). In fact if predictive performance was what was of primary importance, I would use bagged regularized logistic regression as a sort of "belt-and-braces" strategy for avoiding over-fitting a small dataset. Millar in his book on subset selection in regression gives pretty much that advice in the appendix, and I have found it to be excellent advice for problems with lots of features and not very many observations.

If understanding the data is important, then there is no need for the model used to understand the data to be the same one used to make predictions. In that case, I would resample the data many times and look at the patterns of selected variables across samples to find which variables were informative (as mbq suggests, if feature selection is unstable, a single sample won't give the full picture), but I would still used the bagged regularized logistic regression model ensemble for predictions.

  • 1
    $\begingroup$ +1 for the pointer to regularized logistic regression. It's unclear how one could formally "look at patterns" when resampling the "data many times," though. That sounds a lot like data snooping and therefore seems likely to lead to frustration and error. $\endgroup$
    – whuber
    Dec 11, 2010 at 19:07
  • 5
    $\begingroup$ Feature selection when the selection is unstable will always be a recipe for frustration and error. Using only one sample cuts down on the frustration, but increases the likelihood of error as it encourages you to draw inferences about the relevant features for the problem based on what works best on the particular sample you look at - which is a form of over-fitting. The re-sampling gives you an idea of the uncertainty in the feature selection - which is often just as important. In this case we shouldn't draw any strong conclusions about the relevant features as there isn't enough data. $\endgroup$ Dec 11, 2010 at 20:42
  • $\begingroup$ Good point; I hate when people only count mean from resampling, it's such a waste. $\endgroup$
    – user88
    Dec 11, 2010 at 23:38

In general, there are two problems of feature selection:

  • minimal optimal, where you seek for smallest set of variables that give you the smallest error
  • all relevant, where you seek for all variables relevant in a problem

The convergence of predictor selection is in a domain of the all relevant problem, which is hell hard and thus requires much more powerful tools than logistic regression, heavy computations and a very careful treatment.

But it seems you are doing the first problem, so you shouldn't worry about this. I can generally second whuber's answer, but I disagree with the claim that you should drop resampling -- here it won't be a method to stabilize feature selection, but nevertheless it will be a simulation for estimating performance of a coupled feature selection + training, so will give you an insight in confidence of your accuracy.

  • $\begingroup$ +1 I worry that lots of resampling will only be confusing and misleading. Resampling in a controlled way, via cross validation or a hold-out sample for verification, obviously is not problematic. $\endgroup$
    – whuber
    Dec 11, 2010 at 19:08

You might glance at the paper Stability Selection by Meinshausen and Buhlmann in J R Statist. Soc B (2010) 72 Part 4, and the discussion after it. They consider what happens when you repeatedly divide your set of data points at random into two halves and look for features in each half. By assuming that what you see in a one half is independent of what you see in the matching other half you can prove bounds on the expected number of falsely selected variables.


Don't use stepwise! See my paper


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.