Tutorials › Regression Analysis (Undergraduate) › Choosing Model Size Across Subsets

Subset and Stepwise Selection · Tutorial 650 of 991

Choosing Model Size Across Subsets

Compare best-subset models of different sizes using four criteria, and understand why their penalties can lead to different choices.

Advanced 12 min read

What You'll Learn

  • Calculate adjusted R-squared for candidate models of different sizes
  • Use Mallows’ Cp and understand its full-model variance reference
  • Compare AIC and BIC using consistent parameter counts
  • Interpret when criteria agree or recommend different model sizes
  • Check the assumptions and limitations behind criterion-based choices

Why Model Size Needs a Criterion

In a best-subset analysis, one candidate model is available for each number of predictors: typically, the model with the smallest residual sum of squares among the subsets of that size. Adding predictors cannot increase the training residual sum of squares, so choosing the model with the smallest training error alone always favors the largest candidate. Yet a larger model also uses more parameters. The practical question is how to balance fit against complexity.

Adjusted R-squared, Mallows’ Cp, AIC, and BIC all make that balance in different ways. They do not necessarily select the same model size, and none is a universal rule for which model is scientifically correct. The comparisons below assume candidates use the same response, the same observations, and the same response scale. In the usual Gaussian linear-regression setting, the errors are independent, have mean zero and constant variance, and are normally distributed when using the likelihood-based AIC and BIC formulas.

Definition: Let \(n\) be the sample size and let a candidate model contain \(k\) predictors and an intercept. Its total number of estimated regression coefficients is \(q=k+1\). Write \(RSS_k\) for its residual sum of squares and \(TSS=\sum_{i=1}^{n}(y_i-\bar{y})^2\) for the total sum of squares. In the formulas below, AIC and BIC use the Gaussian likelihood with the error variance estimated from each candidate; shared constants are omitted, so the resulting values are for comparing these candidates on the same data.

Four Criteria and Their Penalties

For a model with \(k\) predictors, adjusted R-squared is

$$ R^2_{\mathrm{adj},k} =1-\frac{RSS_k/(n-k-1)}{TSS/(n-1)}. $$

It compares the model’s residual mean square with the sample variance of the response. Unlike ordinary \(R^2\), adjusted R-squared can decrease when a predictor is added. Among the candidates, a larger value is preferred.

Mallows’ Cp uses the residual variance estimate from the largest, full candidate model. If that model has \(K\) predictors, define \(s^2_{\mathrm{full}}=RSS_K/(n-K-1)\). For a candidate with \(k\) predictors, the criterion is

$$ C_{p,k}=\frac{RSS_k}{s^2_{\mathrm{full}}}-n+2(k+1). $$

A comparatively small Cp is desirable, but its size should also be judged against the candidate’s parameter count \(q=k+1\). A Cp near \(q\) is often taken as evidence that the model’s lack of fit is not large relative to its complexity. This is a diagnostic guideline, not a guarantee that the model is correct.

For the same Gaussian model, convenient comparison forms of AIC and BIC are

$$ \mathrm{AIC}_k=n\log(RSS_k/n)+2(k+1), \qquad \mathrm{BIC}_k=n\log(RSS_k/n)+(k+1)\log n. $$

The terms \(2(k+1)\) and \((k+1)\log n\) penalize estimated coefficients, including the intercept. With these conventions, smaller AIC or BIC is preferred. BIC’s per-parameter penalty exceeds AIC’s when \(\log n>2\); the difference between their penalties depends on sample size.

Key takeaway: Maximize adjusted R-squared; minimize AIC or BIC. For Cp, look for a small value in relation to its parameter count, using the full model’s residual variance as the reference. These criteria reward fit and penalize complexity in different ways.

Worked Comparison Across Model Sizes

The following hypothetical best-subset results use \(n=50\), \(TSS=1000\), and candidate models with \(k=0,\ldots,5\) predictors. The \(k=0\) candidate contains only an intercept. The largest candidate has \(K=5\), so its residual degrees of freedom are \(50-5-1=44\), and its residual variance estimate is \(s^2_{\mathrm{full}}=503/44=11.4318\). Thus the reference variance for Cp is defined from the largest candidate in this set.

Predictors \(k\)\(RSS_k\)Adjusted \(R^2\)CpAICBIC
010000.000039.48151.8153.7
17000.285415.23136.0139.8
26100.36409.360131.1136.8
35700.39287.861129.7137.3
45350.41746.799128.5138.1
55030.43986.000127.4138.9

Worked Example: Computing Adjusted R-squared and Cp

For the candidate with \(k=3\), \(RSS_3=570\). It has \(50-3-1=46\) residual degrees of freedom. Its adjusted R-squared is

$$ R^2_{\mathrm{adj},3} =1-\frac{570/46}{1000/49} =1-\frac{27930}{46000} =0.3928. $$

For Cp, use the full-model variance estimate already calculated, \(503/44\), and remember that this candidate has \(q=3+1=4\) estimated regression coefficients:

$$ C_{p,3} =\frac{570}{503/44}-50+2(4) =\frac{25080}{503}-42 =7.861. $$

The Cp value is larger than this model’s parameter count of 4. That is a comparison to consider, not proof that the candidate must be rejected. Cp’s interpretation depends on the full model providing a useful estimate of the error variance.

In this table, adjusted R-squared is largest at \(k=5\), and AIC is smallest there as well. Cp is also smallest at \(k=5\), where it equals 6, the number of estimated coefficients. BIC instead reaches its minimum at \(k=2\). These results illustrate that a more conservative complexity penalty can favor a smaller candidate, even when the largest model improves its fit. They do not establish that either selected model is the true or scientifically best model.

Why the Criteria Can Disagree

A short calculation shows how AIC and BIC compare the gain in fit from adding one predictor with the extra penalty. If a model with \(k\) predictors has residual sum of squares \(RSS_k\), the change in AIC when moving to the \((k+1)\)-predictor model is

$$ \mathrm{AIC}_{k+1}-\mathrm{AIC}_k =n\log\left(\frac{RSS_{k+1}}{RSS_k}\right)+2. $$

The corresponding change in BIC replaces 2 with \(\log n\). Since the fit term is negative when RSS falls, adding a predictor improves a criterion only if that reduction outweighs its penalty. For \(n=50\), BIC charges \(\log(50)=3.912\) for one additional coefficient, compared with AIC’s penalty of 2.

Worked Example: Comparing the Last Two Candidates

The four-predictor candidate has \(RSS_4=535\); the five-predictor candidate has \(RSS_5=503\). For AIC, the change on adding the fifth predictor is

$$ \mathrm{AIC}_5-\mathrm{AIC}_4 =50\log(503/535)+2 \approx -1.084. $$

Because the change is negative, AIC favors the five-predictor candidate. For BIC, the same fit improvement is compared with a larger penalty:

$$ \mathrm{BIC}_5-\mathrm{BIC}_4 =50\log(503/535)+\log(50) \approx 0.8283. $$

This change is positive, so BIC favors the four-predictor candidate over the five-predictor candidate. The difference is not a calculation error: BIC’s additional penalty for this one coefficient is larger at this sample size. BIC’s minimum across the full table is at \(k=2\), so this pairwise comparison alone does not identify its overall choice.

A Justification for the Adjusted R-squared Penalty

Ordinary R-squared is \(1-RSS_k/TSS\). It cannot decrease when a predictor is added because the larger model can reproduce the smaller model by assigning the new coefficient a value of zero. Adjusted R-squared instead divides each sum of squares by its associated degrees of freedom:

$$ R^2_{\mathrm{adj},k} =1-\frac{RSS_k/(n-k-1)}{TSS/(n-1)} =1-\left(\frac{RSS_k}{TSS}\right) \left(\frac{n-1}{n-k-1}\right). $$

The first ratio reflects improvement in fit, while the factor \((n-1)/(n-k-1)\) grows as predictors are added. Therefore a lower RSS does not automatically make adjusted R-squared larger: the reduction in RSS must be sufficient to offset the degrees-of-freedom adjustment. This explains why adjusted R-squared penalizes model size, though it is not the same penalty as AIC’s or BIC’s.

Worked Example: Checking the Adjusted R-squared Change

In the table, the four-predictor model has adjusted \(R^2=0.4174\), and the five-predictor model has adjusted \(R^2=0.4398\). The increase is \(0.4398-0.4174=0.0224\), so adjusted R-squared favors the five-predictor candidate. This conclusion accounts for the additional predictor: the fit improvement is large enough to overcome the degrees-of-freedom adjustment. It describes relative fit under this criterion, not a causal effect or evidence that every included predictor is useful in another sample.

Conditions, Limits, and Common Mistakes

Before interpreting a criterion comparison, check that all candidates were fitted to the same observations and response on the same scale. AIC and BIC comparisons also require the same likelihood basis; changing the response scale or comparing criteria computed with inconsistent parameter counts can make numerical differences misleading. For Cp, the full-model residual variance must be a defensible reference. If the full candidate is inadequate or its variance estimate is unstable, the resulting Cp values may not be informative.

The candidates also matter. A best-subset search finds the best-fitting subset at each specified size among the predictors and constraints supplied to the search; it does not establish that those predictors, the linear form, or the error assumptions are appropriate. A criterion’s preferred candidate is conditional on that candidate set and on the criterion used. Subject-matter considerations and model diagnostics remain relevant.

  • Mistake: Choose the lowest RSS. Because RSS cannot increase as predictors are added, this simply favors the largest candidate. Compare fit against a complexity penalty instead.
  • Mistake: Minimize adjusted R-squared. Adjusted R-squared is a “larger is better” criterion; AIC and BIC are minimized.
  • Mistake: Count only predictors in AIC, BIC, or Cp. Under the formulas here, \(q=k+1\), because the intercept is also estimated.
  • Mistake: Treat agreement as proof, or disagreement as a failure. Agreement can be reassuring, but the criteria measure different trade-offs. Disagreement makes the dependence on the penalty visible; it does not identify one criterion as automatically correct.
Key takeaway: Use adjusted R-squared, Cp, AIC, and BIC as distinct summaries of fit and complexity across the available best-subset candidates. Report which criterion favors which size, check that its assumptions and comparisons are appropriate, and avoid presenting its selection as definitive.

Check Your Understanding

Answer each question using the definitions and comparisons in this tutorial.

  1. A candidate model has 4 predictors and an intercept. What value of \(q\) should be used in the AIC and BIC penalty terms?
  2. Why can ordinary R-squared not decrease when a predictor is added, and how does adjusted R-squared account for model size?
  3. For AIC, what does a negative value of \(\mathrm{AIC}_{k+1}-\mathrm{AIC}_k\) indicate about the two candidates?
  4. Why does Mallows’ Cp require a reference estimate of error variance, and where does it come from in the formula used here?
  5. Suppose adjusted R-squared favors one candidate while BIC favors a smaller one. Does this establish that one calculation is wrong? Explain.