Stepwise Regression

Statistics
Introduced by
M. A. Efroymson
Year
1960
Type
Automated variable selection

What does it do?

Stepwise regression is an automated variable selection procedure for multiple linear regression.

It adds or removes predictors one at a time according to a statistical criterion, usually an F-statistic or a p-value threshold. The procedure is usually traced to Efroymson (1960). Draper and Smith's Applied Regression Analysis (1966) is a standard textbook treatment of it. Its use in published work is now widely questioned, mainly because the p-values and coefficient estimates reported after selection are unreliable.

The intuition behind the method

When you have many candidate predictors and want the model to 'choose' which ones to keep, stepwise regression tries them one by one. Forward selection starts with no predictors and keeps adding the variable that most improves fit; backward elimination starts with all variables and drops the least useful one at each step; the bidirectional (stepwise) variant does both, so a variable added early can later be dropped if a new arrival makes it redundant. At each step the procedure checks a simple question: does adding or removing this variable change the fit enough to be worth the extra complexity? The threshold for 'enough' is usually set as an F-ratio or p-value cutoff.

History

M. A. Efroymson's 1960 chapter in Mathematical Methods for Digital Computers, edited by Ralston and Wilf, is the cited origin of the procedure. Draper and Smith's Applied Regression Analysis (1966) is a standard textbook treatment of it, and a later edition appeared in 1998. The method then became widely used in applied research, and the later literature has documented its problems with biased estimates and unstable selection. Penalised alternatives such as the LASSO and elastic net were developed later as principled ways to combine selection and estimation.

When to use it

Stepwise regression is applicable when the outcome is continuous, the candidate predictors are interval-scaled or appropriately dummy-coded, and the OLS assumptions are reasonable: linearity, independence, homoscedasticity, approximately normal residuals, and no severe multicollinearity. It is most defensible in purely predictive work with many observations per candidate predictor, or in exploratory work where the aim is to shortlist variables for confirmation on separate data. Do not use it for causal questions, for tests of specific predictors, or when the number of observations per candidate predictor is small. Fewer than 10 observations per candidate predictor is a rough rule of thumb, not an established cut-off; the stability of the selection depends on the sample size and the strength of the predictors. When the main goal is sparse automatic selection, penalised regression such as the LASSO or elastic net is usually the better-justified choice.

Limitations and considerations

  • Post-selection inference is invalid: p-values and confidence intervals for the final model are biased because the same data drove both selection and estimation (the 'winner's curse').
  • The selected subset can be unstable. Small changes in the data can produce a different final model, and the selection can change between runs on resampled data.
  • The search is greedy, so it does not guarantee the globally best subset and can miss it.
  • Because the final model is chosen to fit the data used for estimation, its R-squared is inflated and its standard errors tend to be understated.
  • The many implicit tests performed during selection are not corrected for multiple comparisons.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • The computations are simple, and the procedure is available in many statistical packages, which makes it accessible to applied researchers.
  • It reduces the number of predictors automatically, which can help prediction when the number of observations is moderate relative to the number of candidates.
  • It gives a quick first shortlist of variables in large exploratory analyses.
  • Forward selection avoids evaluating all 2^p possible subsets, so it remains computationally feasible when p is large.

Applications

  • Historical baseline in biomedical studies seeking to shortlist clinical covariates for a regression model before confirmation on independent data.
  • Exploratory phase of large-scale surveys where the analyst wishes to reduce a wide predictor set prior to theory-driven modelling.
  • Educational illustration of sequential variable selection and the concept of partial F-statistics in graduate statistics courses.
  • Engineering quality studies where a large number of process variables are screened for association with a continuous quality metric, with the selected subset then validated experimentally.

How it works

How it works

1

The full model regresses the outcome y on all p candidate predictors, with coefficients estimated by ordinary least squares (OLS). Stepwise procedures instead move through a sequence of submodels, each using a subset S of those predictors. The coefficients of any given submodel are estimated by minimising the residual sum of squares, which gives the closed-form OLS estimator shown above. The purpose of the search is to identify which subset S to keep.

Formula
y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \cdots + \beta_p x_p + \varepsilon, \quad \varepsilon \sim \mathcal{N}(0,\sigma^2)
2

At each forward step, the procedure computes a partial F-statistic for every predictor not yet in the model. This statistic measures the reduction in residual sum of squares that the predictor would contribute, scaled by the current error variance estimate. The predictor with the largest F-to-enter is the candidate for addition.

Formula
F_{\text{enter},j} = \frac{\text{SS}_{\text{reg}}(x_j \mid \text{current model}) / 1}{\hat{\sigma}^2_{\text{current}}}
3

In the bidirectional variant, after each addition the procedure also computes F-to-remove for every predictor already in the model. This statistic measures how much the fit would deteriorate if that predictor were dropped while the others stay in the model. A predictor becomes a candidate for removal when its F-to-remove falls below the removal threshold.

Formula
F_{\text{remove},j} = \frac{\text{SS}_{\text{reg}}(x_j \mid \text{all other predictors in model}) / 1}{\hat{\sigma}^2_{\text{full}}}
4

A predictor is added when its F-to-enter exceeds the entry threshold, and an existing predictor is removed when its F-to-remove falls below the removal threshold. The procedure stops when no predictor meets the entry criterion and no predictor meets the removal criterion. The two thresholds are chosen by the analyst, and the procedure does not guarantee that the final model is a good one.

Formula
\text{Add } x_j \text{ if } F_{\text{enter},j} > F_{\alpha,\text{enter}}; \quad \text{Remove } x_k \text{ if } F_{\text{remove},k} < F_{\alpha,\text{remove}}
5

Once the final subset is fixed, OLS estimates are computed from its reduced design matrix X using the closed-form expression shown. The formula is the standard OLS estimator for that subset. However, the subset was itself chosen from the same data, so the standard errors, p-values and confidence intervals reported for these estimates do not have their usual properties.

Formula
\hat{\boldsymbol{\beta}} = (\mathbf{X}^\top \mathbf{X})^{-1} \mathbf{X}^\top \mathbf{y}

Common pitfalls

  • Treating the selected model as if it had been specified in advance and reporting its p-values at face value. This is a common and serious error.
  • Using stepwise selection with a small sample, for example fewer than 10 observations per candidate predictor (a rough rule of thumb rather than an established cut-off), which makes the selected model much less stable and more prone to overfitting.
  • Setting the entry and removal thresholds equal. Unequal thresholds help stop a variable from cycling in and out of the model; with equal thresholds, check the step history for a variable that is added and then removed.
  • Using stepwise selection to establish causal effects or to rank variable importance. It does neither reliably.
  • Ignoring multicollinearity. When predictors are strongly correlated, the choice among them can be largely arbitrary, so the selected variables may not be meaningful.

Frequently asked questions

What is the difference between forward selection, backward elimination, and stepwise (bidirectional) selection?

Forward selection begins with an empty model and adds the predictor with the highest F-to-enter at each step, stopping when no remaining predictor meets the entry threshold. Backward elimination begins with all p predictors and removes the predictor with the lowest F-to-remove at each step, stopping when every retained predictor meets the removal threshold. Bidirectional stepwise selection combines both passes: after each addition it checks whether any previously included predictor should now be removed, and after each removal it can re-check the excluded predictors. Because it can revisit earlier decisions, the bidirectional variant can correct early inclusions, which pure forward selection cannot. All three variants share the same post-selection inference problems.

Why are p-values from a stepwise-selected model not trustworthy?

Standard p-values assume the model structure was fixed before the data were seen. In stepwise regression the data are used to choose which predictors enter the model and then again to estimate and test them. This double use inflates the apparent significance of the retained variables, an effect often called the 'winner's curse'. Across repeated samples, predictors with no true effect can be selected and appear significant. Correcting for this requires data splitting, bootstrap-based validation, or penalised estimation methods that combine selection and estimation in one optimisation.

When is stepwise regression still acceptable to use?

Stepwise selection is most defensible in purely predictive applications where (a) the dataset is large relative to the number of candidate predictors, (b) the resulting model will be validated on a held-out or prospective sample, and (c) inference about individual coefficients is not the goal. In exploratory work it can serve as a preliminary screening tool, provided the shortlisted variables are then tested in a pre-specified model on new data. It should not be used for causal inference, hypothesis tests about specific predictors, or any setting where the reported p-values will be read at face value.

What modern methods should I consider instead of stepwise regression?

For sparse variable selection with defensible inference, the LASSO and the elastic net are the usual alternatives. They combine selection and estimation in a single penalised criterion, their tuning parameter is commonly chosen by cross-validation, and bootstrap confidence intervals can be reported. Best-subset selection, which searches all subsets, is an alternative when p is small enough for that search to be feasible. For confirmatory research, the model should be specified on theoretical grounds before data collection rather than letting the data choose the predictors.

Related methods

Sources

  1. Efroymson, M. A. (1960). Multiple regression analysis. In A. Ralston & H. S. Wilf (Eds.), Mathematical Methods for Digital Computers (pp. 191–203). Wiley.

    Open publication reference
  2. Draper, N. R., & Smith, H. (1966). Applied Regression Analysis (1st ed.). Wiley.

    ISBN: 9780471221708
  3. Draper, N. R., & Smith, H. (1998). Applied Regression Analysis (3rd ed.). Wiley.

    ISBN: 9780471170822
  4. Multiple Regresion and SEM, p. 117