---
title: "Multiple Regression"
book: "University Economics — Year 2"
subject: economics
language: en
chapter: 30
exercises: 12
source: https://one-course.com/books/economics/4/en/chapter/30-multiple-regression
license: CC-BY-NC-SA-4.0
credit: "One Economics Book, One Course (one-course.com)"
---

# Chapter 30 — Multiple Regression

A regression with one regressor compares people who differ in that regressor and, usually, in much else. Adding regressors compares people who differ in the first and are alike in the others. This chapter writes the model in matrix form, derives the least-squares estimator, shows what “holding the others constant” means exactly, and measures what leaving a variable out does to a coefficient. The chart shows the question on real data: the estimated return to a year of schooling as the comparison is made more like for like.

![Estimated effect of a year of schooling on log earnings in 1978, per cent, as controls are added one at a time, with 95 per cent confidence intervals; American men with positive earnings in 1975 and 1978 (13,055 men).](https://one-course.com/images/onecourse/chapters/economics-4/b2-multiple-regression/fig-66a9e30a4f58.svg)

*Estimated effect of a year of schooling on log earnings in 1978, per cent, as controls are added one at a time, with 95 per cent confidence intervals; American men with positive earnings in 1975 and 1978 (13,055 men). Source: CPS comparison sample of LaLonde (1986), as distributed by Dehejia and Wahba; our computation*

With no control, a year of schooling goes with log earnings 4.10 per cent higher. Adding age raises the estimate to 5.22; adding age squared brings it to 3.99; race and marriage move it little; adding 1975 earnings halves it, to 2.04. Each number is a correct answer to a different question. Which question is the right one is not a matter of statistics, and the last step is a warning taken up in [Chapter 32](https://one-course.com/books/economics/4/en/chapter/32-specification#ch-b2-specification).

**You already know.**

From the Year 1 volume: the ordinary least squares estimator with one regressor, fitted values and residuals, the error term, the zero conditional mean assumption, $R^2$, the omitted variable, estimators, standard errors and confidence intervals. From mathematics: matrices, the transpose, the inverse, the rank, and orthogonal projection.

## 30.1 The model in matrix form

**Definition 30.1 (Multiple regression model).**

The *multiple regression model* writes an outcome as a linear function of several regressors plus an error: $y_i = \beta_0 + \beta_1x_{i1} + \dots + \beta_{k-1}x_{i,k-1} + u_i$, $i = 1, \dots, n$.

**Definition 30.2 (Regressor matrix).**

The *regressor matrix* $X$ is the $n \times k$ matrix whose row $i$ is $(1, x_{i1}, \dots,
x_{i,k-1})$: one row per observation, one column per regressor, the first column a column of ones.

With $y$ and $u$ the $n$-vectors of outcomes and errors and $\beta$ the $k$-vector of coefficients, the model is $y = X\beta + u$. Three assumptions make $\beta$ the object least squares estimates: the model is linear in $\beta$; $X$ has full column rank $k$, so that no column is a linear combination of the others; and $E[u \mid X] = 0$, so that the errors have mean zero whatever the regressors. The coefficient $\beta_j$ is then the change in the conditional mean of $y$ when $x_j$ rises by one and the other regressors are held fixed.

## 30.2 The least-squares estimator

Least squares chooses $b$ to minimise the sum of squared residuals $(y - Xb)'(y - Xb) = y'y - 2b'X'y + b'X'Xb$. Setting the gradient $-2X'y + 2X'Xb$ to zero gives the following equations.

**Definition 30.3 (Normal equations).**

The *normal equations* of least squares are $X'Xb = X'y$; when $X$ has full column rank, $X'X$ is invertible and they have the single solution $\hat\beta = (X'X)^{-1}X'y$.

The [normal equations](#def-b2-multiple-regression-normal-equations) say $X'(y - X\hat\beta) = X'e = 0$: the residual vector $e$ is orthogonal to every column of $X$. So the fitted vector $\hat y = X\hat\beta$ is the orthogonal projection of $y$ on the space spanned by the columns of $X$, and $e$ is what is left, at right angles to that space. With a column of ones in $X$, the residuals sum to zero.

![Least squares as projection. The fitted vector is the point of the column space closest to y; the residual is orthogonal to the column space, which is what the normal equations say.](https://one-course.com/images/onecourse/chapters/economics-4/b2-multiple-regression/fig-a1173ef511d6.svg)

*Least squares as projection. The fitted vector is the point of the column space closest to $y$; the residual is orthogonal to the column space, which is what the [normal equations](#def-b2-multiple-regression-normal-equations) say.*

The listings use the CPS comparison sample described in the box. The first loads it; the second solves the [normal equations](#def-b2-multiple-regression-normal-equations) with numpy and compares the result with statsmodels.

**How it is measured — The comparison sample.**

LaLonde (1986) asked whether econometric methods applied to survey data could reproduce what a field experiment had found about a training programme. To do so he built comparison samples of men from two American surveys, the Current Population Survey and the Panel Study of Income Dynamics. Dehejia and Wahba (1999) re-examined the same samples and distribute them; the CPS one has 15,992 men, with their age, schooling, race, marital status, whether they have a high-school diploma, and their earnings in 1974, 1975 and 1978. In the file, 25.9 per cent of the men have 1978 earnings equal to the largest value, 25,564.7: earnings above some level were recorded at that level, so the top of the distribution is cut off. This chapter uses the 13,055 men with positive earnings in both 1975 and 1978. Dropping the men with no earnings in 1978 selects on the outcome itself, so the coefficients describe men in work, not all men; the experiment itself returns in [Chapter 33](https://one-course.com/books/economics/4/en/chapter/33-causality-and-the-experimental-ideal#ch-b2-causality-and-experiments).

```python
"""The CPS comparison sample: men with positive earnings in 1975 and 1978."""

import numpy as np
from econdata import nsw

d = nsw("cps_controls")
cap = d.re78.max()
print(f"men in the file: {len(d)}")
print(f"share at the 1978 maximum of {cap:,.1f}: {(d.re78 == cap).mean():.1%}")

d = d[(d.re78 > 0) & (d.re75 > 0)].copy()
d["lre78"] = np.log(d.re78)
d["lre75"] = np.log(d.re75)
print(f"men with positive earnings in 1975 and 1978: {len(d)}")

cols = ["lre78", "education", "age", "black", "hispanic", "married", "lre75"]
table = d[cols].describe().loc[["mean", "std", "min", "max"]].T
print(table.round(2).to_string())
```

***Listing 30.1.** Loading the comparison sample and the regression sample. code/bachelor-2/30-multiple-regression/listings/load_cps.py*

```
$ python load_cps.py
men in the file: 15992
share at the 1978 maximum of 25,564.7: 25.9%
men with positive earnings in 1975 and 1978: 13055
            mean    std    min    max
lre78       9.55   0.90   1.08  10.15
education  12.03   2.85   0.00  18.00
age        33.24  10.81  16.00  55.00
black       0.07   0.25   0.00   1.00
hispanic    0.07   0.26   0.00   1.00
married     0.73   0.44   0.00   1.00
lre75       9.36   1.03   2.37  10.14
```

***Output 30.1.** A quarter of the men are at the earnings cap; the regression sample keeps 13,055 men.*

```python
"""Least squares by the normal equations, against statsmodels."""

import numpy as np
import statsmodels.api as sm
from econdata import nsw

d = nsw("cps_controls")
d = d[(d.re78 > 0) & (d.re75 > 0)]
y = np.log(d.re78).to_numpy()
names = ["const", "education", "age", "age2", "black", "hispanic", "married"]
cols = [np.ones(len(d)), d.education, d.age, d.age**2, d.black, d.hispanic, d.married]
X = np.column_stack(cols)
n, k = X.shape

beta = np.linalg.solve(X.T @ X, X.T @ y)  # the normal equations X'X b = X'y
fit = sm.OLS(y, X).fit()
for name, b, b_sm in zip(names, beta, fit.params):
    print(f"{name:10s} {b:12.6f} {b_sm:12.6f}")
print("same coefficients to 1e-8:", np.allclose(beta, fit.params, rtol=0, atol=1e-8))

e = y - X @ beta
print("residuals orthogonal to every column:", np.allclose(X.T @ e, 0, atol=1e-5))
r2 = 1 - (e @ e) / ((y - y.mean()) @ (y - y.mean()))
adj = 1 - (1 - r2) * (n - 1) / (n - k)
print(f"R2 {r2:.4f} ({fit.rsquared:.4f}), adjusted {adj:.4f} ({fit.rsquared_adj:.4f})")
```

***Listing 30.2.** The [normal equations](#def-b2-multiple-regression-normal-equations) solved with numpy, against statsmodels. code/bachelor-2/30-multiple-regression/listings/ols_by_hand.py*

```
$ python ols_by_hand.py
const          7.100734     7.100734
education      0.038343     0.038343
age            0.098755     0.098755
age2          -0.001202    -0.001202
black         -0.170828    -0.170828
hispanic      -0.052405    -0.052405
married        0.262576     0.262576
same coefficients to 1e-8: True
residuals orthogonal to every column: True
R2 0.1181 (0.1181), adjusted 0.1177 (0.1177)
```

***Output 30.2.** The same coefficients either way; the residuals are orthogonal to every column.*

Holding age, race and marriage fixed, a year of schooling goes with earnings 3.83 per cent higher; married men earn 26.3 log points more than unmarried men of the same age, schooling and race. Age enters with a positive coefficient and a negative one on its square: earnings rise with age at a falling rate.

## 30.3 Partialling out

What does “holding the others fixed” do to the data? Split the regressors into $x$, the one of interest, and $W$, the others (with the column of ones), so that $y = x\beta_1 + W\gamma + u$.

**Definition 30.4 (Frisch–Waugh–Lovell theorem).**

The *Frisch–Waugh–Lovell theorem* states that the least-squares coefficient on $x$ in the regression of $y$ on $x$ and $W$ equals the coefficient in the regression of $\tilde y$ on $\tilde x$, where $\tilde y$ and $\tilde x$ are the residuals from regressing $y$ and $x$ on $W$.

**Proposition 30.5 (Frisch–Waugh–Lovell).**

Let $M = I - W(W'W)^{-1}W'$, $\tilde x = Mx$ and $\tilde y = My$. Then the coefficient on $x$ in the regression of $y$ on $(x, W)$ is $\hat\beta_1 = \tilde x'\tilde y/\tilde x'\tilde x = \tilde x'y/\tilde x'\tilde x$.

**Proof.** $M$ is symmetric, $MM = M$, and $MW = 0$. Write $y = x\hat\beta_1 + W\hat\gamma + e$, with $e$ orthogonal to $x$ and to every column of $W$. Then $Me = e$, since $e$ is already orthogonal to $W$. Multiply by $M$: $My = Mx\hat\beta_1 + e$. Multiply by $x'$: $x'My = x'Mx\,\hat\beta_1 + x'e = x'Mx\,\hat\beta_1$. Since $x'My = (Mx)'(My) = \tilde x'\tilde y$ and $x'Mx = \tilde x'\tilde x$, $\hat\beta_1 = \tilde x'\tilde y/\tilde x'\tilde x$; and $\tilde x'\tilde y = \tilde x'My =
(M\tilde x)'y = \tilde x'y$. ∎

The coefficient on schooling uses only the variation in schooling that age, race and marriage do not predict. The rest of the variation is discarded.

```python
"""Frisch-Waugh-Lovell: the education coefficient by partialling out the controls."""

import numpy as np
from econdata import nsw

d = nsw("cps_controls")
d = d[(d.re78 > 0) & (d.re75 > 0)]
y = np.log(d.re78).to_numpy()
x = d.education.to_numpy(dtype=float)
W = np.column_stack([np.ones(len(d)), d.age, d.age**2, d.black, d.hispanic, d.married])


def resid(v, M):
    """Residual of v after least squares on the columns of M."""
    return v - M @ np.linalg.lstsq(M, v, rcond=None)[0]


b_long = np.linalg.lstsq(np.column_stack([x, W]), y, rcond=None)[0][0]
rx = resid(x, W)
ry = resid(y, W)
b_fwl = (rx @ ry) / (rx @ rx)
b_half = (rx @ y) / (rx @ rx)
b_short = np.linalg.lstsq(np.column_stack([np.ones(len(d)), x]), y, rcond=None)[0][1]

print(f"long regression:               {b_long:.6f}")
print(f"residual on residual:          {b_fwl:.6f}")
print(f"y on residualised x:           {b_half:.6f}")
print(f"education alone (no controls): {b_short:.6f}")
print(f"variance of x {x.var():.3f}; of its residual {rx.var():.3f}")
```

***Listing 30.3.** Partialling out the controls gives the same coefficient as the long regression. code/bachelor-2/30-multiple-regression/listings/fwl.py*

```
$ python fwl.py
long regression:               0.038343
residual on residual:          0.038343
y on residualised x:           0.038343
education alone (no controls): 0.040973
variance of x 8.101; of its residual 7.117
```

***Output 30.3.** Three routes, one coefficient; the controls remove an eighth of the variance of schooling.*

## 30.4 The omitted-variable bias formula

**Definition 30.6 (Omitted-variable bias).**

*Omitted-variable bias* is the difference between the coefficient on a regressor in a regression that leaves out a variable and the coefficient in the regression that includes it.

Let the long regression be $y = x\hat\beta_1 + W\hat\beta_W + z\hat\gamma + e$ and the short one leave $z$ out. Let $\hat\delta$ be the coefficient on $x$ when $z$ itself is regressed on $x$ and $W$. Then, exactly in any sample,

$$
\hat\beta_1^{\text{short}} = \hat\beta_1^{\text{long}} + \hat\gamma\,\hat\delta.\tag{30.1}
$$

Proof: regress both sides of $y = x\hat\beta_1 + W\hat\beta_W + z\hat\gamma + e$ on $x$ and $W$. Least squares is linear in the outcome, the regression of $x$ and of $W$ on themselves gives coefficient one on themselves, $e$ is orthogonal to $x$ and $W$ so its coefficients are zero, and $z$ gives $\hat\delta$ on $x$ (Exercise 11).

The formula needs only two signs: the effect of the omitted variable on the outcome and its association with the regressor.

|  | $z$ and $x$ positively associated ($\delta > 0$) | negatively associated ($\delta < 0$) |
| --- | --- | --- |
| $z$ raises $y$ ($\gamma > 0$) | short coefficient too high | short coefficient too low |
| $z$ lowers $y$ ($\gamma < 0$) | short coefficient too low | short coefficient too high |

*The sign of the [omitted-variable bias](#def-b2-multiple-regression-ovb) $\gamma\delta$. Adding age in the opening chart raised the estimate: earnings rise with age, and older men in the sample have less schooling.*

```python
"""The omitted-variable bias formula, short = long + gamma delta."""

import numpy as np
from econdata import nsw

d = nsw("cps_controls")
d = d[(d.re78 > 0) & (d.re75 > 0)]
y = np.log(d.re78).to_numpy()
z = np.log(d.re75).to_numpy()  # the variable left out of the short regression
W = np.column_stack([np.ones(len(d)), d.education, d.age, d.age**2, d.black,
                     d.hispanic, d.married])  # fmt: skip


def ols(target, M):
    return np.linalg.lstsq(M, target, rcond=None)[0]


short = ols(y, W)[1]
full = ols(y, np.column_stack([W, z]))
long, gamma = full[1], full[-1]
delta = ols(z, W)[1]

print(f"short regression (no 1975 earnings): {short:.6f}")
print(f"long regression:                     {long:.6f}")
print(f"gamma, effect of log 1975 earnings:  {gamma:.6f}")
print(f"delta, 1975 earnings on education:   {delta:.6f}")
print(f"long + gamma * delta:                {long + gamma * delta:.6f}")
print("equal to 1e-12:", abs(short - long - gamma * delta) < 1e-12)
```

***Listing 30.4.** The [omitted-variable bias](#def-b2-multiple-regression-ovb) formula checked on the sample. code/bachelor-2/30-multiple-regression/listings/ovb.py*

```
$ python ovb.py
short regression (no 1975 earnings): 0.038343
long regression:                     0.020429
gamma, effect of log 1975 earnings:  0.399801
delta, 1975 earnings on education:   0.044806
long + gamma * delta:                0.038343
equal to 1e-12: True
```

***Output 30.4.** Adding 1975 earnings: $0.020429 + 0.399801 \times 0.044806
= 0.038343$.*

A man with 1 per cent higher earnings in 1975, at the same schooling, age, race and marriage, earns 0.40 per cent more in 1978; and a year of schooling goes with 4.5 per cent higher 1975 earnings. The product, 1.8 points, is the part of the schooling coefficient that 1975 earnings take over. Whether it should be taken over is another matter: 1975 earnings are themselves partly a result of schooling, so controlling for them removes part of the effect being measured.

## 30.5 Near-collinear regressors

**Definition 30.7 (Perfect collinearity).**

Regressors are *perfectly collinear* when one column of $X$ is an exact linear combination of the others; $X$ then has rank below $k$, $X'X$ is singular, and the coefficients are not identified.

A common case is a full set of indicator variables with a constant: an indicator for married men, one for unmarried men, and the column of ones, which is their sum. Near-collinearity is not a failure of the assumptions, but it costs precision. Under the assumptions of [Chapter 31](https://one-course.com/books/economics/4/en/chapter/31-inference-in-regression#ch-b2-regression-inference), with $R_j^2$ the $R^2$ of the regression of $x_j$ on the other regressors and $s_j^2$ the sample variance of $x_j$,

$$
\operatorname{Var}(\hat\beta_j \mid X) = \frac{\sigma^2}{ns_j^2(1 - R_j^2)}.\tag{30.2}
$$

The formula follows from the [Frisch–Waugh–Lovell theorem](#def-b2-multiple-regression-fwl): $\hat\beta_j$ is a regression on $\tilde x_j$, whose sum of squares is $ns_j^2(1 - R_j^2)$ (Exercise 12).

**Definition 30.8 (Variance inflation factor).**

The *variance inflation factor* of regressor $j$ is $1/(1 - R_j^2)$: the factor by which the variance of $\hat\beta_j$ exceeds what it would be if $x_j$ were uncorrelated with the other regressors.

```python
"""Near-collinear regressors: the standard error of b1 as the correlation rises."""

import numpy as np
import statsmodels.api as sm

rng = np.random.default_rng(30)
n = 500
print("  rho   corr in sample   b1     se(b1)    VIF")
for rho in (0.0, 0.5, 0.9, 0.99):
    x1 = rng.standard_normal(n)
    x2 = rho * x1 + np.sqrt(1 - rho**2) * rng.standard_normal(n)
    y = 1 + x1 + x2 + rng.standard_normal(n)
    fit = sm.OLS(y, sm.add_constant(np.column_stack([x1, x2]))).fit()
    r = np.corrcoef(x1, x2)[0, 1]
    vif = 1 / (1 - r**2)
    print(f"{rho:5.2f}  {r:14.3f}  {fit.params[1]:6.3f}  {fit.bse[1]:7.3f}  {vif:6.1f}")

x1 = rng.standard_normal(n)
X = np.column_stack([np.ones(n), x1, 2 * x1])
print(f"rank of X with x2 = 2 x1: {np.linalg.matrix_rank(X)} of {X.shape[1]} columns")
```

***Listing 30.5.** Simulated regressors with rising correlation, and an exactly collinear design. code/bachelor-2/30-multiple-regression/listings/collinearity.py*

```
$ python collinearity.py
  rho   corr in sample   b1     se(b1)    VIF
 0.00          -0.028   1.002    0.045     1.0
 0.50           0.538   0.934    0.057     1.4
 0.90           0.906   1.019    0.103     5.6
 0.99           0.990   1.123    0.311    48.5
rank of X with x2 = 2 x1: 2 of 3 columns
```

***Output 30.5.** The standard error grows with the correlation roughly as the square root of the VIF; with an exact multiple the matrix loses a rank.*

At a correlation of 0.99 the [variance inflation factor](#def-b2-multiple-regression-vif) is 48.5 and the standard error of $\hat\beta_1$ is 0.311, about seven times the 0.045 of uncorrelated regressors; the estimate itself is still unbiased. Near-collinearity is a shortage of information about the separate effects, not an error to be corrected; the remedies are more data or a question that does not need the separate effects.

## 30.6 Fit

The $R^2$ of a multiple regression is $1 - e'e/\sum_i(y_i - \bar y)^2$, as with one regressor. Adding a regressor never lowers it, since least squares could always set the new coefficient to zero.

**Definition 30.9 (Adjusted R-squared).**

The *adjusted $R^2$* is $\bar R^2 = 1 - \frac{e'e/(n - k)}{\sum_i(y_i - \bar y)^2/(n -
1)} = 1 - (1 - R^2)\frac{n - 1}{n - k}$; it can fall when a regressor is added.

In the listing $R^2$ is 0.1181 and $\bar R^2$ 0.1177: with 13,055 observations and seven coefficients the correction is tiny. Neither number says whether the coefficient on schooling is the effect of schooling. Adding 1975 earnings raises $R^2$ from 0.118 to 0.254 and moves the schooling coefficient from 3.83 to 2.04; a better fit is not a better answer to a causal question.

**Model — The linear regression model.**

**Assumes.** The conditional mean of the outcome is linear in the regressors; the [regressor matrix](#def-b2-multiple-regression-regressor-matrix) has full column rank; the error has mean zero given the regressors.

**Predicts.** Least squares estimates each coefficient without bias: the change in the mean outcome when one regressor rises by one and the others are held fixed.

**Tested.** Linearity can be checked against more flexible forms ([Chapter 32](https://one-course.com/books/economics/4/en/chapter/32-specification#ch-b2-specification)); the zero conditional mean assumption cannot be tested from the residuals, which are orthogonal to the regressors by construction, but can be tested against an experiment, as LaLonde did ([Chapter 33](https://one-course.com/books/economics/4/en/chapter/33-causality-and-the-experimental-ideal#ch-b2-causality-and-experiments)).

**Breaks.** When a variable that affects the outcome and is correlated with a regressor is left out, the coefficient absorbs its effect, by the amount $\gamma\delta$; and when a control is itself an outcome of the regressor, holding it fixed removes part of the effect.

## 30.7 Exercises

**Exercise 30.1 ★.**

Read the opening chart. Give the estimate with no control, after adding age, and with every control. Which single step moves the estimate most?

**Solution of Exercise 30.1.**

4.10 per cent with no control, 5.22 after adding age, 2.04 with every control. The largest single move is the last, adding log 1975 earnings: from 3.83 to 2.04, 1.79 points; adding age squared moves it 1.23 points, adding age 1.12.

**Exercise 30.2 ★.**

A quarter of the men have 1978 earnings at the cap. What does the cap do to the measured differences in log earnings between men with much schooling and men with little?

**Solution of Exercise 30.2.**

Men above the cap are recorded at the cap, so high earners appear to earn less than they do. Men with much schooling are more often above the cap, so the cap compresses the gap between them and men with little schooling: the measured return to schooling is likely too small.

**Exercise 30.3 ★.**

Compute $\bar R^2$ from $R^2 = 0.1181$, $n = 13{,}055$ and $k = 7$.

**Solution of Exercise 30.3.**

$1 - (1 - 0.1181) \times 13{,}054/13{,}048 = 1 - 0.8819 \times 1.00046 = 0.1177$.

**Exercise 30.4 ★.**

1975 earnings are measured after most of the men had finished school. Why might controlling for them be a mistake? What would show that a control is a bad one?

**Solution of Exercise 30.4.**

Schooling raises 1975 earnings, and 1975 earnings predict 1978 earnings. Holding 1975 earnings fixed compares men with different schooling but the same 1975 earnings, which removes the part of the effect of schooling that works through earlier earnings. A control is bad if it is itself affected by the regressor: evidence would be that the regressor predicts the control (here a year of schooling goes with 4.5 per cent higher 1975 earnings), or, better, that the control was measured after the regressor was set.

**Exercise 30.5 ★★.**

By hand: with five observations, $x = (1, 2, 3, 4, 5)$, $d = (0, 0, 1, 1, 1)$ and $y = (4, 4, 9, 13, 14)$, regress $y$ on a constant, $x$ and $d$. Write $X'X$ and $X'y$, solve the [normal equations](#def-b2-multiple-regression-normal-equations), and compute $R^2$ and $\bar R^2$.

**Solution of Exercise 30.5.**

$X'X = \begin{pmatrix}5 & 15 & 3\\ 15 & 55 & 12\\ 3 & 12 & 3\end{pmatrix}$, $X'y = (44, 161, 36)'$. The solution is $b = (1, 2, 3)'$: check $5 + 30 + 9 = 44$, $15 + 110 + 36 = 161$, $3 + 24 + 9 = 36$. Fitted values $3, 5, 10, 12, 14$; residuals $1, -1, -1, 1, 0$, so $e'e = 4$. With $\bar y = 8.8$, $\sum(y_i - \bar y)^2 = 90.8$, so $R^2 = 1 - 4/90.8 = 0.956$ and $\bar R^2 = 1 - (4/2)/(90.8/4) = 0.912$.

**Exercise 30.6 ★★.**

Predict, then compute: adding age raises the schooling coefficient from 4.10 to 5.22. The correlation between age and schooling in the sample is $-0.15$; age has a coefficient of 0.0192 in the long regression, and the regression of age on schooling has slope $-0.585$. Check the [omitted-variable bias](#def-b2-multiple-regression-ovb) formula.

**Solution of Exercise 30.6.**

Earnings rise with age ($\gamma > 0$) and older men have less schooling ($\delta < 0$), so leaving age out biases the schooling coefficient down. The formula: $0.0522 + 0.0192 \times (-0.585) = 0.0522 - 0.0112 = 0.0410$, the short coefficient.

**Exercise 30.7 ★★.**

**(D)** (a) With the Brenland household survey, regress the log gross income of heads with positive income on years of schooling, then add age and age squared. (b) With the CPS sample, add `nodegree` to the regression of the listing `ols_by_hand.py`. What happens to the schooling coefficient, its standard error, and its [variance inflation factor](#def-b2-multiple-regression-vif)?

**Solution of Exercise 30.7.**

(a) 5.80 per cent per year of schooling with no control, $R^2 = 0.108$; 5.84 per cent with age and age squared, $R^2 = 0.309$. (b) With `nodegree` the schooling coefficient falls from 3.83 to 2.16 per cent; men without a diploma earn 14.8 log points less at the same years of schooling. The standard error rises from 0.0028 to 0.0039, and the VIF of schooling from 1.14 to 2.24: years of schooling and having a diploma are strongly related.

**Exercise 30.8 ★★.**

Change $n$ to 2000 in the collinearity listing. By what factor should the standard errors fall? Compare with the output.

**Solution of Exercise 30.8.**

By [(30.2)](#eq-b2-multiple-regression-var) the standard error falls as $1/\sqrt n$: by a factor of 2. The output gives 0.022, 0.025, 0.052 and 0.160 against 0.045, 0.057, 0.103 and 0.311. The ratios are close to 2, though not exactly, because new draws give new sample correlations.

**Exercise 30.9 ★★.**

A regression includes a constant, an indicator for married men and an indicator for unmarried men. Show that $X$ does not have full column rank. Give two ways to fix it, and say what the coefficients then mean.

**Solution of Exercise 30.9.**

The column of ones equals the sum of the two indicators, so the three columns are linearly dependent and the rank is 2. Either drop one indicator: the constant is then the mean for the omitted group (other regressors fixed) and the remaining coefficient the difference between the groups. Or drop the constant: each indicator’s coefficient is its group’s mean.

**Exercise 30.10 ★★★.**

Show that $M = I - W(W'W)^{-1}W'$ is symmetric and idempotent, that $MW = 0$, and that $My$ is the residual vector of the regression of $y$ on $W$.

**Solution of Exercise 30.10.**

Let $P = W(W'W)^{-1}W'$. Then $P' = W((W'W)^{-1})'W' = P$, since $W'W$ is symmetric, and

$$
PP = W(W'W)^{-1}W'W(W'W)^{-1}W' = P.
$$

So $M = I - P$ is symmetric and $MM = I - 2P + P = M$. $MW = W - W(W'W)^{-1}W'W = 0$. The regression of $y$ on $W$ has coefficients $(W'W)^{-1}W'y$ and fitted values $Py$, so its residual is $y - Py = My$.

**Exercise 30.11 ★★★.**

Prove [(30.1)](#eq-b2-multiple-regression-ovb) in full.

**Solution of Exercise 30.11.**

Let $Z = (x, W)$ and $A = (Z'Z)^{-1}Z'$, so that the short regression’s coefficients are $Ay$. From the long regression, $y = Z\hat b + z\hat\gamma + e$, where $\hat b$ collects $\hat\beta_1$ and $\hat\beta_W$. Then $Ay = AZ\hat b + Az\,\hat\gamma
+ Ae = \hat b + \hat\gamma Az$, since $AZ = I$ and $Z'e = 0$. The first element of $Az$ is $\hat\delta$, so $\hat\beta_1^{\text{short}} = \hat\beta_1^{\text{long}} + \hat\gamma\hat\delta$.

**Exercise 30.12 ★★★.**

Using the [Frisch–Waugh–Lovell theorem](#def-b2-multiple-regression-fwl) and $\operatorname{Var}(u \mid X) = \sigma^2I$, derive [(30.2)](#eq-b2-multiple-regression-var).

**Solution of Exercise 30.12.**

By the theorem $\hat\beta_j = \tilde x_j'y/\tilde x_j'\tilde x_j$ with $\tilde x_j = Mx_j$, a function of $X$ only. With $y = X\beta + u$, $\tilde x_j'y = \tilde x_j'x_j\beta_j + \tilde x_j'u$ (since $\tilde x_j$ is orthogonal to the other columns), and $\tilde x_j'x_j = \tilde x_j'\tilde x_j$. So $\hat\beta_j - \beta_j = \tilde x_j'u/\tilde x_j'\tilde x_j$ and $\operatorname{Var}(\hat\beta_j \mid X) = \sigma^2\tilde x_j'\tilde x_j/(\tilde x_j'\tilde x_j)^2 = \sigma^2/\tilde
x_j'\tilde x_j$. The sum of squared residuals of $x_j$ on the others is $(1 - R_j^2)\sum_i(x_{ij} - \bar x_j)^2 =
(1 - R_j^2)ns_j^2$.

## 30.8 Problem: Brenland’s household survey

**Problem 30.1.**

Weekend problem — Brenland’s household survey: matrices, the return to schooling with controls, partialling out and omitted-variable bias, and the collinearity of age and experience

Brenland’s household survey of 2025 has 2,000 households; 1,922 heads have positive gross income. Let $y_i$ be the log gross income of head $i$, $s_i$ his years of schooling and $a_i$ his age.

**Part I — Matrices.**

1. Write the [regressor matrix](#def-b2-multiple-regression-regressor-matrix) of the regression of $y$ on a constant, $s$ , $a$ and $a^2$ : its size and a typical row.
2. What is the size of $X'X$ ? Of $X'y$ ?
3. What does the first element of $X'X$ count? The first element of $X'y$ ?
4. Why must $X'X$ be invertible for the estimator to exist?
5. What does the first normal equation say about the residuals?

**Part II — Returns to schooling with controls.**

6. Regress $y$ on a constant and $s$ . Give the coefficient on $s$ and $R^2$ .
7. Add $a$ and $a^2$ . Give the coefficient on $s$ , its 95 per cent confidence interval, $R^2$ and $\bar R^2$ .
8. Interpret the coefficient on $s$ in the long regression.
9. At what age is predicted income highest, holding schooling fixed?
10. Why does the coefficient on $s$ barely move?

**Part III — Partialling out and omitted-variable bias.**

11. Regress $s$ on a constant, $a$ and $a^2$ , and keep the residual $\tilde s$ . Compare the variances of $s$ and $\tilde s$ .
12. Regress $y$ on $\tilde s$ . What coefficient do you get?
13. Give $\delta_a$ and $\delta_{a^2}$ , the coefficients on $s$ when $a$ and $a^2$ are regressed on a constant and $s$ .
14. Write the short coefficient as the long one plus the bias, with two omitted variables.
15. Compute the bias and check the identity.
16. Why are $\delta_a$ and $\delta_{a^2}$ so different in size, and yet give a bias near zero?

**Part IV — Collinearity of age and experience.**

17. Define experience as $a - s - 6$ . Regress $y$ on a constant, $s$ , $a$ and experience. What goes wrong?
18. Give the rank of the [regressor matrix](#def-b2-multiple-regression-regressor-matrix) .
19. Which combinations of the coefficients can still be estimated?
20. Give the [variance inflation factors](#def-b2-multiple-regression-vif) of $s$ , $a$ and $a^2$ in the regression of Part II.
21. Why is the high VIF of $a$ and $a^2$ no problem for the coefficient on $s$ ?
22. With half the sample, by what factor would the standard error of the schooling coefficient grow?
23. If ability raised income and was positively correlated with schooling, which way would the estimate be biased?
24. Could controlling for hours worked fix that bias? Could it create another?
25. State the result: the return to schooling with its interval, and the size of the [omitted-variable bias](#def-b2-multiple-regression-ovb) from age.

**Solution of Problem 30.1.**

**Part I.** 1. $X$ is $1{,}922 \times 4$; row $i$ is $(1, s_i, a_i, a_i^2)$. 2. $4 \times 4$; $4 \times 1$. 3. The number of heads, 1,922; the sum of $y_i$. 4. The estimator is $(X'X)^{-1}X'y$; if $X'X$ is singular some coefficients are not identified. 5. The residuals sum to zero. **Part II.** 6. 0.0580; $R^2 = 0.108$. 7. 0.0584, interval 0.0518 to 0.0649; $R^2 = 0.309$, $\bar R^2 = 0.308$. 8. Among heads of the same age, a year more schooling goes with gross income about 5.8 per cent higher. 9. The coefficients are 0.0724 on $a$ and $-0.000755$ on $a^2$; the peak is at $0.0724/(2 \times 0.000755) = 48$ years. 10. In the survey schooling and age are almost uncorrelated, so leaving age out removes little. **Part III.** 11. The variance of $s$ is 6.728, of $\tilde s$ 6.712: age predicts almost none of schooling. 12. 0.0584, the long coefficient, as the theorem says. 13. $\delta_a = 0.318$ and $\delta_{a^2} = 30.99$. 14. $\hat\beta_s^{\text{short}} = \hat\beta_s^{\text{long}} + \hat\gamma_a\hat\delta_a + \hat\gamma_{a^2}\hat\delta_{a^2}$. 15. $0.0724 \times 0.318 - 0.000755 \times 30.99 = 0.0230 - 0.0234 = -0.0004$; $0.0584 - 0.0004 = 0.0580$, the short coefficient. 16. $a^2$ is measured in squared years, so its coefficients are small and its $\delta$ large; the two terms have opposite signs and nearly cancel. **Part IV.** 17. Experience is an exact linear combination of the constant, $s$ and $a$: $X$ has rank 3 with 4 columns, and the coefficients are not identified. 18. 3. 19. Only combinations such as $\beta_s - \beta_e$ and $\beta_a + \beta_e$: the effect of schooling at a given age, or of age at given schooling; never the three separately. 20. 1.00 for $s$, 43.5 for $a$ and for $a^2$. 21. The VIF of $s$ is 1.00: $s$ is almost uncorrelated with $a$ and $a^2$, and its variance does not depend on how well $a$ and $a^2$ can be told apart. 22. By about $\sqrt2 = 1.41$. 23. Upwards: $\gamma > 0$ and $\delta > 0$. 24. No: hours do not measure ability. They may be a bad control, since schooling may change hours worked. 25. The return to a year of schooling in Brenland is 5.84 per cent (95 per cent interval 5.18 to 6.49) holding age fixed; leaving age out changes it by $-0.04$ points, because age and schooling are almost uncorrelated in the survey.
