Regression · Selection

Stepwise Model Selection

Forward, backward, or bidirectional stepwise selection of predictors for an OLS model by AIC or BIC, with the full selection path and a post-selection-inference warning.

In the menus Regression › Selection › Stepwise Model Selection

Also searched as stepwise stepwise regression forward selection backward elimination best subsets model selection

When to use it

You have many candidate predictors for a numeric outcome and want an automated search to suggest a smaller subset by an information criterion (AIC/BIC), as a starting point for a model you will then validate, NOT as a hypothesis test of which predictors 'matter'.

When not to: You intend to report the final model's p-values, standard errors, or confidence intervals as valid inference (they are invalid after this kind of data-dependent selection), predictors are highly correlated (the search becomes especially unstable, arbitrarily keeping one of a correlated pair or the other), or you specifically need a formal statistical test of predictor importance rather than a predictive-model starting point.

Step by step

  1. Open it from the menu

    Click Regression in the menu bar; under Selection choose Stepwise Model Selection.

  2. Fill in the form

    Choose the columns: What you want to predict, Columns that may explain it. The form lists only columns whose type fits each field.

  3. Check the options

    The options start at their defaults: Direction, Criterion, Alpha. Change one only when your question needs it.

  4. Run the analysis

    Press Run analysis. The Result Card opens on its Results tab.

What to choose in the form

Fields of the Stepwise Model Selection form
What you want to predict Response requiredOne numeric column. Numeric (continuous) outcome to model.
Columns that may explain it Predictors requiredOne numeric or categorical or ordered categorical column. Two or more candidate predictors. Categorical predictors are auto-encoded and move as whole factors.
DirectionSearch direction. Default: both.
CriterionInformation criterion to optimize (lower is better). Default: aic.
AlphaThreshold for the descriptive per-coefficient significance flags on the FINAL model. Default: 0.05.

How to read the card

The Results tab starts with what to know first (rows left out, checks that did not pass), then the interpretation in words and the Key Results; charts and assumption checks follow further down. Learn More explains the method in plain words. Read a Result Card covers all four tabs.

What it assumes

Normality (of residuals, not of the raw data)

If it does not hold: Non-normal residuals in the final selected model make its standard errors, t-tests, and confidence intervals approximate rather than exact, on top of the post-selection bias already present.

How to check: Shapiro-Wilk on the final model's residuals (for 3 to 5000 residuals), reported directly on the card.

Homogeneity of variance (homoscedasticity)

If it does not hold: Heteroscedasticity in the final selected model makes its classical standard errors wrong, compounding the post-selection bias already present in the reported p-values.

How to check: Breusch-Pagan test on the final model's residuals, reported directly on the card.

A worked example

Selecting among all ten candidate predictors in the mtcars data (cylinders, displacement, horsepower, rear-axle ratio, weight, quarter-mile time, engine shape, transmission, gears, carburetors) for fuel economy (mpg), comparing forward-AIC and backward-AIC on the same data.

Result: Forward-AIC selects weight, cylinders, and horsepower; backward-AIC selects weight, quarter-mile time, and transmission type: two different three-predictor models from the same starting data.

This disagreement is the expected signature of stepwise selection's instability, not an error in either search; both models are plausible predictive starting points, but neither the specific predictors chosen nor their p-values in either final model should be reported as proof of which variables genuinely drive fuel economy; cross-validation or a held-out sample is needed to compare the two candidates honestly.

From the Statistics Library.

The code tabs

Code gives this analysis as Python, R and MATLAB code (and SAS where the tab offers it), reading the data the way KernelStats did. Export sends the card to a report or to slides. See The Code tab.

Understand the statistics

Ask Oobi

Type one of these into Ask Oobi beside your data:

  • Which of cylinders, displacement, horsepower, weight and quarter-mile time best predict a car's fuel economy?
  • Explain the stepwise model selection in plain words.
  • What does overfitting mean?

Last reviewed November 16, 2026.

Report an unclear step