Tutorials › Regression Analysis (Undergraduate) › Stepwise Selection in a Retail Sales Analysis

Integrated Applied Case Studies · Tutorial 984 of 991

Stepwise Selection in a Retail Sales Analysis

Learn how a stepwise search selects retail-sales predictors, how to assess whether those choices are stable, and why the search itself limits what the results establish.

Advanced 10 min read

What You'll Learn

  • Define a candidate predictor set and apply forward stepwise selection using an AIC-style criterion.
  • Compare models by calculating changes in residual sum of squares and complexity penalty.
  • Summarize how often predictors and models are selected across resamples.
  • Explain how searching many candidate predictors can increase false-positive findings.
  • Report stepwise results without treating the selected model as uniquely correct or causal.

Why Stepwise Selection Needs Careful Interpretation

A retail analyst may have several plausible predictors of store sales: customer traffic, promotion intensity, seasonal demand, local income, and competitor activity. Including every available variable can make a model difficult to interpret, while choosing predictors by intuition alone may overlook useful combinations. Stepwise selection offers a systematic search through a specified set of candidate models. It is a search procedure, however, not a guarantee that the final model is the uniquely correct explanation of sales.

This tutorial follows a hypothetical analysis of weekly sales across 24 comparable stores. The outcome is sales in thousands of dollars per week. The candidate predictors are a traffic index, promotion intensity, and a seasonal-demand index. The examples are constructed for instruction and do not describe real stores.

The Model and the Search Rule

For a chosen subset of \(q\) predictors, write the ordinary linear regression model as

$$ Y_i=\beta_0+\beta_1x_{i1}+\cdots+\beta_qx_{iq}+\varepsilon_i,\qquad i=1,\ldots,n. $$

Here \(Y_i\) is sales for store \(i\), the \(x\)'s are the selected predictors, and the \(\beta\)'s are regression coefficients. For the usual Gaussian linear-model likelihood calculations, assume the errors are independent, have mean zero and common variance \(\sigma^2\), and are normally distributed: \(\varepsilon_i\sim N(0,\sigma^2)\). These assumptions concern the model errors conditional on the predictors. The sales observations and predictors must also be measured comparably, and the candidate model set and selection rule should be specified before inspecting the selection results. These conditions make the stated model-comparison calculations meaningful; they do not ensure that the candidate set contains a good model.

A stepwise procedure repeatedly compares models that differ by adding or removing candidate predictors. In forward selection, the search starts with an intercept-only model and considers adding predictors. In backward selection, it starts with a specified larger model and considers removals. A bidirectional procedure may allow both additions and removals at each stage. The procedure stops according to its stated rule—for example, when no permitted change improves the chosen criterion. Different starting models, candidate sets, or stopping rules can lead to different results.

Definition: Stepwise selection is a model-search procedure that adds and/or removes predictors one step at a time from a prespecified candidate set, using a rule to decide which change to make and when to stop. The resulting model is the endpoint of that search; it is not, by that fact alone, the only suitable model.

One possible rule is to compare models with an AIC-style score. Let \(RSS\) be the residual sum of squares for a model fitted to the same \(n\) observations, and let \(k\) be its number of fitted slope coefficients. An intercept is included in every model here, so its contribution is common when models are compared. We use the simplified score

$$ AIC^*=n\ln(RSS/n)+2k. $$

Smaller \(AIC^*\) is preferred by this criterion. It rewards lower residual error but penalizes additional slopes. It is a model-comparison score, not a probability that a model is true, and its values are meaningful here only for models fitted to the same response observations under the same outcome scale and likelihood setup.

Why the Score Balances Fit and Complexity

Under the normal-error model, the maximized likelihood estimates the error variance by \(RSS/n\). Substituting this estimate into the Gaussian log likelihood gives a negative twice-log-likelihood of the form \(n\ln(RSS/n)\) plus terms common to models fitted to the same data. AIC adds twice the number of estimated parameters to this quantity. The simplified score above omits the common terms and uses the number of slope coefficients for \(k\); the intercept and error-variance contributions are common across these comparisons.

Consequently, if a proposed step changes a model from \(k_1\) to \(k_2\) slopes and from \(RSS_1\) to \(RSS_2\), the score change is

$$ \Delta AIC^*=n\ln(RSS_2/RSS_1)+2(k_2-k_1). $$

A negative change favors the new model by this criterion; a positive change favors the old one. This comparison makes the trade-off explicit: adding a predictor is worthwhile only when the reduction in residual error is large enough to offset the complexity penalty.

Worked Example: Following a Forward Search

Suppose the intercept-only model for the 24 stores has \(RSS=220\). The single-predictor candidate models have the following hypothetical residual sums of squares: traffic, 170; promotion, 165; and season, 180. We first compare each to the intercept-only model, where \(k=0\).

For traffic, \(k\) increases by one, so

$$ \Delta AIC^*=24\ln(170/220)+2(1-0) \approx 24(-0.2578)+2=-4.188. $$

For promotion,

$$ \Delta AIC^*=24\ln(165/220)+2 =24\ln(0.75)+2 \approx -4.904. $$

For season,

$$ \Delta AIC^*=24\ln(180/220)+2 \approx 24(-0.2007)+2=-2.816. $$

All three changes lower the score, and promotion gives the largest reduction. A forward search using this rule therefore adds promotion first. Now suppose the model with promotion and season has \(RSS=145\), the model with promotion and traffic has \(RSS=149\), and the model with all three predictors has \(RSS=140\). From the promotion-only model, adding season changes the score by

$$ 24\ln(145/165)+2(2-1)\approx -1.101. $$

Adding traffic instead gives \(24\ln(149/165)+2\approx -0.448\). Thus the next forward step chooses season. From the promotion-and-season model, adding traffic changes the score by

$$ 24\ln(140/145)+2(3-2)\approx 1.158. $$

That addition raises the score, so this forward search stops at promotion and season. The calculation describes the path taken under the specified rule; another search strategy or candidate set could reach another model.

Resampling to Examine Selection Stability

A selected predictor can depend on which observations happen to be in the data. One way to examine that dependence is to resample the observational units, rerun the entire selection procedure on each resample, and summarize how often each predictor or model is selected. For an ordinary bootstrap illustration, each resample has the original sample size and is drawn with replacement from the observed stores. This procedure is most defensible when stores can reasonably be treated as independent sampling units; if the data have meaningful dependence or a different sampling design, the resampling scheme must reflect it.

Selection frequency is descriptive. It reports how often the specified procedure selects a predictor in the resamples. It is not a posterior probability that the predictor matters, and it does not repair a misspecified model or account for every uncertainty in the analysis.

Worked Example: Summarizing Ten Resampled Searches

Suppose ten bootstrap resamples of the 24 stores are analyzed with the same forward AIC-style procedure and the same three candidate predictors. The selected models are: promotion plus season in four resamples; promotion plus traffic in three; traffic plus season in two; and all three predictors in one.

Promotion appears in the first, second, and fourth model groups, so its selection frequency is \((4+3+1)/10=8/10=0.80\), or 80%. Traffic is selected in the second, third, and fourth groups: \((3+2+1)/10=0.60\), or 60%. Season is selected in the first, third, and fourth groups: \((4+2+1)/10=0.70\), or 70%.

The exact promotion-and-season model occurs in \(4/10=40\%\) of these searches. Thus, promotion is selected more consistently than either other predictor in this illustration, but the precise subset varies. The evidence supports describing promotion as comparatively stable under this particular resampling and search procedure; it does not establish that promotion is a causal driver or that the promotion-and-season model is uniquely correct.

Search Multiplicity and Near-Ties

Searching many candidate predictors creates more opportunities for a variable to look useful by chance. A simple calculation illustrates the issue. Suppose eight candidate predictors have no genuine association with the outcome after accounting for the model, and suppose—for illustration—that eight null-hypothesis p-values are independent and each is uniformly distributed between 0 and 1. The probability that none is below 0.05 is \(0.95^8\). Therefore the probability that at least one is below 0.05 is

$$ P(\text{at least one }p<0.05)=1-0.95^8\approx 0.3366. $$

So even in this simplified setting, screening eight null predictors creates about a 33.66% chance of finding at least one p-value below 0.05. Real predictors are often correlated, so the independence calculation need not apply exactly. The general caution remains: ordinary p-values and confidence intervals calculated after data-driven selection do not automatically retain their usual interpretation. A small p-value from the winning step should not be presented as though that predictor had been the only one considered in advance.

A related caution is that two models can have very similar scores. In the example, the traffic-and-season model has \(RSS=149\), while the promotion-and-season model has \(RSS=145\). Both have two slopes, and

$$ AIC^*_{\text{traffic+season}}-AIC^*_{\text{promotion+season}} =24\ln(149/145)+2(2-2) =24\ln(149/145) \approx 24(0.0272125)\approx 0.6531. $$

The promotion-and-season model has the lower score, but the difference is small. This ranking says only which of these two models scores better under the stated criterion and data. It is not a test establishing that one model is true, nor evidence that the other model is impossible. The selected model is not uniquely established simply because a search returns one winner.

How to Report a Stepwise Analysis

A clear report describes the outcome, candidate predictors, observation set, selection direction, criterion, and stopping rule. It should distinguish the search result from subsequent interpretation. For example: “In the hypothetical sample of 24 stores, forward selection among traffic, promotion, and seasonal demand using the stated AIC-style score stopped with promotion and seasonal demand.” If resampling was done, report the resampling unit and scheme, the number of resamples, and the selection frequencies. Do not imply that selection frequencies are significance levels or causal probabilities.

The model also inherits the limitations of its data and assumptions. The linear conditional-mean form may not represent the relationship well; errors may be dependent or have unequal variance; important predictors may be absent; and predictor measurements may be noisy. Stepwise selection addresses none of those issues by itself. The earlier material on collinearity and influential observations is also relevant: correlated predictors can compete for selection, and a small number of unusual observations can affect fitted models and the selected path.

Common Mistakes

  • Treating the selected model as the only correct one. The procedure selects one endpoint according to a particular search path and score. Similar-scoring alternatives may also be reasonable.
  • Reading selection frequency as probability of truth. A frequency such as 80% means the procedure selected that predictor in 80% of the specified resamples—not that there is an 80% probability its coefficient is nonzero.
  • Ignoring how many candidates were searched. Selection after screening many predictors can make conventional post-selection p-values and intervals overconfident if treated as though the model were prespecified.
  • Calling a selected association causal. A selected predictor may be associated with sales, but an observational regression search alone does not show that changing the predictor would change sales.
  • Comparing scores from different observations. The score comparison shown here assumes candidate models use the same response observations and compatible likelihood calculations.
Key takeaway: Stepwise selection is a rule-based search through a prespecified model set. Compare models using a clearly stated criterion, examine whether selections persist across appropriate resamples, and report close alternatives and search limitations rather than presenting the selected model as uniquely established.

Check Your Understanding

Answer each question using the definitions and calculations above.

  1. In forward selection, what does the procedure do at each step, and what determines when it stops?
  2. A candidate addition changes \(RSS\) from 180 to 150 in a sample of \(n=24\) and adds one slope. Write the change in \(AIC^*\) and determine whether it is positive or negative.
  3. In 20 resampled searches, a predictor is selected 13 times. What is its selection frequency, and what does that frequency not establish?
  4. Why can screening many candidate predictors make a small conventional p-value less persuasive than it would be for a prespecified single predictor?
  5. Two models have nearly equal AIC-style scores. What can be concluded from their ranking, and what cannot be concluded?