Tutorials › Regression Analysis (Undergraduate) › Deriving the Adjusted R-Squared Penalty

Model Fit and Nested Comparisons · Tutorial 254 of 991

Deriving the Adjusted R-Squared Penalty

See why adjusted R-squared applies a degrees-of-freedom penalty and calculate how much residual sum of squares must fall for the measure to rise.

Intermediate 10 min read

What You'll Learn

  • Express adjusted R-squared as one minus the ratio of residual mean square to total mean square.
  • Identify the conditions needed for the adjusted R-squared formula to be defined.
  • Derive the residual-sum-of-squares reduction threshold when predictors are added.
  • Determine whether a specified reduction makes adjusted R-squared rise, fall, or stay unchanged.
  • Distinguish the algebraic fit comparison from assumptions needed for statistical inference.

Why Adjusted R-Squared Has a Penalty

Ordinary \(R^2\) summarizes the fraction of variation around the sample mean accounted for by a regression fit. When predictors are added to a least-squares model, its residual sum of squares cannot increase, so ordinary \(R^2\) cannot decrease. That makes ordinary \(R^2\) useful for describing fit, but by itself it does not account for how many predictor coefficients were estimated.

Adjusted \(R^2\) makes a specific correction: it compares residual variation per residual degree of freedom with total variation per total degree of freedom. This tutorial derives that expression and uses it to answer a practical question: when a model uses more predictors, how much must the residual sum of squares (RSS) decrease for adjusted \(R^2\) to increase?

Definition and Conditions

Consider a least-squares regression model with an intercept and \(p\) predictor coefficients, fit to the same \(n\) observations on a quantitative response. Let \(y_i\) be the observed response and \(\hat{y}_i\) its fitted value. Define the residual sum of squares as \(\mathrm{RSS}=\sum_{i=1}^{n}(y_i-\hat{y}_i)^2\), and the total sum of squares around the sample mean as \(\mathrm{TSS}=\sum_{i=1}^{n}(y_i-\bar{y})^2\).

The intercept model has \(p+1\) estimated coefficients. If the design matrix has full column rank, the residual degrees of freedom are \(n-p-1\); the total degrees of freedom around the sample mean are \(n-1\). The corresponding mean squares are the sums of squares divided by their degrees of freedom.

Definition: For a regression with an intercept, \(p\) predictor coefficients, and \(n\) observations, adjusted R-squared is $$ R^2_{\mathrm{adj}} = 1-\frac{\mathrm{RSS}/(n-p-1)}{\mathrm{TSS}/(n-1)}. $$ This formula requires a full-rank design, positive residual degrees of freedom \(n-p-1>0\), and \(\mathrm{TSS}>0\). The last condition means that the observed response is not constant, so the total mean square is positive.

The ratio compares two mean squares, each measured in squared response units. Their ratio, and therefore adjusted \(R^2\), is unitless. The condition \(\mathrm{TSS}>0\) matters: if every observed response is identical, then \(\mathrm{TSS}=0\), and the denominator of the ratio is zero. Full rank and positive residual degrees of freedom alone do not prevent that problem.

This is an algebraic fit summary. The formula and the comparisons below do not require normally distributed errors or an independence assumption. Such assumptions can matter for inference about regression parameters, but they are not needed to calculate adjusted \(R^2\) from a given fit.

Worked Example: Calculating Adjusted R-Squared From Mean Squares

Suppose a hypothetical regression relates weekly energy use, measured in kilowatt-hours, to two predictors for \(n=20\) buildings. The fitted model has full rank, \(\mathrm{TSS}=190\) squared kilowatt-hours, and \(\mathrm{RSS}=72\) squared kilowatt-hours. Calculate ordinary and adjusted \(R^2\).

The response is not constant because \(\mathrm{TSS}=190>0\). The residual degrees of freedom are \(20-2-1=17\), which is positive, so both mean squares in the adjusted \(R^2\) ratio are defined. The total degrees of freedom are \(20-1=19\).

Ordinary \(R^2\) is \(1-\mathrm{RSS}/\mathrm{TSS}\):

$$ R^2=1-\frac{72}{190}=0.6211. $$

For adjusted \(R^2\), the residual mean square is \(72/17=4.235\) squared kilowatt-hours, and the total mean square is \(190/19=10.00\) squared kilowatt-hours. Therefore,

$$ R^2_{\mathrm{adj}} = 1-\frac{72/17}{190/19} = 1-\frac{4.235}{10.00} = 0.5765. $$

The adjusted value is lower than ordinary \(R^2\) here because the correction compares variation per degree of freedom rather than comparing the unadjusted sums of squares.

Deriving the Reduction Threshold

Now compare two fits to the same response observations, with an intercept in each. Suppose the first fit has \(p\) predictor coefficients and RSS \(\mathrm{RSS}_{\mathrm{old}}\). The second has \(q\) additional predictor coefficients and RSS \(\mathrm{RSS}_{\mathrm{new}}\). Write \(d=n-p-1\) for the first fit's residual degrees of freedom; the second has \(d-q\). Assume both fits have full rank, both residual degrees of freedom are positive, and \(\mathrm{TSS}>0\). Because the response and observations are unchanged, both fits have the same positive total mean square, \(\mathrm{TSS}/(n-1)\).

Adjusted \(R^2\) rises exactly when the new residual mean square is smaller than the old one. To see this, subtract each residual-mean-square ratio from one. Since the total mean square is common and positive, the comparison reduces to comparing the two residual mean squares:

$$ R^2_{\mathrm{adj,new}}>R^2_{\mathrm{adj,old}} \quad\Longleftrightarrow\quad \frac{\mathrm{RSS}_{\mathrm{new}}}{d-q} < \frac{\mathrm{RSS}_{\mathrm{old}}}{d}. $$

Let \(\Delta\mathrm{RSS}=\mathrm{RSS}_{\mathrm{old}}-\mathrm{RSS}_{\mathrm{new}}\), the amount by which RSS falls. Substituting \(\mathrm{RSS}_{\mathrm{new}}=\mathrm{RSS}_{\mathrm{old}}-\Delta\mathrm{RSS}\) into the inequality gives

$$ \frac{\mathrm{RSS}_{\mathrm{old}}-\Delta\mathrm{RSS}}{d-q} < \frac{\mathrm{RSS}_{\mathrm{old}}}{d}. $$

Both degrees of freedom are positive, so multiplying by \(d(d-q)\) preserves the inequality. Expanding and cancelling the shared term gives

$$ d(\mathrm{RSS}_{\mathrm{old}}-\Delta\mathrm{RSS}) < (d-q)\mathrm{RSS}_{\mathrm{old}} \quad\Longleftrightarrow\quad d\,\Delta\mathrm{RSS}>q\,\mathrm{RSS}_{\mathrm{old}}. $$

Dividing by \(d>0\) yields the threshold. Equality means adjusted \(R^2\) is unchanged; a smaller reduction makes it fall.

Theorem: When \(q\) predictor coefficients are added, adjusted \(R^2\) increases if and only if $$ \Delta\mathrm{RSS} > q\frac{\mathrm{RSS}_{\mathrm{old}}}{n-p-1}. $$ The right-hand side is \(q\) times the old model's residual mean square. A reduction equal to this threshold leaves adjusted \(R^2\) unchanged; a reduction below it lowers adjusted \(R^2\).

The threshold grows with \(q\): adding more coefficients requires a larger total RSS reduction to compensate for the added degrees-of-freedom penalty. It is not a fixed amount for every data set. It depends on the old fit's residual mean square. The condition is an exact algebraic comparison, not a significance test and not a rule that the added predictors are practically useful.

Worked Example: A Reduction That Clears the Threshold

For a hypothetical outcome measured on \(n=30\) observations, an old model has three predictor coefficients, \(\mathrm{TSS}=300\), and \(\mathrm{RSS}_{\mathrm{old}}=130\). A proposed fit adds \(q=2\) predictor coefficients and has \(\mathrm{RSS}_{\mathrm{new}}=118\). Both designs have full rank and positive residual degrees of freedom, and the common TSS is positive. Does adjusted \(R^2\) increase?

The old residual degrees of freedom are \(30-3-1=26\), so its residual mean square is \(130/26=5.000\). The required reduction is

$$ q\frac{\mathrm{RSS}_{\mathrm{old}}}{n-p-1} = 2\left(\frac{130}{26}\right) = 10. $$

The actual reduction is \(130-118=12\), which exceeds 10. Therefore adjusted \(R^2\) rises. Direct calculation confirms this: the total mean square is \(300/29=10.345\), the old adjusted value is

$$ 1-\frac{130/26}{300/29} = 1-\frac{145}{300} = 0.5167, $$

and the new residual degrees of freedom are \(30-5-1=24\). The new adjusted value is

$$ 1-\frac{118/24}{300/29} = 1-\frac{3422}{7200} = 0.5247. $$

Thus the direct calculations agree with the threshold: the decrease in RSS is large enough to raise adjusted \(R^2\).

Worked Example: A Reduction That Does Not Clear the Threshold

A hypothetical model for an outcome measured on \(n=24\) observations has \(p=2\) predictor coefficients, \(\mathrm{TSS}=230\), and \(\mathrm{RSS}_{\mathrm{old}}=84\). A fit with one additional coefficient has \(\mathrm{RSS}_{\mathrm{new}}=81\). Both fits have full rank, positive residual degrees of freedom, and the response is not constant. Determine the direction of change in adjusted \(R^2\).

The old residual degrees of freedom are \(24-2-1=21\), and its residual mean square is \(84/21=4\). With \(q=1\), the required reduction is \(1(4)=4\). But the actual reduction is \(84-81=3\), which is below the threshold. Adjusted \(R^2\) must fall.

The total mean square is \(230/23=10\). The old adjusted value is

$$ 1-\frac{84/21}{230/23}=1-\frac{4}{10}=0.6000. $$

The new residual degrees of freedom are \(24-3-1=20\), and the new residual mean square is \(81/20=4.050\). Its adjusted value is

$$ 1-\frac{81/20}{230/23}=1-\frac{4.050}{10}=0.5950. $$

Although RSS fell, it did not fall enough to offset the additional coefficient's penalty, so adjusted \(R^2\) decreased.

Using the Penalty Carefully

For a fit with an intercept and \(p\) predictors, ordinary \(R^2\) uses the ratio \(\mathrm{RSS}/\mathrm{TSS}\), whereas adjusted \(R^2\) uses the ratio of mean squares. The practical comparison is therefore not simply “did RSS fall?” but “did RSS fall enough per added coefficient?” If \(q\) coefficients are added, compare the RSS reduction with \(q\) times the old residual mean square.

A common mistake is to reason that any decrease in RSS must increase adjusted \(R^2\). That conclusion confuses ordinary \(R^2\), which cannot decrease when predictors are added in a least-squares fit on the same observations, with adjusted \(R^2\), which accounts for residual degrees of freedom. For example, a reduction of three units in the second worked example was real, but the one added coefficient required a reduction greater than four units for adjusted \(R^2\) to rise.

The threshold also has limits as a decision rule. It describes how one numerical fit summary changes; it does not establish that an added predictor has a causal effect, that the model predicts well on new observations, or that the change is statistically significant. The comparison is meaningful only when the response, observations, and total sum of squares are the same for both fits and the adjusted values are defined.

Check Your Understanding

Use the mean-square ratio and reduction threshold to answer these questions.

  1. For a model with \(n=40\), \(p=4\), and \(\mathrm{RSS}=180\), what is its residual mean square, and what RSS reduction is required for adjusted \(R^2\) to rise if two coefficients are added?
  2. Why must \(\mathrm{TSS}>0\) be required, even when the design has full rank and positive residual degrees of freedom?
  3. If the required threshold is 8 and the observed RSS reduction is exactly 8, what happens to adjusted \(R^2\)? Explain using the derived inequality.
  4. Two fits use the same response observations but have different total sums of squares. Can the common-total-mean-square comparison in the derivation be used directly? Explain.
  5. In your own words, why does a decrease in RSS alone not guarantee an increase in adjusted \(R^2\)?