Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

We return to the Dwaine Studios cities of Chapters 6 and 7 (7.1 The model and least squares in matrix form), where a chain of portrait studios in mid-sized towns wants to decide, for a city it has never entered, how much a new studio will sell. Two recorded numbers about each of its 21 cities plausibly drive that answer: the target population targtpop (thousands of persons under 16, the pool of potential family-portrait customers) and the disposable income dispoinc (thousands of dollars per person, how much those families have to spend), together predicting annual sales (thousands of dollars).

In Chapter 6 we built this data into matrices, and in Chapter 7 we solved the normal equations XXb=XY\mathbf{X}'\mathbf{X}\mathbf{b} = \mathbf{X}'\mathbf{Y} to get the least-squares coefficients b=(XX)1XY=(68.86, 1.45, 9.37)\mathbf{b} = (\mathbf{X}'\mathbf{X})^{-1}\mathbf{X}'\mathbf{Y} = (-68.86,\ 1.45,\ 9.37); see 7.1 The model and least squares in matrix form. That was the FIT stage. This chapter is about what comes after: reading those three numbers honestly, deciding which predictors are earning their place, and knowing the traps that wait for anyone who reports a coefficient without thinking. Figure 1 shows the raw material, sales against each predictor one at a time.

Two side-by-side scatterplots for the 21 Dwaine Studios cities. The left panel plots sales in thousands of dollars against target population, showing a strong upward straight-line trend. The right panel plots sales against disposable income, showing a weaker but still positive upward trend with more scatter.

Figure 1:Dwaine sales against each predictor separately. Both slopes are positive: bigger target population and higher income each go with higher sales. The chapter’s work is to untangle these two overlapping stories into one model that holds both at once.

Both pictures slope up, so both predictors look useful. But the two predictors also move together (richer cities tend to have different age profiles), and that overlap is the whole difficulty of multiple regression. A coefficient in a multiple regression is not the slope you would see in a one-predictor scatterplot. It answers a more careful question, and this chapter is about asking that question correctly, testing whether a predictor belongs, and seeing the answer in a picture.

8.1 Reading the coefficients of a multiple regression

Intuition

The fit handed us three numbers. This section is about what each one honestly means, because the obvious reading is the wrong one. The short version: a number in a multiple regression answers a more careful question than the same-looking number in a one-predictor plot.

The Dwaine fit is sales^=68.86+1.45targtpop+9.37dispoinc\widehat{\text{sales}} = -68.86 + 1.45\,\text{targtpop} + 9.37\,\text{dispoinc}. It is tempting to read the 9.37 the same way we read a simple-regression slope: “raise income by one unit and sales go up 9.37.” That reading is wrong in a specific and important way. In a one-predictor world, moving income means moving whatever else travels with income. In the multiple regression, the coefficient on income has already accounted for target population. It measures what income adds after target population has said everything it can say.

The clean phrase is: a multiple regression coefficient is a partial slope (Definition 8.1). It is the change in the mean response for a one-unit change in that predictor, holding the other predictors fixed. “Holding fixed” is what makes it different from the marginal picture in Figure 1, where nothing is held fixed and every predictor drifts along with every other.

Formula

The multiple linear regression model with p1p-1 predictors is stated in Definition 8.2.

Term by term:

In words: each βk\beta_k is the effect of its own predictor after the other predictors in the model have been given their say. Change what else is in the model and you change the question, so you can change the coefficient.

R

The fit itself is one line; the reading is the hard part. We start from the same 21 cities.

dwaine <- read.csv("data/dwaine.csv")
fit <- lm(sales ~ targtpop + dispoinc, data = dwaine)
round(coef(fit), 4)
(Intercept)    targtpop    dispoinc
   -68.8571      1.4546      9.3655

The fitted model is no longer a line but a plane sitting above the (targtpop, dispoinc) floor, as in Figure 2. Each coefficient is the tilt of that plane in one direction. The partial slope for income is how steeply the plane rises as you walk in the income direction while keeping your population coordinate fixed.

A three-dimensional scatterplot of the 21 Dwaine cities with target population and disposable income on the floor axes and sales on the vertical axis, with the fitted least-squares plane drawn through the point cloud. The plane tilts upward in both floor directions, more steeply along the population axis.

Figure 2:The Dwaine fit is a plane, not a line. Walking in the target-population direction with income held fixed climbs the plane at rate 1.45; walking in the income direction with population held fixed climbs it at rate 9.37. The two partial slopes are the two tilts of this one surface.

8.2 The limits of “holding the others fixed”

Intuition

“Holding the other predictors fixed” is the correct interpretation, and it is also where careful people get into trouble. The phrase is a statement about the arithmetic of the fitted plane: it is always true that the coefficient is the plane’s tilt in one direction with the other coordinates pinned. The trouble is that the sentence quietly promises something the data may not support, that you could actually find, or create, two cities identical in every predictor but one. When predictors move together, that promise is fiction.

Look again at the Dwaine predictors. Target population and disposable income have a correlation of 0.78. Cities with many young families are systematically different in income from cities with few. So “two cities with the same target population but different income” describes a thinner slice of reality than it sounds, and “hold population fixed and push income far” can walk you clean off the cloud of cities that ever existed. The coefficient is still computable and still meaningful as a description of the fitted surface. What weakens is the causal daydream that you could intervene on one predictor and leave the others undisturbed.

The mechanism: a coefficient depends on its companions

A coefficient is not a property of a predictor. It is a property of a predictor and the company it keeps. Add or remove another predictor and the coefficient can move, sometimes a little, sometimes enough to change sign. Figure 3 shows the Dwaine income story both ways: the steep marginal slope when income stands alone, and the gentler partial slope once population is accounted for.

A scatterplot of Dwaine sales against disposable income, with points colored by target population from light (low) to dark (high). A steep dashed line shows the simple regression of sales on income alone, slope 31.17. Shorter solid segments within bands of similar population color show a gentler within-band slope near 9.37, illustrating that at fixed population the income effect is smaller.

Figure 3:Two answers to “how does income relate to sales.” The steep dashed line ignores population and reports slope 31.17. Within groups of cities that share a population level (same color), the income slope is much gentler, near the partial slope 9.37. The difference is the population that rides along with income in the raw data.

When “holding fixed” describes empty space

The deeper limit is geometric. Holding population fixed and varying income traces a line across the (targtpop, dispoinc) floor. If the data cloud is a tilted ellipse, because the two predictors are correlated, then most of that line lies outside the cloud. The model will still return a fitted value there, but it is extrapolating into a region where no city has ever been observed, and no data constrain the answer. We return to this in 8.7 Two dangers: hidden extrapolation and lurking variables with a picture; for now, hold the warning: a coefficient can be perfectly estimated and still describe a comparison you can never actually make.

The widget below does the holding fixed for you, one population level at a time, so you can watch the gentle partial slope and the steep marginal slope stop looking like rivals.

Slice the fitted plane at one target population and slide that population up and down. The partial slope stays 9.37 while the marginal line, slope 31.17, only traces where those slices sit.

8.3 Extra sums of squares

Intuition

We need a way to ask “how much does a predictor add?” that does not depend on staring at a coefficient. The natural measure is how much unexplained variation a predictor removes when it joins a model that already has the others. Fit the model without the predictor and record its error sum of squares; add the predictor and record the new, smaller error sum of squares; the drop is the predictor’s extra sum of squares (Definition 8.3). It is the variation that only this predictor could mop up, once the others have done their part.

Two facts make this work. First, adding a predictor can never make the error sum of squares larger (we prove this below), so the drop is never negative. Second, the total variation SSTO\mathrm{SSTO} in YY does not depend on the model, so a smaller SSE\mathrm{SSE} means a larger SSR\mathrm{SSR}: the extra sum of squares is variation moved from the “unexplained” column to the “explained” column.

A picture makes the “only this predictor could mop up” idea concrete. Think of the response’s variation as a target, and each predictor as a circle that covers the part it can explain. When two predictors are correlated, their circles overlap, and the shared piece can be credited to only one of them: whichever entered the model first. The extra sum of squares of the second predictor is just its own crescent, the part of its circle that the first predictor’s circle did not already cover. Figure 5 draws this for the body-fat predictors we work with next.

A schematic Venn diagram. A large faint circle is the total variation in body fat. A blue circle labeled SSR(triceps) = 352.3 and an orange circle labeled SSR(thigh given triceps) = 33.2 sit inside it and overlap in a shared region. An arrow points to the part of the big circle outside both predictor circles, labeled error SSE. Areas are schematic, not to scale.

Figure 5:Extra sum of squares as overlapping circles. Triceps enters first and claims the whole shared overlap, so thigh, entering second, gets credit only for its own crescent (33.2), not the larger region it shares with triceps. This is why a later predictor’s extra sum of squares is small when the predictors overlap, and why reordering them changes the split.

Formula

For a model already containing a set of predictors, write SSE()\mathrm{SSE}(\cdot) for its error sum of squares. The extra sum of squares of X2X_2 given X1X_1 is defined in Definition 8.3.

In words: SSR(X2X1)\mathrm{SSR}(X_2 \mid X_1) is the extra explained variation you buy by adding X2X_2 to a model that already has X1X_1. The vertical bar reads “given” or “adjusted for.”

Extra sums of squares chain into a decomposition of the total regression sum of squares. Adding predictors one at a time,

SSR(X1,X2,X3)=SSR(X1)+SSR(X2X1)+SSR(X3X1,X2),\mathrm{SSR}(X_1, X_2, X_3) = \mathrm{SSR}(X_1) + \mathrm{SSR}(X_2 \mid X_1) + \mathrm{SSR}(X_3 \mid X_1, X_2),

which is exactly what the sequential (Type I) ANOVA table prints, one row per predictor in the order you list them. Because the order is a choice, so is the split: reorder the predictors and the pieces change, though their total SSR\mathrm{SSR} does not.

Derivation (adding a predictor cannot increase SSE)

Proof. Let the reduced model use the predictors in a set RR and the full model use RR together with one more predictor, so the full model’s columns span a larger space. By 7.2 The geometry of least squares, the fitted vector is the orthogonal projection of Y\mathbf{Y} onto the column space of the design matrix, and SSE\mathrm{SSE} is the squared distance from Y\mathbf{Y} to that space. Every fitted vector the reduced model can produce is also available to the full model (set the extra coefficient to zero), so the full model’s column space contains the reduced model’s. Projecting onto a larger subspace lands at least as close to Y\mathbf{Y}:

SSE(full)=minvfull spaceYv2    minvreduced spaceYv2=SSE(reduced).\mathrm{SSE}(\text{full}) = \min_{\mathbf{v} \in \text{full space}} \lVert \mathbf{Y} - \mathbf{v}\rVert^2 \;\le\; \min_{\mathbf{v} \in \text{reduced space}} \lVert \mathbf{Y} - \mathbf{v}\rVert^2 = \mathrm{SSE}(\text{reduced}).

Therefore SSR(X2X1)=SSE(X1)SSE(X1,X2)0\mathrm{SSR}(X_2 \mid X_1) = \mathrm{SSE}(X_1) - \mathrm{SSE}(X_1, X_2) \ge 0, with equality only when the added predictor buys nothing (its fitted contribution is already in the reduced space). \blacksquare

R and Python

The classic worked example is not Dwaine but the ALRM body-fat data: 20 men, percent body fat measured by underwater weighing, against three tape-measure predictors, triceps skinfold, thigh circumference, and midarm circumference. It is built for this section because the predictors overlap heavily, so order matters a lot.

Figure 6 draws the decomposition as a stacked bar: the total variation in body fat split into the sequential pieces plus the leftover error.

A single horizontal stacked bar showing the total sum of squares of body fat, 495.4, divided into four segments: a large segment for triceps (352.3), a smaller one for thigh given triceps (33.2), a still smaller one for midarm given triceps and thigh (11.5), and the residual error (98.4). Each segment is labeled with its value.

Figure 6:The total variation in body fat, split by sequential extra sums of squares. The first predictor claims the lion’s share; each later predictor adds less because the tape-measure predictors overlap. The rightmost segment is the variation no predictor explained.

8.4 The general linear test

Intuition

Extra sums of squares measure how much a predictor adds; now we ask whether that addition is more than noise would produce. The tool is a comparison of two models, one reduced (without the terms in question) and one full (with them). If the extra terms are worthless, the full model’s error sum of squares will be only trivially smaller than the reduced model’s, a drop no bigger than random scatter would give. If the extra terms matter, the drop will be large relative to the noise level. The general linear test (Definition 8.5) turns “large relative to noise” into a single FF statistic.

Formula

Let the full model have SSE(F)\mathrm{SSE}(F) on dfF=npFdf_F = n - p_F degrees of freedom and the reduced model SSE(R)\mathrm{SSE}(R) on dfR=npRdf_R = n - p_R, where the reduced model is the full model with some coefficients forced to zero. The general linear test statistic and its null distribution are stated in Theorem 8.6.

In words: FF^{*} is the extra variation explained per dropped coefficient, measured in units of the noise variance. Under the reduced model (the dropped coefficients really are zero) with normal errors, FF(q, npF)F^{*} \sim F(q,\ n - p_F), and a large FF^{*} is evidence against the reduced model. We reject the reduced model when FF^{*} exceeds the upper FF critical value, equivalently when its pp-value is small.

Derivation (the test statistic and its distribution)

Proof. Write Y^F\widehat{\mathbf{Y}}_F and Y^R\widehat{\mathbf{Y}}_R for the fitted vectors of the full and reduced models. By 7.2 The geometry of least squares each is the orthogonal projection of Y\mathbf{Y} onto a column space, and the reduced space is a subspace of the full space. Split the reduced model’s residual through the full fit:

YY^R=(YY^F)full residual+(Y^FY^R)extra fit.\mathbf{Y} - \widehat{\mathbf{Y}}_R = \underbrace{(\mathbf{Y} - \widehat{\mathbf{Y}}_F)}_{\text{full residual}} + \underbrace{(\widehat{\mathbf{Y}}_F - \widehat{\mathbf{Y}}_R)}_{\text{extra fit}}.

The full residual is orthogonal to the entire full column space, and Y^FY^R\widehat{\mathbf{Y}}_F - \widehat{\mathbf{Y}}_R lies inside that space, so the two pieces are perpendicular. Pythagoras gives

SSE(R)=SSE(F)+Y^FY^R2,\mathrm{SSE}(R) = \mathrm{SSE}(F) + \lVert \widehat{\mathbf{Y}}_F - \widehat{\mathbf{Y}}_R \rVert^2,

so the numerator sum of squares SSE(R)SSE(F)=Y^FY^R2\mathrm{SSE}(R) - \mathrm{SSE}(F) = \lVert \widehat{\mathbf{Y}}_F - \widehat{\mathbf{Y}}_R\rVert^2 is the squared length of the extra-fit vector, which lives in a subspace of dimension q=pFpRq = p_F - p_R. That is where its qq degrees of freedom come from. Figure 7 draws this right triangle. \blacksquare

A right-triangle diagram. The response vector Y sits at the top. A long leg drops from Y to the full-model fit Y-hat-F, labeled as the full residual with length-squared SSE(F). A short horizontal leg runs from Y-hat-F to the reduced-model fit Y-hat-R inside the reduced subspace, labeled the extra fit. The hypotenuse from Y to Y-hat-R is labeled the reduced residual with length-squared SSE(R). A right-angle marker sits at Y-hat-F.

Figure 7:The general linear test is Pythagoras. The reduced residual (hypotenuse, SSE(R)) splits into the full residual (long leg, SSE(F)) and the extra-fit vector (short leg), which meet at a right angle. The test compares the short leg’s squared length, per dropped coefficient, to the noise level.

The distributional claim needs one more layer. Under the reduced model with normal errors, the two perpendicular pieces are independent, and each squared length divided by σ2\sigma^2 is a chi-square: SSE(F)/σ2χnpF2\mathrm{SSE}(F)/\sigma^2 \sim \chi^2_{n - p_F} and (SSE(R)SSE(F))/σ2χq2(\mathrm{SSE}(R) - \mathrm{SSE}(F))/\sigma^2 \sim \chi^2_{q}. Dividing each chi-square by its degrees of freedom and taking the ratio gives an F(q, npF)F(q,\ n-p_F) variable. The independence and chi-square facts rest on the normal-theory geometry of projections built in 7.3 The hat matrix. The full argument uses Cochran’s theorem on quadratic forms, which is beyond the matrix algebra this book proves. So we take those two distributional facts on the authority of that geometry, and verify the whole machine numerically below. The ALRM text, Chapter 7, gives the quadratic-form details for the reader who wants them.

Tests on a subset of coefficients

The savings data give a clean subset test, and they carry the second running thread of this chapter. In Chapter 4 you used these 50 countries to study correlation and its traps (4.2 Correlation and the regression slope); we now fit them as a multiple regression. The response sr is the aggregate personal savings rate, and the predictors are the percent of population under 15 (pop15), the percent over 75 (pop75), per-capita disposable income (dpi), and its growth rate (ddpi). Life-cycle savings theory says the two dependency measures, pop75 and dpi, might not matter once age structure and growth are in the model. That is a hypothesis about two coefficients at once, and the general linear test is built for it.

One coefficient: the test is exactly t2t^2

When the reduced model drops a single coefficient (q=1q = 1), the general linear test must agree with the tt-test that software already prints for that coefficient. It does, exactly.

Proof. From 7.4 The sampling distribution of b the estimated variance of bkb_k is s2{bk}=MSEckks^2\{b_k\} = \mathrm{MSE}\cdot c_{kk}, where ckkc_{kk} is the kk-th diagonal entry of (XX)1(\mathbf{X}'\mathbf{X})^{-1}. The extra sum of squares for dropping the single predictor XkX_k works out to SSR(Xkothers)=bk2/ckk\mathrm{SSR}(X_k \mid \text{others}) = b_k^2 / c_{kk}. Substituting both into the general linear test with q=1q = 1,

F=SSR(Xkothers)/1MSE=bk2/ckkMSE=bk2MSEckk=bk2s2{bk}=(bks{bk})2=tk2.F^{*} = \frac{\mathrm{SSR}(X_k \mid \text{others})/1}{\mathrm{MSE}} = \frac{b_k^2 / c_{kk}}{\mathrm{MSE}} = \frac{b_k^2}{\mathrm{MSE}\cdot c_{kk}} = \frac{b_k^2}{s^2\{b_k\}} = \left(\frac{b_k}{s\{b_k\}}\right)^2 = t_k^2.

So the subset test with one dropped coefficient is the square of the ordinary tt statistic, and an F(1,np)F(1, n-p) variable is the square of a tnpt_{n-p} variable. The two tests are one test. \blacksquare

Before you trust any single row of a sequential table, promote and demote the predictors yourself and watch FF^{*} re-decide whether the newest one earned its place.

Let the body-fat predictors in one at a time, in any of the six entry orders, and watch each extra sum of squares and its general linear test F* change while the total SSR does not.

8.5 Added-variable plots

Intuition

A coefficient is a single number; sometimes you want to see the partial relationship it summarizes. The obstacle is that you cannot simply plot YY against XkX_k, because that picture mixes in every other predictor. The added-variable plot (Definition 8.8), also called a partial regression plot, removes the other predictors from both axes first, then plots what is left.

Here is the recipe. To see the partial effect of XkX_k: regress YY on all the other predictors and keep the residuals eYe_Y, the part of YY the others do not explain. Regress XkX_k on all the other predictors and keep the residuals eXe_X, the part of XkX_k the others do not explain. Now plot eYe_Y against eXe_X. Both axes have been purged of the other predictors, so the plot shows the relationship between YY and XkX_k that is genuinely new. Its slope is exactly the multiple regression coefficient bkb_k, a fact we prove below, so the plot is a picture of the very number in the coefficient table.

The one rule people break is forgetting to clean the horizontal axis: they residualize YY but then plot it against the raw predictor. Figure 9 lays out the three steps so both axes get the same treatment.

A three-step flowchart. Step 1, a blue box, regress Y on the other predictors and keep the residuals e_Y, the part of Y the others miss. Step 2, an orange box, regress X_k on the other predictors and keep the residuals e_X, the part of X_k the others miss. Arrows from both lead to Step 3, a green box, plot e_Y against e_X and read the slope, which equals the coefficient b_k. A heading reads that both axes must have the other predictors removed, and a footnote warns that skipping either cleaning step breaks the equality.

Figure 9:The added-variable plot in three steps. Both axes must be purged of the other predictors before plotting, not just the response. Clean only one axis and the slope is no longer the coefficient, which is the mistake Try it 8.5 walks through.

Formula

For predictor XkX_k in a model whose other predictors are collected as X(k)X_{(-k)},

eY=YY^(from X(k)),eX=XkX^k(from X(k)),e_Y = Y - \widehat{Y}\big(\text{from } X_{(-k)}\big), \qquad e_X = X_k - \widehat{X}_k\big(\text{from } X_{(-k)}\big),

and the added-variable plot is the scatter of eYe_Y against eXe_X. The least-squares slope of that scatter equals bkb_k, the full-model coefficient on XkX_k.

Derivation (the added-variable slope equals bkb_k)

Proof (Frisch-Waugh, two-predictor case). Take the full model Y=b0+b1X1+b2X2+eY = b_0 + b_1 X_1 + b_2 X_2 + e and let X1X_1 play the role of “the other predictor” while we build the added-variable plot for X2X_2. Split X2X_2 into its projection onto {1,X1}\{\mathbf{1}, X_1\} and the leftover: X2=X^2+eXX_2 = \widehat{X}_2 + e_X, where eX{1,X1}e_X \perp \{\mathbf{1}, X_1\} by construction. Substitute into the fitted equation and group the terms that live in span{1,X1}\operatorname{span}\{\mathbf{1}, X_1\}:

Y=(b0+b1X1+b2X^2)in span{1,X1}+b2eX+e.Y = \underbrace{(b_0 + b_1 X_1 + b_2 \widehat{X}_2)}_{\text{in } \operatorname{span}\{\mathbf{1},\,X_1\}} + b_2\, e_X + e.

Now form eYe_Y by removing the {1,X1}\{\mathbf{1}, X_1\} part of YY, that is, projecting YY onto the orthogonal complement of span{1,X1}\operatorname{span}\{\mathbf{1}, X_1\}. The first group vanishes under this projection. The term eXe_X is already orthogonal to {1,X1}\{\mathbf{1}, X_1\}, so it survives untouched. The full residual ee is orthogonal to {1,X1,X2}\{\mathbf{1}, X_1, X_2\}, hence to {1,X1}\{\mathbf{1}, X_1\}, so it survives too. Therefore

eY=b2eX+e.e_Y = b_2\, e_X + e.

Finally regress eYe_Y on eXe_X through the origin (both residual vectors have mean zero). The slope is

eY,eXeX,eX=b2eX+e, eXeX2=b2+e,eXeX2=b2,\frac{\langle e_Y, e_X\rangle}{\langle e_X, e_X\rangle} = \frac{\langle b_2 e_X + e,\ e_X\rangle}{\lVert e_X\rVert^2} = b_2 + \frac{\langle e, e_X\rangle}{\lVert e_X\rVert^2} = b_2,

because e,eX=0\langle e, e_X\rangle = 0: the full residual ee is orthogonal to X2X_2 and to {1,X1}\{\mathbf{1}, X_1\}, hence to eX=X2X^2e_X = X_2 - \widehat{X}_2. The added-variable slope is exactly the multiple regression coefficient. The same argument works with any number of other predictors in place of X1X_1. \blacksquare

R and Python

An added-variable plot for disposable income in the Dwaine model. The horizontal axis is disposable income with target population removed, the vertical axis is sales with target population removed. The 21 points scatter around an upward-sloping line whose slope is labeled 9.37, matching the multiple regression coefficient.

Figure 10:The added-variable plot for income, with target population purged from both axes. Its slope is the multiple regression coefficient 9.37 exactly. The upward tilt confirms income adds information beyond population; the scatter shows how much.

An added-variable plot can also reveal the opposite, a predictor with almost nothing left to add. Figure 11 shows the plot for growth rate ddpi in the savings model, whose partial slope is a positive but gentle 0.41.

An added-variable plot for the income growth rate ddpi in the savings model. The horizontal axis is ddpi with the other three predictors removed, the vertical axis is the savings rate with those predictors removed. The 50 country points scatter around a gently upward-sloping line labeled with slope 0.41.

Figure 11:The added-variable plot for income growth in the savings model. The gentle upward slope, 0.41, is the partial effect of growth on savings once age structure and income are accounted for. The wide scatter is why the effect, though real, is only marginally significant.

Rather than take the recipe on faith, pull the cleaning slider below and watch the marginal slope turn into the coefficient in front of you.

Remove what target population explains from both axes, a little at a time, and watch the slope travel from the marginal 31.17 to the added-variable slope 9.37, which is exactly the coefficient on dispoinc.

8.6 R2R^2, adjusted R2R^2, and standardized coefficients

Intuition

We can now test which predictors belong; the next job is to summarize a whole model in one number and compare models of different sizes fairly. R2R^2 is the fraction of the response’s variation the model explains, and it has one seductive flaw: it never goes down when you add a predictor, even a column of random noise. That makes it useless for comparing models of different sizes, because the biggest model always wins. Adjusted R2R^2 (Definition 8.10) fixes this by charging rent for each predictor: it goes up only if the new predictor explains more than an average predictor’s worth of noise would. Standardized coefficients (Definition 8.11) solve a different problem: raw coefficients live in different units (dollars, thousands of people, percents), so you cannot compare their sizes; putting everything in standard-deviation units makes the comparison fair.

Formula

R2=1SSESSTO,Ra2=1SSE/(np)SSTO/(n1)=1n1np(1R2).R^2 = 1 - \frac{\mathrm{SSE}}{\mathrm{SSTO}}, \qquad R^2_a = 1 - \frac{\mathrm{SSE}/(n-p)}{\mathrm{SSTO}/(n-1)} = 1 - \frac{n-1}{n-p}\,(1 - R^2).

In words: R2R^2 measures explained fraction, Ra2R^2_a measures explained fraction after paying for model size, and bkb_k^{*} measures effect size in standard deviations, so different predictors can be ranked on one scale.

Derivation (R2R^2 never falls; Ra2R^2_a can)

Proof. By the monotonicity result of 8.3 Extra sums of squares (Theorem 8.4), adding a predictor cannot raise SSE\mathrm{SSE}, and SSTO\mathrm{SSTO} does not depend on the model. Hence SSE/SSTO\mathrm{SSE}/\mathrm{SSTO} cannot rise, so R2=1SSE/SSTOR^2 = 1 - \mathrm{SSE}/\mathrm{SSTO} cannot fall: every added predictor leaves R2R^2 equal or higher, which is why R2R^2 alone cannot choose a model. Adjusted R2R^2 behaves differently because it uses MSE=SSE/(np)\mathrm{MSE} = \mathrm{SSE}/(n-p). Adding a useless predictor lowers SSE\mathrm{SSE} by a little but also lowers the divisor npn-p by one; if the shrinkage in SSE\mathrm{SSE} is smaller than the shrinkage in npn-p demands, MSE\mathrm{MSE} rises and Ra2R^2_a falls. So Ra2R^2_a can go down when a predictor does not earn its degree of freedom, which is exactly the behavior we want from a model-size-aware measure. \blacksquare

Figure 13 makes this concrete: starting from the real savings model, we add columns of pure random noise one at a time and watch R2R^2 climb while Ra2R^2_a sags.

A line plot with the number of added junk predictors on the horizontal axis, from zero to ten, and two curves. The R-squared curve rises steadily from about 0.34 toward 0.45 as noise predictors are added. The adjusted R-squared curve starts at the same point but drifts downward, ending below its starting value.

Figure 13:Adding pure noise predictors to the savings model. R-squared (upper curve) rises with every junk column, because it never falls when a predictor is added. Adjusted R-squared (lower curve) drifts down, correctly reporting that the noise columns are not worth their degrees of freedom.

R and Python

Figure 14 ranks the four standardized coefficients on one axis, which the raw coefficients, living in incompatible units, could never share.

A horizontal bar chart of the four standardized coefficients of the savings model. pop15 is a long bar to the left at -0.94, pop75 a shorter left bar at -0.49, ddpi a right bar at 0.26, and dpi a tiny left bar at -0.07. A vertical reference line marks zero.

Figure 14:The savings coefficients on a common standard-deviation ruler. Young-population share (pop15) has by far the largest standardized effect, and it is negative; income (dpi) has almost none. Only after standardizing can predictors in percent and in dollars be compared this way.

8.7 Two dangers: hidden extrapolation and lurking variables

Intuition

Two failures deserve their own section because they are invisible in the coefficient table and fatal to a conclusion. The first is hidden extrapolation (Definition 8.13): predicting at a combination of predictor values that is inside the range of each predictor separately but outside the region where they occur together. The second is the lurking variable (Definition 8.14): an omitted predictor that, if included, would move or reverse the coefficients you reported.

Hidden extrapolation

With one predictor, extrapolation is easy to police: stay inside the observed range of XX. With several predictors, the observed region is not a box but a cloud, usually a tilted one because predictors are correlated. A query point can sit inside every predictor’s own range and still fall far outside the cloud. Figure 15 shows the Dwaine case: a city with target population 75 and disposable income 16 is unremarkable on each axis alone, yet no real city combines a population that large with income that low, so a prediction there is an extrapolation the one-variable ranges would never flag.

A scatterplot of the 21 Dwaine cities with target population on the horizontal axis and disposable income on the vertical axis, forming an upward-tilted elliptical cloud. A shaded convex hull outlines the observed cities. A red query point at population 75, income 16 sits inside both the horizontal and vertical ranges but clearly outside the shaded hull, in the empty lower-right region.

Figure 15:Hidden extrapolation in two predictors. The red query point lies within the observed range of population and within the observed range of income, but outside the tilted cloud where the two occur together. A prediction there is an extrapolation that no single-variable range check would catch.

The practical check is to ask whether a query point lies within the joint region of the data, not merely within each margin. Chapter 9 makes this rigorous with the hat matrix: the leverage value hiih_{ii} of 7.3 The hat matrix measures how far a point sits from the center of the predictor cloud, and a new point whose leverage value would exceed the observed ones is a hidden extrapolation.

Lurking variables

A regression can only adjust for the predictors you give it. If an important variable is missing and it correlates with both the response and an included predictor, the coefficient you report absorbs the missing variable’s influence and can be badly wrong, even reversed. This is the multiple regression version of the correlation-is-not-causation warning from 4.2 Correlation and the regression slope, and it is why an observational coefficient is always provisional: some unmeasured factor might be doing the work.

“Even reversed” sounds like an exaggeration until you see it. Figure 16 shows the mechanism on a schematic dataset. Ignore the lurking variable and the points march up from left to right, so the slope looks positive. Color the points by the hidden group and each group tips the other way: within any single group the slope is negative. A model that never saw the group reports the upward trend and gets the sign exactly backwards.

A schematic scatterplot of response Y against predictor X. Points fall into three colored groups, blue lower-left, green middle, orange upper-right. A dashed overall line through all points slopes upward, labeled overall slope positive with the lurking variable ignored. Within each colored group a solid line slopes downward, labeled that within each group the slope is negative. The overall and within-group slopes have opposite signs.

Figure 16:A lurking variable can flip a slope’s sign. The dashed overall line slopes up because the groups sit at different heights; the solid within-group lines all slope down. If the group is a variable you never measured, your fitted coefficient reports the up-slope and misses the true down-slope entirely.

The honest posture is to name the lurking variables you can think of and admit the ones you cannot. In the Dwaine study, local competition, the age of each studio, and regional advertising are all plausibly related to both sales and the city characteristics; none is in the model, so each partial slope is “the best we can say from these three columns,” not a final truth. No amount of arithmetic inside a fixed set of predictors can rule out a variable you never measured.

8.8 Chapter summary

You can now take a fitted multiple regression and do the work that matters after the fit. You can read each coefficient as a partial slope, stating in words the controlled comparison it makes and the exact phrase “holding the other predictors fixed,” and you can explain why that phrase weakens when predictors are correlated and can describe a region with no data. You can compute extra sums of squares and read a sequential ANOVA table as a decomposition of SSR\mathrm{SSR}. You can run the general linear test for one coefficient or a group, derive its FF statistic from the Pythagorean split of nested models, and show it collapses to t2t^2 for a single coefficient. You can build an added-variable plot and prove its slope is the multiple regression coefficient. You can compute R2R^2, adjusted R2R^2, and standardized coefficients, and explain why only the last two are safe for comparing models or effects. And you can spot the two dangers that a coefficient table hides: hidden extrapolation in the joint predictor space and the lurking variable no model ever measured.

Key results at a glance

ResultStatement or formulaValid when
Partial slope (Definition 8.1)bkb_k is the change in E{Y}E\{Y\} per unit of XkX_k, other predictors held fixedmultiple regression model
Extra sum of squares (Definition 8.3)SSR(X2X1)=SSE(X1)SSE(X1,X2)\mathrm{SSR}(X_2\mid X_1) = \mathrm{SSE}(X_1) - \mathrm{SSE}(X_1,X_2)any nested pair of models
Monotonicity of SSE (Theorem 8.4)SSE(full)SSE(reduced)\mathrm{SSE}(\text{full}) \le \mathrm{SSE}(\text{reduced}), so SSR(X2X1)0\mathrm{SSR}(X_2\mid X_1)\ge 0reduced predictors a subset of the full
General linear test (Theorem 8.6)F=[SSE(R)SSE(F)]/qSSE(F)/(npF)F(q,npF)F^{*} = \dfrac{[\mathrm{SSE}(R)-\mathrm{SSE}(F)]/q}{\mathrm{SSE}(F)/(n-p_F)} \sim F(q, n-p_F)normal errors, reduced model true
One-coefficient identity (Theorem 8.7)F=bk2/s2{bk}=tk2F^{*} = b_k^2/s^2\{b_k\} = t_k^2dropping a single coefficient (q=1q=1)
Added-variable slope (Theorem 8.9)slope of eYe_Y on eXe_X equals bkb_kany multiple regression (Frisch-Waugh)
R2R^2 monotonicity (Theorem 8.12)R2R^2 never falls as predictors are added; Ra2R^2_a cancomparing nested models
Adjusted R2R^2 (Definition 8.10)Ra2=1n1np(1R2)R^2_a = 1 - \frac{n-1}{n-p}(1-R^2)comparing models of different size
Standardized coefficient (Definition 8.11)bk=bk(sXk/sY)b_k^{*} = b_k\,(s_{X_k}/s_Y)ranking effects across different units

Key terms

partial slope, multiple linear regression model, extra sum of squares, sequential (Type I) ANOVA, general linear test, full model, reduced model, added-variable plot, coefficient of determination (R2R^2), adjusted R2R^2, standardized coefficient, hidden extrapolation, lurking variable, multicollinearity.

You should now be able to

Where this fits. In the workflow spine of The modeling workflow this chapter is mostly USE: it takes the fit that Chapter 7 produced for Dwaine in matrix form and turns it into interpretation, tests, and honest caveats, with the general linear test also serving FIT by deciding which terms belong. Chapter 7 gave the estimator and its variance; this chapter gave the reasoning that makes an estimate a claim. What we deferred is the CHECK stage: whether any single case is quietly running the fit, and whether the model’s assumptions hold at all. That is Chapter 9’s job. It returns to the savings data, singling out Libya as the case that bends the fit and Zambia as a large-residual outlier, and builds the influence diagnostics (9.3 Influence: which points actually change the fit) and the leverage statistic that 9.1 Leverage values and the hat matrix points to, which together decide how much of this chapter’s confidence survives contact with real data. The general linear test you learned here is the testing engine that Chapter 11 reuses for categorical predictors and interactions (11.1 From categories to numbers: indicator coding) and Chapter 12 for variable selection (12.2 Choosing among models: selection criteria), neither re-deriving it.

8.9 Frequently asked questions

Q1. Why is the multiple regression coefficient on income so different from the simple-regression slope? Because they answer different questions. The simple slope 31.17 compares cities that differ in income and lets population differ along with it; the partial slope 9.37 compares cities that differ in income but share population. When predictors are correlated, the two questions have different answers, and only the partial slope earns the phrase “holding population fixed.”

Q2. Does “holding the other predictors fixed” mean I can intervene on one predictor and expect that coefficient’s change? No. The coefficient describes a comparison across cases that already differ, not the effect of an action. With observational data, and especially with correlated predictors or a lurking variable, acting on a predictor need not reproduce the observed association. The coefficient is a description of the fitted surface, not a promise about interventions.

Q3. The sequential ANOVA gives different sums of squares when I reorder the predictors. Which order is right? None is uniquely right; the order is a choice about what “given the others” means. The first predictor gets its full simple-regression sum of squares, each later one gets only what it adds beyond those before it. The pieces always total the same SSR\mathrm{SSR}. If you want each predictor adjusted for all the others at once, use its tt-test (or the general linear test dropping just that predictor), which does not depend on order.

Q4. When should I use the general linear test instead of just reading tt statistics? Use it whenever you want to test several coefficients at once, such as “do these two predictors together add anything.” A group of individually non-significant tt’s does not tell you whether the group as a whole matters, because the predictors may share their explanatory power; the general linear test asks the joint question directly. For a single coefficient, the general linear test and the tt-test are identical (F=t2F^{*} = t^2).

Q5. Why does R2R^2 always go up when I add a predictor, even a useless one? Because adding a predictor can only lower (or not change) SSE\mathrm{SSE}, and SSTO\mathrm{SSTO} is fixed, so R2=1SSE/SSTOR^2 = 1 - \mathrm{SSE}/\mathrm{SSTO} can only rise. That is exactly why R2R^2 cannot be used to choose between models of different sizes; use adjusted R2R^2, which penalizes each added parameter, or a formal test.

Q6. My added-variable plot slope matches the coefficient exactly. Is that a coincidence? No, it is a theorem (Frisch-Waugh). Removing the other predictors from both the response and the target predictor, then regressing the leftovers, reproduces the full-model coefficient exactly. That is what makes the added-variable plot a faithful picture of the coefficient rather than a rough sketch.

Q7. All three body-fat coefficients are non-significant, yet the overall FF is highly significant. How can the model be useful if no single predictor is? This is the fingerprint of multicollinearity. The three tape-measure predictors overlap so much that no one of them adds much given the other two, so each individual tt is small; but together they explain body fat well, so the overall FF is large. The predictors are substitutes, not independent contributors. Chapter 12 takes up this multicollinearity theme on a larger body-fat study and measures the overlap with the variance inflation factor.

8.10 Practice problems

  1. (A) State in one sentence what the Dwaine coefficient 1.4546 on targtpop means, naming its units and what is held fixed.

  2. (A) Explain the difference between the simple-regression slope of sales on dispoinc (31.17) and the multiple regression coefficient (9.37). Which holds population fixed?

  3. (A) Define the extra sum of squares SSR(X2X1)\mathrm{SSR}(X_2 \mid X_1) in words, and explain why it can never be negative.

  4. (A) A reduced model drops three predictors from a full model. State the numerator degrees of freedom of the general linear test comparing them.

  5. (A) Why does R2R^2 never decrease when a predictor is added? Answer using the identity R2=1SSE/SSTOR^2 = 1 - \mathrm{SSE}/\mathrm{SSTO}.

  6. (A) A colleague reports that adjusted R2R^2 fell when they added a variable, and concludes they made an error. Are they right? Explain.

  7. (A) In your own words, what does an added-variable plot put on each axis, and why is neither axis the raw variable?

  8. (A) Give an example, in the Dwaine context, of a lurking variable that could distort the income coefficient, and say why it would matter.

  9. (A) Explain why a query point can be a hidden extrapolation even when each predictor value is inside its own observed range.

  10. (A) All three body-fat coefficients are individually non-significant but the overall FF is highly significant. Explain how both can be true.

  11. (B) Prove that adding a predictor to a model cannot increase SSE\mathrm{SSE} (Theorem 8.4), using the projection characterization of least squares from 7.2 The geometry of least squares.

  12. (B) Show that SSR(X2X1)=SSR(X1,X2)SSR(X1)\mathrm{SSR}(X_2 \mid X_1) = \mathrm{SSR}(X_1, X_2) - \mathrm{SSR}(X_1) is equivalent to SSE(X1)SSE(X1,X2)\mathrm{SSE}(X_1) - \mathrm{SSE}(X_1, X_2), citing which quantity is model-independent.

  13. (B) Derive the Pythagorean identity SSE(R)=SSE(F)+Y^FY^R2\mathrm{SSE}(R) = \mathrm{SSE}(F) + \lVert \widehat{\mathbf{Y}}_F - \widehat{\mathbf{Y}}_R\rVert^2 for nested models, stating where orthogonality is used.

  14. (B) Starting from s2{bk}=MSEckks^2\{b_k\} = \mathrm{MSE}\cdot c_{kk} and SSR(Xkothers)=bk2/ckk\mathrm{SSR}(X_k \mid \text{others}) = b_k^2/c_{kk}, prove that the general linear test with q=1q = 1 gives F=tk2F^{*} = t_k^2 (Theorem 8.7).

  15. (B) Prove that the slope of the added-variable plot for XkX_k equals the full-model coefficient bkb_k, in the two-predictor case (Theorem 8.9, Frisch-Waugh).

  16. (B) Derive Ra2=1n1np(1R2)R^2_a = 1 - \frac{n-1}{n-p}(1 - R^2) from the definition Ra2=1SSE/(np)SSTO/(n1)R^2_a = 1 - \frac{\mathrm{SSE}/(n-p)}{\mathrm{SSTO}/(n-1)}, and explain when adding a predictor lowers it.

  17. (B) Show that the standardized coefficient satisfies bk=bk(sXk/sY)b_k^{*} = b_k\,(s_{X_k}/s_Y) by relating the regression on standardized variables to the regression on raw variables.

  18. (B) Explain why reordering predictors changes the sequential sums of squares but never changes their total or the full-model coefficients. Tie your answer to which quantities the order affects.

  19. (B) The general linear test for the overall regression compares the full model to the intercept-only model. Show that its FF^{*} equals MSR/MSE\mathrm{MSR}/\mathrm{MSE} with MSR=SSR/(p1)\mathrm{MSR} = \mathrm{SSR}/(p-1).

  20. (C) Fit the Dwaine model in R or Python and reproduce b0,b1,b2b_0, b_1, b_2, R2R^2, and the residual standard error. Confirm MSE=SSE/(np)\mathrm{MSE} = \mathrm{SSE}/(n-p) from the residuals.

  21. (C) On bodyfat3.csv, print the sequential ANOVA in both predictor orders (triceps-then-thigh and thigh-then-triceps) and report how SSR(thigh)\mathrm{SSR}(\text{thigh}) and SSR(thightriceps)\mathrm{SSR}(\text{thigh} \mid \text{triceps}) differ. Explain the difference.

  22. (C) Run the general linear test dropping pop75 and dpi from the savings model, first with the built-in model comparison and then by hand from the two error sums of squares. Confirm they agree and report FF^{*} and its pp-value.

  23. (C) For the savings model, verify F=t2F^{*} = t^2 for the single predictor ddpi: compute the general linear test dropping ddpi and compare to the square of ddpi’s tt statistic.

  24. (C) Build the added-variable plot for pop15 in the savings model. Report the slope, confirm it equals the full-model coefficient on pop15, and describe the scatter.

  25. (C) Add three columns of standard normal noise (seed 4210) to the savings data, refit with the extra columns, and report how R2R^2 and adjusted R2R^2 change. Which one behaves sensibly?

  26. (C) Standardize the Dwaine variables and refit; report the two standardized coefficients and say which predictor has the larger standardized effect. Does the ranking match the raw tt statistics?

  27. (C) Predict Dwaine sales at target population 75 and income 16, and separately at the sample means. Argue from Figure 15 which prediction you would trust and why.

  28. (C) Fit the full three-predictor body-fat model and report all three tt statistics and the overall FF. Explain, using the correlations among the predictors, why the individual and joint verdicts disagree.

  29. (B) A student claims that because SSR(X2X1)0\mathrm{SSR}(X_2 \mid X_1) \ge 0 always, adding any predictor always improves the model. Explain precisely what “improves” can and cannot mean here, distinguishing SSE\mathrm{SSE}, R2R^2, adjusted R2R^2, and out-of-sample prediction.

  30. (C) Using the Dwaine model, compute a 95% confidence interval for mean sales and a 95% prediction interval for a new city’s sales at target population 65.4 and income 17.6. Explain in one sentence why the prediction interval is wider, citing 3.5 Prediction interval for a new observation.

8.11 Exam practice

These five questions are written in the style of the course exams: each one asks you to explain your reasoning in full sentences, not just to produce a number. Read the output, decide what it says, and write the argument you would want a grader to read. Work each one before opening its model answer.

EP 8.1. The four-predictor savings model is fit to the 50 countries, and R prints the coefficient table below.

            Estimate Std. Error t value Pr(>|t|)
(Intercept)  28.5661     7.3545  3.8842   0.0003
pop15        -0.4612     0.1446 -3.1885   0.0026
pop75        -1.6915     1.0836 -1.5610   0.1255
dpi          -0.0003     0.0009 -0.3618   0.7192
ddpi          0.4097     0.1962  2.0882   0.0425

Interpret the coefficient on pop15 as a partial slope, giving its units and the exact phrase for what is held fixed. Then, using the tt value and pp-value, explain whether pop15 is distinguishable from zero at the 5% level. Finally, a classmate reads the near-zero dpi coefficient (0.0003)(-0.0003) and concludes that disposable income has no relationship with the savings rate; explain in full sentences why that conclusion overreaches.

EP 8.2. A student fits the three body-fat predictors in two different orders and prints the sequential (Type I) ANOVA table each time.

Response: bodyfat        (order: triceps, thigh, midarm)
          Df Sum Sq Mean Sq F value    Pr(>F)
triceps    1 352.27  352.27 57.2768 1.131e-06
thigh      1  33.17   33.17  5.3931   0.03373
midarm     1  11.55   11.55  1.8773   0.18956
Residuals 16  98.40    6.15
Response: bodyfat        (order: thigh, triceps, midarm)
          Df Sum Sq Mean Sq F value    Pr(>F)
thigh      1 381.97  381.97 62.1052 6.735e-07
triceps    1   3.47    3.47  0.5647   0.46330
midarm     1  11.55   11.55  1.8773   0.18956
Residuals 16  98.40    6.15

The student writes: “Thigh gets a sum of squares of 381.97 in the second table but only 33.17 in the first. The same variable cannot have two different sums of squares, so one of these tables must be a software error.” Evaluate this claim, and explain in full sentences what the two thigh numbers actually represent.

EP 8.3. In the savings model you want to know whether the two economic predictors, dpi and ddpi, can be dropped once the two demographic predictors pop15 and pop75 are in the model. The model comparison prints:

Model 1: sr ~ pop15 + pop75
Model 2: sr ~ pop15 + pop75 + dpi + ddpi
  Res.Df    RSS Df Sum of Sq     F  Pr(>F)
1     47 726.17
2     45 650.71  2    75.455 2.609 0.08471

State the null and alternative hypotheses this test evaluates and your decision at the 5% level. Then, recalling from the full-model summary in EP 8.1 that dpi has t=0.36t = -0.36 (p=0.72p = 0.72) while ddpi has t=2.09t = 2.09 (p=0.0425p = 0.0425), explain in full sentences why it would be a mistake to react to this non-significant joint test by dropping both dpi and ddpi.

EP 8.4. For the savings model, the added-variable plot for pop15 is built by residualizing both the response and pop15 on the other three predictors, and its slope is computed.

AV slope pop15 = -0.4612   full coef pop15 = -0.4612

Explain why the added-variable plot slope must equal the full-model coefficient, naming the result that guarantees it. Then explain what would change if a student residualized only the response sr on the other predictors but plotted those residuals against the raw pop15 values instead of the residualized pop15: would the slope still be -0.4612, and what quantity would that botched slope represent?

EP 8.5. Starting from the four-predictor savings model, three columns of pure standard-normal noise (seed 4210) are added and the model is refit.

model                     R2       adj R2
sr ~ 4 predictors         0.3385   0.2797
sr ~ 4 predictors + 3 noise 0.3980   0.2977

Explain why R2R^2 rose from 0.3385 to 0.3980 even though the three added columns are pure noise. Then explain why this rise is not evidence that the larger model is better, and say what adjusted R2R^2 and out-of-sample prediction each tell you here.

8.12 Chapter game