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.

Economics

12 Ordinary Least Squares

National Graduate Institute for Policy Studies (GRIPS)

In chapter 11 we imposed only mild regularity conditions on the data. To further investigate linear least squares estimation and provide additional interpretation of the estimated coefficients, we need to make more assumptions. The purpose of this chapter is to describe the properties of linear least squares estimation under the classical OLS assumptions, where OLS stands for ordinary least squares.

12.1Estimation under OLS

In this section we introduce the OLS assumptions and study the finite sample properties of the OLS estimators under these assumptions.

12.1.1Assumptions

Let X\boldX and y\boldy be as defined in Section 11.1. The OLS assumptions are as follows:

Let’s break these assumptions down and see what they imply.

Assumption 12.1.1 is just a repetition of assumption 11.1.1 from chapter 11. Assumption 12.1.2 can be decomposed into the separate equations

yn=xn⊺ β+un,n=1,…,Ny_n = \boldx_n^\T \, \boldbeta + u_n, \qquad n = 1, \ldots, N

Here are some examples of models that produce relationships in the form of (12.1).

The notation in fact 12.1.1 follows Section 11.1.2.2. Exercise 12.4.2 requests a proof.

Exercise 12.4.3 asks you to give proofs.

Parts (ii) and (iii) are called homoskedasticity and zero correlation respectively.

Combining assumptions 12.1.3 and 12.1.4 gives

var⁡[u ∣ X]:=E [uu⊺ ∣ X]−E [u ∣ X]E [u⊺ ∣ X]=E [uu⊺ ∣ X]\var [ \boldu \given \boldX ] := \EE [ \boldu \boldu^\T \given \boldX ] - \EE [ \boldu \given \boldX ] \EE [ \boldu^\T \given \boldX ] = \EE [ \boldu \boldu^\T \given \boldX ]

Thus the conditional variance–covariance matrix is the diagonal matrix σ2I\sigma^2 \boldI.

12.1.2The OLS Estimators

The standard estimator of β\boldbeta in (12.1) is the least squares estimator β^\hboldbeta defined in (11.9). That is,

β^:=(X⊺X)−1X⊺y\hboldbeta := (\boldX^\T \boldX)^{-1} \boldX^\T \boldy

Unlike chapter 11, it’s now understood as an estimator of the unknown parameter vector β\boldbeta. In this context, β^\hboldbeta is also called the OLS estimator of β\boldbeta. Substituting y=Xβ+u\boldy = \boldX \boldbeta + \boldu into (12.3) and cancelling terms gives the useful comparison

β^=β+(X⊺X)−1X⊺u\hboldbeta = \boldbeta + (\boldX^\T \boldX)^{-1} \boldX^\T \boldu

The usual OLS estimator of the parameter σ2\sigma^2 introduced in assumption 12.1.4 is

σ^2:=RSSN−K\hat \sigma^2 := \frac{\rss}{N - K}

While we can compute β^\hboldbeta and σ^2\hat \sigma^2 directly using the expressions in (12.3) and (12.5), in practice it’s more common to pass them to a routine in a regression package. Here’s an example that runs the gravity model regression (12.2) on world trade data using Python.

First we import some Python libraries often used for statistics:

from numpy import log  # used in the formula below
import pandas as pd, statsmodels.formula.api as smf

Then we read in the data to a pandas DataFrame from a local CSV file:

data = pd.read_csv("./data/gravity_dataset_2013.csv")

Next we build a model using a formula to indicate the regression we want to run symbolically (similar to R).

formula = "log(value) ~ log(egdp) + log(igdp) + log(dist)"
model = smf.ols(formula, data)

The formula used above is analogous to (12.2). We omit the shock (the last term in (12.2)) because it is not part of the data set, as well as the constant term, which is included automatically. The names egdp and igdp represent exporter and importer GDP respectively.

Now we can perform the estimation and print a table summarizing results:

result = model.fit(cov_type='HC1')
print(result.summary())

The output is as follows:

                            OLS Regression Results                            
==============================================================================
Dep. Variable:             log(value)   R-squared:                       0.652
Model:                            OLS   Adj. R-squared:                  0.652
Method:                 Least Squares   F-statistic:                 1.203e+04
Date:                Wed, 04 Nov 2015   Prob (F-statistic):               0.00
Time:                        16:02:42   Log-Likelihood:                -47185.
No. Observations:               19655   AIC:                         9.438e+04
Df Residuals:                   19651   BIC:                         9.441e+04
Df Model:                           3                                         
Covariance Type:                  HC1                                         
==============================================================================
                 coef    std err          z      P>|z|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
Intercept    -30.2350      0.394    -76.773      0.000       -31.007   -29.463
log(egdp)      1.2783      0.008    153.772      0.000         1.262     1.295
log(igdp)      1.0287      0.009    118.885      0.000         1.012     1.046
log(dist)     -1.3483      0.023    -58.113      0.000        -1.394    -1.303
==============================================================================
Omnibus:                     1819.031   Durbin-Watson:                   1.798
Prob(Omnibus):                  0.000   Jarque-Bera (JB):             3361.159
Skew:                          -0.639   Prob(JB):                         0.00
Kurtosis:                       4.571   Cond. No.                         708.
==============================================================================

The value of the OLS estimate β^\hboldbeta is the column under coef. Objects such as standard errors are discussed below. The argument cov_type=’HC1’ to the model.fit call that produced this table requests heteroskedasticity-consistent or "robust" standard errors, which will be discussed in Section 12.2.1.

Let’s check that the values for β^\hboldbeta reported under coef coincide with the expression for β^\hboldbeta given in (12.3). First we build the design matrix X\boldX (see the URL given above for details) and then compute as follows:

betahat = inv(X.T @ X) @ X.T @ y

When we print the result the output agrees with the output in the table

[-30.23498073   1.27825004   1.02865139  -1.34830012]    

The expression for the R2R^2 in the table above is for Rc2R_c^2, as given in (11.31).

Figure 12.1 shows a partial regression plot for the linear model just described. It is produced from the result object generated above via the commands

import matplotlib.pyplot as plt
import statsmodels.api as sm
fig = plt.figure()
fig = sm.graphics.plot_partregress_grid(result, fig=fig)

To understand the figure, consider, for example, the bottom left subplot, which shows the relationship between log(igdp) and the dependent variable. The data points in the plot correspond to the residuals in (11.26) and (11.27). In particular, the values on the horizontal axis are the residuals from regressing log(igdp) on all other columns in X\boldX, while those on the vertical axis are the residuals from regressing the dependent variable log(value) on all other columns in X\boldX.

The relationship between these residuals measures the change in log(value) associated with changing log(igdp) while holding all other variables fixed. The slope of the regression line running through the plot is exactly the coefficient estimate on log(igdp). For clarification see the discussion surrounding (11.26) and (11.27).

The partial regression plot can be useful both for interpretation and diagnostics. For now, however, let’s look at some general theory concerning properties of the OLS estimators.

Partial regression plot for the gravity model

Figure 12.1:Partial regression plot for the gravity model

12.1.3Finite Sample Properties

Let’s start with classical results on finite sample properties under the OLS assumptions. These are elegant results, although you should also read Section 14.2 if you want to view them with proper perspective. Our first result shows that, under the OLS assumptions, the OLS estimators are unbiased.

Now that we know β^\hboldbeta is unbiased, let’s consider the variance.

For a proof, see exercise 12.4.5 and its solution.

Is the value on the right-hand side of (12.8) small or large? A famous result in OLS theory is that under the stated conditions, the OLS estimator β^\hboldbeta is best linear unbiased. That is, in the class of linear unbiased estimators of β\boldbeta, the OLS estimator has the lowest variance.

Here var⁡[β^ ∣ X]⩽var⁡[b ∣ X]\var [\hboldbeta \given \boldX] \leq \var [\boldb \given \boldX] means that var⁡[b ∣ X]−var⁡[β^ ∣ X]\var [\boldb \given \boldX] - \var [\hboldbeta \given \boldX] is nonnegative definite. Since matrices have no standard ordering, this is one way to assert that var⁡[b ∣ X]\var [\boldb \given \boldX] is “larger.” One implication is that var⁡[bk ∣ X]⩾var⁡[β^k ∣ X]\var [b_k \given \boldX] \geq \var [\hat \beta_k \given \boldX] for all kk. (Why?)

Also, linearity of b\boldb means that b\boldb is linear as a function of y\boldy, taking X\boldX as fixed. In view of theorem 3.1.1, this is equivalent to requiring that b=Cy\boldb = \boldC \boldy for some matrix C\boldC. The matrix C\boldC is allowed to depend on X\boldX but not y\boldy.

The statement that b\boldb is unbiased means E [b ∣ X]=E [Cy ∣ X]=β\EE [\boldb \given \boldX] = \EE [ \boldC \boldy \given \boldX] = \boldbeta for all β∈RK\boldbeta \in \RR^K.

12.1.3.1Precision of the Estimates

Theorem 12.1.2 shows that the variance–covariance matrix of β^\hboldbeta given X\boldX is σ2(X⊺X)−1\sigma^2 (\boldX^\T \boldX)^{-1}. The scalar variances of the individual OLS coefficient estimates β^1,…,β^K\hat \beta_1, \ldots, \hat \beta_K are given by the principal diagonal of this matrix. Since each β^k\hat \beta_k is unbiased (theorem 12.1.1), small variance means probability mass concentrated around the true parameter βk\beta_k. In this case, we say that the estimator has high precision.

The Gauss–Markov theorem states that, as far as unbiased linear estimators go, the OLS estimates will have highest precision. But what if we hold the estimation technique fixed, as well as the sample size, and vary the application? Which problems will have high precision estimates, and which will have low precision estimates?

To answer this question, let’s focus on the variance of a fixed coefficient βk\beta_k. We can write y=Xβ+u\boldy = \boldX \boldbeta + \boldu as

y=X1β1+col⁡k(X)βk+u\boldy = \boldX_1 \boldbeta_1 + \col_k (\boldX) \beta_k + \boldu

where col⁡k(X)\col_k(\boldX) is the vector of observations of the kkth regressor, X1\boldX_1 contains as its columns the observations of the other regressors, and β^1\hboldbeta_1 is the OLS estimates of the corresponding coefficients. By the FWL theorem,

β^k=(col⁡k(X)⊺M1col⁡k(X))−1col⁡k(X)⊺M1y\hat \beta_k = (\col_k(\boldX)^\T \boldM_1 \col_k(\boldX))^{-1} \col_k(\boldX)^\T \boldM_1 \boldy

where M1\boldM_1 is the residual projection M1:=I−P1\boldM_1 := \boldI - \boldP_1 and P1:=X1(X1⊺X1)−1X1⊺\boldP_1 := \boldX_1 (\boldX_1^\T\boldX_1)^{-1} \boldX_1^\T projects onto colspace⁡X1\colspace \boldX_1. Applying M1\boldM_1 to both sides of (12.10) yields

M1y=M1col⁡k(X)βk+M1u\boldM_1 \boldy = \boldM_1 \col_k(\boldX) \beta_k + \boldM_1 \boldu

Substituting into (12.11) gives

β^k=βk+(col⁡k(X)⊺M1col⁡k(X))−1col⁡k(X)⊺M1u\hat \beta_k = \beta_k + (\col_k(\boldX)^\T \boldM_1 \col_k(\boldX))^{-1} \col_k(\boldX)^\T \boldM_1 \boldu

Some calculations then show (ex. 12.4.11) that

var⁡[β^k ∣ X]=σ2(col⁡k(X)⊺M1col⁡k(X))−1=σ2∥M1col⁡k(X)∥−2\var[ \hat \beta_k \given \boldX ] = \sigma^2 (\col_k(\boldX)^\T \boldM_1 \col_k(\boldX))^{-1} = \sigma^2 \|\boldM_1 \col_k(\boldX)\|^{-2}

Thus the variance of β^k\hat \beta_k depends on two components, the variance σ2\sigma^2 of the shock uu and the norm of the vector M1col⁡kX\boldM_1 \col_k \boldX.

The variance in σ2\sigma^2 is unavoidable: some data are noisier than others. The larger the variance in the unobservable shock, the harder it will be to estimate βk\beta_k with good precession.

The other term is more interesting. M1col⁡kX\boldM_1 \col_k \boldX is the residuals from regressing col⁡kX\col_k \boldX on X1\boldX_1, and ∥M1col⁡kX∥\|\boldM_1 \col_k \boldX\| is the norm of this vector. If this norm is small, then the variance of β^k\hat \beta_k will be large.

When will this norm be small? It will be so when col⁡kX\col_k \boldX is “almost” a linear combination of the other regressors and hence close to colspace⁡X1\colspace \boldX_1. Then

∥M1col⁡kX∥=∥col⁡kX−P1col⁡kX∥≈0\| \boldM_1 \col_k \boldX \| = \| \col_k \boldX - \boldP_1 \col_k \boldX \| \approx 0

This situation is sometimes referred to as multicollinearity.

Figure 12.2 gives an illustration of the effect of multicollinearity on the variance of OLS estimate β^2\hat \beta_2. In this example X\boldX has two columns. They are related by col⁡2X=δcol⁡1X+(1−δ)z\col_2 \boldX = \delta \col_1 \boldX + (1 - \delta) \boldz, where z\boldz is a vector of NN independent draws from the standard normal distribution. Larger δ\delta means more dependence between col⁡1X\col_1 \boldX and col⁡2X\col_2 \boldX. The true parameter is β2=1\beta_2 = 1. The figure shows the distribution of β^2\hat \beta_2 for different values of δ\delta. The estimator β^2\hat \beta_2 is unbiased but its variance increases with δ\delta. (The normal shape of the distribution is explained in the next section.)

Distribution of \hat \beta_2 when \col_2 \boldX = \delta \col_1 \boldX + (1 - \delta) \boldz

Figure 12.2:Distribution of β^2\hat \beta_2 when col⁡2X=δcol⁡1X+(1−δ)z\col_2 \boldX = \delta \col_1 \boldX + (1 - \delta) \boldz

12.1.4Inference with Normal Errors

If we want to compute confidence intervals or test hypotheses about the coefficients in finite samples (i.e., without appealing to asymptotics), we need to strengthen our OLS assumptions even further, by specifying the parametric class of the error vector u\boldu. Because of its many attractive properties, the normal distribution is the default.

Assumption 12.1.5 implies both assumption 12.1.3 and assumption 12.1.4. It also implies that the conditional distribution of β^\hboldbeta given X\boldX is normal, as can be seen from (12.4) and fact 5.1.5. The next theorem records this result.

It follows from theorem 12.1.4 and (5.12) that the distribution of individual coefficient β^k\hat \beta_k given X\boldX is also normal, with

L[ β^k ∣ X ]=L[ ek⊺ β^ ∣ X ]=N(βk,σ2vk(X))\lL \left[ \, \hat \beta_k \given \boldX \, \right] = \lL \left[ \, \bolde_k^\T \, \hboldbeta \given \boldX \, \right] = \nN(\beta_k, \sigma^2 v_k(\boldX))

Here vk(X):=v_k (\boldX) := the (k,k)(k,k)th element of (X⊺X)−1(\boldX^\T \boldX)^{-1}.

Theorem 12.1.4 and the normality of the marginal distributions along the individual coefficients is illustrated in figure 12.3. The central plot shows the contours of a density estimate that can be understood as a smoothed histogram based on simulated observations of β^\hboldbeta (see Section 14.1 for details on these density estimates). Each observation β^=(β^1,β^2)\hboldbeta = (\hat \beta_1, \hat \beta_2) is obtained by fitting the regression model yn=β1+β2xn+uny_n = \beta_1 + \beta_2 x_n + u_n, where β1=0.5\beta_1 = 0.5, β2=1\beta_2 = 1 and unu_n is standard normal. The sample size for each fit is N=250N=250. The univariate distributions on the top and right are univariate density estimates based on the observations of β^1\hat \beta_1 and β^2\hat \beta_2 respectively.

Simulated observations of \hboldbeta and its marginals

Figure 12.3:Simulated observations of β^\hboldbeta and its marginals

We also want to know the distribution of σ^2\hat \sigma^2, as defined in (12.5). It turns out to be more convenient to work with a transformation of σ^2\hat \sigma^2 defined as

Q:=RSSσ2=(N−K)σ^2σ2Q := \frac{\rss}{\sigma^2} = (N-K) \frac{\hat \sigma^2}{\sigma^2}

12.1.4.1The tt-Test

Let’s consider the problem of testing a hypothesis about an individual coefficient βk\beta_k. Specifically, we consider the null hypothesis

H0 ⁣:βk=βk0H_0 \colon \beta_k = \beta_k^0

where βk0\beta_k^0 is any number. If we knew σ2\sigma^2, we could construct a test of H0H_0 based around the following observation:

zk:=β^k−βkσvk(X)    ⟹    L[ zk ∣ X ]=N(0,1)z_k := \frac{\hat \beta_k - \beta_k} { \sigma \sqrt{v_k(\boldX)} } \; \implies \; \lL [ \, z_k \given \boldX \, ] = \nN(0, 1)

(The implication follows from (12.14).) Since we don’t, the standard methodology is to replace σ2\sigma^2 with its estimator σ^2\hat \sigma^2, and determine the distribution of the resulting test statistic. Our next result implements this idea. In doing so, we will make use of the following notation:

se⁡(β^k):=σ^2vk(X)\se(\hat \beta_k) := \sqrt{ \hat \sigma^2 v_k(\boldX)}

The term se⁡(β^k)\se(\hat \beta_k) is called the standard error of β^k\hat \beta_k. It can be regarded as the sample estimate of the standard deviation of β^k\hat \beta_k. Replacing this standard deviation with its sample estimate se⁡(β^k)\se(\hat \beta_k) and βk\beta_k with βk0\beta_k^0 in (12.16), we obtain the tt-statistic

tk:=β^k−βk0se⁡(β^k)t_k := \frac{\hat \beta_k - \beta_k^0}{\se(\hat \beta_k)}

associated with the hypothesis H0H_0. The distribution of this statistic under the null is described in the next theorem.

Let T:=∣tk∣T := |t_k| and let a desired size α\alpha for our test of H0H_0 be given. In view of (10.18), to generate a test of size α\alpha, we choose c=cαc = c_{\alpha} to solve α=Pθ{T>c}\alpha = \PP_{\theta}\{T > c\}, or

1−α=Pθ{∣tk∣⩽c}1 - \alpha = \PP_{\theta}\{|t_k| \leq c\}

From (4.36), the solution is cα=F−1(1−α/2)c_{\alpha} = F^{-1}(1 - \alpha/2), where FF is the Student’s tt CDF with N−KN-K degrees of freedom. In view of example 10.2.7, the corresponding pp-value is 2F(−∣tk∣)2 F(- |t_k|).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
set.seed(1234) 
N <- 50; K <- 3
beta <- rep(1, K)
X <- cbind(runif(N), runif(N), runif(N))
u <- rnorm(N) 
y <- X %*% beta + u

betahat <- solve(t(X) %*% X) %*% t(X) %*% y 
residuals <- y - X %*% betahat
sigmahat <- sqrt(sum(residuals^2) / (N - K))

# Compute t-stat (Z-score) for k-th regressor
zscore <- function(k) {
    se <- sigmahat * sqrt(solve(t(X) %*% X)[k, k])
    return(betahat[k] / se)
}
# Print t-stats
for (k in 1:3) {
    cat("t-stat, k =", k, ":", zscore(k), "\n")
}
# For comparison:
print(summary(lm(y ~ X - 1)))

Listing 8:Calculating Z-scores (R)

12.1.4.2The FF-Test

The tt-test is used to test hypotheses about individual regressors. For hypotheses concerning multiple regressors, the most common test is the FF-test. The FF-test can test quite general hypotheses. For simplicity we will focus on null hypotheses that restrict a subset of the coefficients to be zero.

Let X1\boldX_1, X2\boldX_2, β^1\hboldbeta_1, β^2\hboldbeta_2, P1\boldP_1, and M1\boldM_1 be as defined in Section 11.2.2. As our null hypothesis we take

H0 ⁣:β2=0H_0 \colon \boldbeta_2 = \boldzero

Since

y=Xβ+u=X1β1+X2β2+u\boldy = \boldX \boldbeta + \boldu = \boldX_1 \boldbeta_1 + \boldX_2 \boldbeta_2 + \boldu

it follows that under the null hypothesis we have

y=X1β1+u\boldy = \boldX_1 \boldbeta_1 + \boldu

Letting

USSR:=∥My∥2andRSSR:=∥M1y∥2\ussr := \| \boldM \boldy \|^2 \quad \text{and} \quad \rssr := \| \boldM_1 \boldy \|^2

be the residual sums of squares for the unrestricted regression (12.19) and restricted regression (12.20) respectively, the standard test statistic for our null hypothesis is

F:=(RSSR−USSR)/K2USSR/(N−K)F := \frac{(\rssr - \ussr) / K_2}{ \ussr / (N - K)}

Large residuals in the restricted regression (12.20) relative to those in (12.19) result in large values for FF, which translates to evidence against the null hypothesis.

The most common implementation of the FF-test is the test that all coefficients of nonconstant regressors are zero. In this case (12.19) becomes

y=1β1+X2β2+u\boldy = \boldone \beta_1 + \boldX_2 \boldbeta_2 + \boldu

where β2\boldbeta_2 is the vector of coefficients corresponding to the nonconstant regressors. Since X1=1\boldX_1 = \boldone, we then have M1=Mc\boldM_1 = \boldM_c, where the latter is defined in (3.10), and hence RSSR\rssr is the squared norm of y−yˉ1\boldy - \bar y \boldone. An application with simulated data is given in listing 9. If you run the program, you will find that the F statistic calculated by the theoretical formula agrees with the F statistic produced by R’s summary function.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
set.seed(1234) 
N <- 50; K <- 3
beta <- rep(1, K)
x2 <- runif(N); x3 <- runif(N)
X <- cbind(rep(1, N), x2, x3)
u <- rnorm(N) 
y <- X %*% beta + u

betahat <- solve(t(X) %*% X) %*% t(X) %*% y 
residuals <- y - X %*% betahat
ussr <- sum(residuals^2)
rssr <- sum((y - mean(y))^2)

Fa <- (rssr - ussr) / 2
Fb <- ussr / (N - K)

cat("F =", Fa / Fb, "\n")        # Print result
print(summary(lm(y ~ x2 + x3)))  # For comparison

Listing 9:Calculating the F statistic (R)

It is an exercise to show that in the case of (12.22), the F statistic in (12.21) can be rewritten as

F=Rc21−Rc2N−KK2F = \frac{R^2_c}{1 - R^2_c} \frac{N - K}{K_2}

where Rc2R^2_c is the centered R squared defined in Section 11.2.3. Can you provide some intuition as to why large FF is evidence against the null?

12.2Problems and Extensions

The standard OLS assumptions are strict and the results we have obtained are sensitive to their failure. Let’s discuss some situations where the OLS assumptions fail and investigate the implications.

12.2.1Nonspherical Errors

Heteroskedasticity occurs when the variance of the error term is not constant across observations, in contradiction to assumption 12.1.4. In particular, the errors are called heteroskedastic if the diagonal terms of E [uu⊺ ∣ X]\EE [ \boldu \boldu^\T \given \boldX ] are not constant. If the off-diagonal terms are nonzero, then the errors are said to have serial correlation.

Failure of assumption 12.1.4 does not alone cause bias in the OLS estimator β^\hboldbeta. This is easily verified by reading the proof of the first part of theorem 12.1.1. Indeed, the proof that β^\hboldbeta is unbiased for β\boldbeta does not require assumption 12.1.4. At the same time, the claim that σ^2\hat \sigma^2 is unbiased for σ\sigma in the second part of theorem 12.1.1 does not make sense without assumption 12.1.4, and the expression var⁡[β^ ∣ X]=σ2(X⊺X)−1\var [\hboldbeta \given \boldX] = \sigma^2 (\boldX^\T \boldX)^{-1} from (12.8) is no longer valid. The Gauss–Markov theorem also breaks down. The most important practical consequence is that the results on inference in Section 12.1.4, which depend on the expression for the variance given above, are no longer valid.

What happens if we replace the assumption E [uu⊺ ∣ X]=σ2I\EE [ \boldu \boldu^\T \given \boldX ] = \sigma^2 \boldI with the more general assumption

E [uu⊺ ∣ X]=Ω\EE [ \boldu \boldu^\T \given \boldX ] = \boldOmega

for some positive definite matrix Ω\boldOmega? (Assumption 12.1.1–Assumption 12.1.3 are maintained.) Using (12.4), we can write the variance of the OLS estimator β^\hboldbeta under these conditions as

var⁡[β^ ∣ X]=E [(β^−β)(β^−β)⊺ ∣ X]=(X⊺X)−1X⊺ΩX(X⊺X)−1\var [\hboldbeta \given \boldX] = \EE [ (\hboldbeta - \boldbeta)(\hboldbeta - \boldbeta)^\T \given \boldX] = (\boldX^\T \boldX)^{-1} \boldX^\T \boldOmega \boldX (\boldX^\T \boldX)^{-1}

If Ω\boldOmega is known, then we can estimate under assumptions 12.1.1–12.1.3 and (12.24) using generalized least squares. The idea is as follows: In view of fact 3.3.10, there exists a nonsingular matrix C\boldC such that C⊺C=Ω−1\boldC^\T \boldC = \boldOmega^{-1}. Using C\boldC, we transform the regression model by multiplying both sides of y=Xβ+u\boldy = \boldX \boldbeta + \boldu by C\boldC. This gives

yc=Xcβ+ucwhereyc:=Cy, Xc:=CX and uc:=Cu\boldy_c = \boldX_c \boldbeta + \boldu_c \quad \text{where} \quad \boldy_c := \boldC \boldy, \, \boldX_c := \boldC \boldX \text{ and } \boldu_c := \boldC \boldu

Exercise 12.4.17 asks you to show that

E [uc ∣ Xc]=0andE [ucuc⊺ ∣ Xc]=I\EE [ \boldu_c \given \boldX_c ] = \boldzero \quad \text{and} \quad \EE [ \boldu_c \boldu_c^\T \given \boldX_c ] = \boldI

Hence the full set of OLS assumptions 12.1.1–12.1.4 is satisfied for the transformed data. If we use the transformed data to estimate β\boldbeta via (Xc⊺Xc)−1Xc⊺yc(\boldX_c^\T \boldX_c)^{-1} \boldX_c^\T \boldy_c, we recover the best linear unbiased property. Expanding out the definitions of Xc\boldX_c and yc\boldy_c and using C⊺C=Ω−1\boldC^\T \boldC = \boldOmega^{-1}, we can show the new estimator to be

β^GLS:=(X⊺Ω−1X)−1X⊺Ω−1y\hboldbeta_{{\rm GLS}} := (\boldX^\T \boldOmega^{-1} \boldX)^{-1} \boldX^\T \boldOmega^{-1} \boldy

This estimator is called the generalized least squares (GLS) estimator of β\boldbeta.

In practice, Ω\boldOmega is rarely known. While we can estimate it, estimation is difficult unless additional structure is imposed. This is because Ω\boldOmega is N×NN \times N, implying that, absent further restrictions, the number of parameters contained in Ω\boldOmega grows faster than the sample. Our estimation problem gets harder the more data that we have.

A common way of adding structure is to assume that Ω\boldOmega is diagonal. That is, Ω=diag⁡(σ12,…,σN2)\boldOmega = \diag(\sigma_1^2, \ldots, \sigma_N^2), where each σn\sigma_n is strictly positive and unknown. The diagonal assumption rules out correlation but maintains the possibility of heteroskedasticity. One estimator of Ω\boldOmega is

Ω^:=diag⁡(u^12,…,u^N2)whereu^:=My\hat \boldOmega := \diag(\hat u^2_1, \ldots, \hat u^2_N) \quad \text{where} \quad \hboldu := \boldM \boldy

Replacing Ω\boldOmega with Ω^\hat \boldOmega in (12.25) leads to the estimate of var⁡[β^ ∣ X]\var [\hboldbeta \given \boldX] given by

V^:=(X⊺X)−1X⊺Ω^X(X⊺X)−1\hat \boldV := (\boldX^\T \boldX)^{-1} \boldX^\T \hat \boldOmega \boldX (\boldX^\T \boldX)^{-1}

If we use this expression in place of the usual variance estimate σ^2(X⊺X)−1\hat \sigma^2 (\boldX^\T \boldX)^{-1} when we form our standard errors, we get the heteroskedasticity-consistent standard errors proposed by White (1980).

12.2.2Bias

In Section 12.2.1 we considered what happens when assumption 12.1.4 (spherical errors) fails. What about the other OLS assumptions? Assumption 12.1.1 (full rank) is fairly benign. Assumption 12.1.2 and Assumption 12.1.3 (linearity and exogeneity) are more problematic. Let’s have a look at how they might fail and the consequences.

The linearity assumption yn=xn⊺ β+uny_n = \boldx_n^\T \, \boldbeta + u_n is fundamental. If we replace it with a more general assumption such as yn=f(xn)+uny_n = f(\boldx_n) + u_n for some arbitrary function ff, then OLS theory falls apart. For example, we cannot even ask if the OLS estimator is unbiased because β\boldbeta has vanished. There is no parameter vector for β^\hboldbeta to estimate.[2]

The remaining assumption we need to consider is exogenous regressors. What happens if all other OLS assumptions hold but assumption 12.1.3 fails?

Observe that, by (12.4),

E [β^ ∣ X]−β=(X⊺X)−1X⊺E [u ∣ X]\EE [ \hboldbeta \given \boldX ] - \boldbeta = (\boldX^\T \boldX)^{-1} \boldX^\T \EE[ \boldu \given \boldX]

Without E [u ∣ X]=0\EE [ \boldu \given \boldX ] = \boldzero, we cannot assert that the right-hand side is zero. Hence β^\hboldbeta is biased. Bias due to failure of assumption 12.1.3 is called endogeneity bias.

As discussed in several parts of this text, striving for unbiasedness is somewhat misguided. Better estimators can usually be constructed by admitting some degree of bias in order to penalize complexity (thereby acknowledging that the empirical distribution is not the true distribution). However, there is an important difference with the bias in (12.29). Good estimators reduce bias as the sample size increases, so that the object they aim to compute can be recovered asymptotically. This is not true for the OLS estimator when exogeneity fails.

To see this, recall from theorem 11.1.2 that β^ →p E [xx⊺]−1 E [x y]\hboldbeta \, \toprob \, \EE[ \boldx \boldx^\T]^{-1} \, \EE[\boldx \, y] as N→∞N \to \infty. The right-hand side is the vector of coefficients in the best linear predictor. If y=x⊺β+uy = \boldx^\T \boldbeta + u, then this becomes

β^ →p E [xx⊺]−1 E [x (x⊺β+u)]=β+E [xx⊺]−1 E [x u]\hboldbeta \, \toprob \, \EE[ \boldx \boldx^\T]^{-1} \, \EE[\boldx \, (\boldx^\T \boldbeta + u)] =\boldbeta + \EE[ \boldx \boldx^\T]^{-1} \, \EE[\boldx \, u]

With exogeneity we get E [x u]=E [x E [u ∣ x]]=0\EE[\boldx \, u] = \EE[ \boldx \, \EE[ u \given \boldx ] ] = 0 and the OLS estimator is consistent. Without exogeneity we cannot assert the same.

12.2.2.1Examples of Endogeneity Bias

Let’s look at some applications where assumption 12.1.3 fails. First up, consider again the Cobb–Douglas example, which yields the regression model

ln⁡yn=γ+aln⁡kn+δln⁡ℓn+un\ln y_n = \gamma + a \ln k_n + \delta \ln \ell_n + u_n

Here yy is output, kk is capital, ℓ\ell is labor, and subscript nn indicates observation on the nnth firm. The term unu_n is a firm specific productivity shock. A likely problem here is that the firm will choose higher levels of both capital and labor when it anticipates high productivity in the current period. This will lead to endogeneity bias.

To illustrate, suppose that un,−1u_{n,-1} is the productivity shock received by firm nn last period and this value is observable to the firm. Suppose further that productivity follows a random walk, with un=un,−1+ηnu_n = u_{n, -1} + \eta_n, where ηn\eta_n is zero-mean white noise. As a result the firm forecasts period nn productivity as E [un ∣ un,−1]=un,−1\EE[u_n \given u_{n,-1}] = u_{n,-1}. Finally, suppose that the firm increases labor input when productivity is anticipated to be high, with the specific relationship ℓn=a+bE [un ∣ un,−1]\ell_n = a + b \EE[u_n \given u_{n,-1}] for b>0b > 0. When all shocks are zero-mean, we then have

E [ℓnun]=E [(a+bun,−1)(un,−1+ηn)]=E [bun,−12]\EE[ \ell_n u_n ] = \EE[ (a + b u_{n,-1})(u_{n,-1} + \eta_n) ] = \EE[ b u_{n,-1}^2 ]

This term will be strictly positive whenever un,−1u_{n,-1} has positive variance. Thus the conditions of fact 12.1.2 fail, and therefore assumption 12.1.3 does not hold (because assumption 12.1.3 implies fact 12.1.2).

This source of endogeneity bias in estimating production functions has been discussed many times in the literature. The best solution is better modeling. For one illustration of careful modeling, see Olley & Pakes (1996).

As a second example of endogeneity bias, suppose next that we have in hand data generated according to the simple AR(1) model

x0=0andxn=βxn−1+unfor n=1,…,Nx_0 = 0 \quad \text{and} \quad x_n = \beta x_{n-1} + u_n \quad \text{for } n = 1,\ldots,N

Let {un}n=1N\{u_n\}_{n=1}^N be IID with distribution N(0,σ2)\nN(0,\sigma^2). The unknown parameters are β\beta and σ2\sigma^2. Letting y:=(x1,…,xN)\boldy := (x_1,\ldots,x_N), x:=(x0,…,xN−1)\boldx := (x_0,\ldots,x_{N-1}), and u:=(u1,…,uN)\boldu := (u_1,\ldots,u_N), we can write the NN equations in (12.30) as y=βx+u\boldy = \beta \boldx + \boldu. The OLS estimate of β\beta is β^:=(x⊺x)−1x⊺y\hat \beta := (\boldx^\T \boldx)^{-1} \boldx^\T\boldy.

By fact 12.1.2, if assumption 12.1.3 holds, then E [umxn+1]=0\EE [ u_m x_{n+1} ] = 0 for any mm and nn. In the current setup this equality fails. For example, if n⩾mn \geq m, then we can (ex. 12.4.15) write xnx_n as

xn=∑j=0n−1βjun−jx_n = \sum_{j=0}^{n-1} \beta^j u_{n-j}

Hence E [xnum]=∑j=0n−1βjE [un−jum]=βn−mσ2\EE[ x_n u_m] = \sum_{j=0}^{n-1} \beta^j \EE[ u_{n-j} u_m] = \beta^{n - m} \sigma^2. In particular, assumption 12.1.3 fails whenever β≠0\beta \neq 0.

To illustrate the bias in β^\hat \beta, listing 10 generates the data 10,000 times, computes β^\hat \beta on each occasion and histograms the result. The parameters are N=25N = 25 and β=0.9\beta = 0.9. The output is figure 12.4. If you modify the code to print the sample mean, it gives around 0.82. Since the number of replications is large, this is close to E [β^]\EE[\hat \beta]. An asymptotic 95% confidence interval for our estimate is around (0.818, 0.824).

import numpy as np
import matplotlib.pyplot as plt

N = 25
x = np.zeros(N)
beta = 0.9                    
num_reps = 10000               
betahat_obs = np.empty(num_reps)
                        
for j in range(num_reps):
    u = np.random.randn(N)
    for t in range(N-1):
        x[t+1] = beta * x[t] + u[t+1]
    y = x[1:]       # x_1 ,..., x_N          
    x_vec = x[:-1]  # x_0, ..., x_{N-1}
    betahat_obs[j]  = np.sum(x_vec * y) / np.sum(x_vec**2)

plt.hist(betahat_obs, bins=50, alpha=0.6, density=True)
plt.show()

Listing 10:Generates and histograms observations of β^\hat \beta (Python)

Observations of \hat \beta when \beta=0.9

Figure 12.4:Observations of β^\hat \beta when β=0.9\beta=0.9

12.2.3Instrumental Variables

The discussion in Section 12.2.2 shows that the OLS estimator is biased and inconsistent when regressors are endogenous. Here we show that a consistent estimator of β\boldbeta can be found when extra information is available in the form of "exogenous" variables called instruments. These instruments will be collected into a N×JN \times J matrix Z\boldZ, where each column is observations on one exogenous variable. We connect Z\boldZ and the other variables via the following assumptions:

  1. y=Xβ+u\boldy = \boldX \boldbeta + \boldu.

  2. E [u ∣ Z]=0\EE[ \boldu \given \boldZ] = \boldzero.

  3. E [uu⊺ ∣ Z]=σ2I\EE[ \boldu \boldu^\T \given \boldZ] = \sigma^2 \boldI for some positive constant σ\sigma.

  4. Z⊺X\boldZ^\T \boldX has full column rank.

As exercise 12.4.18 asks you to show, assumption (iv) implies that J⩾KJ \geq K, which is to say that we have at least as many instruments as regressors. If J>KJ > K, the model is said to be overidentified. If J=KJ=K, the model is called exactly identified. (When J<KJ < K, the model is called underidentified.)

The idea of instrumental variables least squares is to multiply y=Xβ+u\boldy = \boldX \boldbeta + \boldu by Z⊺\boldZ^\T to produce

Z⊺y=Z⊺Xβ+wwherew:=Z⊺u\boldZ^\T \boldy = \boldZ^\T \boldX \boldbeta + \boldw \quad \text{where} \quad \boldw := \boldZ^\T \boldu

Applying (ii) and (iii) from the IV assumptions gives E [w ∣ Z]=0\EE[ \boldw \given \boldZ] = \boldzero and E [ww⊺ ∣ Z]=σ2Z⊺Z\EE [ \boldw \boldw^\T \given \boldZ] = \sigma^2 \boldZ^\T \boldZ. This suggests that we might apply generalized least squares estimation to the linear equation in (12.32). We can use the expression for the GLS estimator from (12.27) after substituting X\boldX for Z⊺X\boldZ^\T \boldX, y\boldy for Z⊺y\boldZ^\T \boldy, and Ω\boldOmega for σ2Z⊺Z\sigma^2 \boldZ^\T \boldZ. This leads to the instrumental variable least squares (IVLS) estimator

β^IVLS:=(X⊺Z(Z⊺Z)−1Z⊺X)−1X⊺Z(Z⊺Z)−1Z⊺y\hboldbeta_{{\rm IVLS}} := (\boldX^\T \boldZ (\boldZ^\T \boldZ)^{-1} \boldZ^\T \boldX)^{-1} \boldX^\T \boldZ (\boldZ^\T \boldZ)^{-1} \boldZ^\T \boldy

In the case where J=KJ = K, this reduces to the simpler expression

β^IVLS:=(Z⊺X)−1Z⊺y\hboldbeta_{{\rm IVLS}} := (\boldZ^\T \boldX)^{-1} \boldZ^\T \boldy

In the preceding discussion, the analogy with GLS was not exact. (Direct application of GLS to (12.32) would require that E [w ∣ Z⊺X]=0\EE[ \boldw \given \boldZ^\T \boldX] = \boldzero rather than E [w ∣ Z]=0\EE[ \boldw \given \boldZ] = \boldzero.) As a consequence we cannot claim unbiasedness and other properties by appealing to the GLS theory. Indeed β^IVLS\hboldbeta_{{\rm IVLS}} is, in general, biased (see ex. 12.4.20).

At the same time, the bias is typically smaller than OLS and vanishes asymptotically (see, e.g., §8.3 of Davidson & MacKinnon (2004)). Figure 12.5 gives an illustration. This figure corresponds to OLS and IVLS estimates of β\beta in y=xβ+uy = x \beta + u when β=10\beta=10, zz is drawn independently of uu, and xx is set equal to αz+(1−α)u\alpha z + (1 - \alpha) u. Thus zz is exogenous and xx is a mixture of zz and uu. The value α\alpha is a constant. In the simulation, α\alpha is set to 0.80.8, so zz is a relatively strong instrument. The histograms are observations of the two estimators over 25,000 repetitions, each one having a sample size of 250250. IV provides a much better estimator of β\beta in this case.

Simulated draws of OLS and IVLS estimators of \beta

Figure 12.5:Simulated draws of OLS and IVLS estimators of β\beta

There is another way to derive the expression given for β^IVLS\hboldbeta_{{\rm IVLS}} on the right-hand side of (12.33). It involves a method called two-stage least squares. The key idea is to project the endogenous regressors onto the column space of the exogenous instruments before running the regression. Exercise 12.4.21 walks you through the details.

12.2.4Causality

Causality is a slippery concept. Let’s touch on some basic points, particularly concerning the connection between causality and regression. (References to more detailed treatments are given in Section 12.3.)

You might have heard R2R^2 interpreted as measuring the “explanatory power” of the regressors in a particular econometric problem. The idea is that regression amounts to decomposing y\boldy into the sum of two orthogonal parts, the fitted values Py\boldP \boldy and the residuals My\boldM \boldy. As in (11.12), the squared norm ∥y∥2=:TSS\| \boldy\|^2 =: \tss can then be decomposed as ∥Py∥2=:ESS\| \boldP \boldy\|^2 =: \ess plus ∥My∥2=:RSS\| \boldM \boldy\|^2 =: \rss. This is sometimes paraphrased as “the total variation in y\boldy is the sum of explained and unexplained variation.” The value of R2R^2 is then claimed to be the fraction of the variation in y\boldy “explained” by the regressors.

This terminology is problematic because the notion that the regressors “explain” variation in y\boldy suggests causation, and R2R^2 says nothing about causation per se. Instead, R2R^2 is better thought of as a measure of correlation (see Section 11.2.3). As has been observed on many occasions, correlation and causation are not the same thing. Two informal examples are as follows:

Identifying causality in observational data can be very challenging. Here’s another example, which, although it falls in the realm of traffic safety, is nonetheless interesting because it involves choices and human behavior: It has been observed that motorcycles fitted with ABS brakes have much lower crash rates than those without anti-lock brakes (see, e.g., Teoh (2011)). Does that mean fitting ABS to a given motorcycle will reduce the probability that the bike is involved in an accident by a similar amount? If so, should traffic authorities mandate the use of ABS brakes?

There’s an obvious problem in jumping to this conclusion: selection bias in the sample. Cautious motorcyclists are more likely to choose bikes with safety features such as ABS. Lower crash rates for ABS bikes might therefore be caused primarily by more careful riding.

We can eliminate the selection bias by randomly assigning bikes of both types to a large group of riders and observing the results. One might expect that such randomization would reduce the observed effect, although perhaps not eliminate it entirely. In fact such a study has already been conducted for the case of passenger vehicles. In Munich, half of a large fleet of taxis were fitted with anti-lock brakes and half were fitted with conventional brakes (Aschenbrenner & Biehl (1994)). The study lasted three years and drivers were randomly assigned across vehicles. A total of 747 accidents were observed. The authors found that accidents rates where slightly higher for taxis fitted with ABS.

The conclusion of the authors is that, while anti-lock brakes do improve braking performance, drivers compensate by driving faster, making shaper turns, poorer lane changes, and so forth. (This altered behavior is called "risk compensation.") The net effect is roughly zero: mandatory ABS brakes will cause no appreciable drop in accident rates.

In general, understanding causality requires either good experiments or good theory. There is no magic econometric procedure that can reliably extract causality from observational data without a good model.

12.3Further Reading

General econometrics texts treating OLS and its extensions include Hayashi (2000), Kennedy (2008), Greene (2011), Davidson & MacKinnon (2004), Wooldridge (2010), and Cameron & Trivedi (2005). A comprehensive treatment of theory can be found in Ruud (2000).

Regarding robust standard errors, asymptotics of the estimator in (12.28) are provided in White (1980). Closely related is the covariance matrix estimator proposed in Newey & West (1987). See Hayashi (2000), Hansen (2015), and Cameron & Trivedi (2005) for textbook treatments.

Measurement errors form another source of bias in OLS estimators. There is a standard approach to so-called errors-in-variables models based around instrumental variables. See, for example, chapter 8 of Davidson & MacKinnon (2004). For a treatment of nonlinear errors-in-variables, see Chen et al. (2011).

For more discussion of causality, see Freedman (2009), Angrist & Pischke (2009), Pearl (2009), or Imbens & Rubin (2015). An important notion of causality in time series models is the ability of one time series to predict another. A seminal contribution is Granger (1969). See Dufour & Taamouti (2010) for a more recent discussion. Chernozhukov et al. (2013) consider how to perform inference on counterfactual distributions. Belloni et al. (2014) discuss treatment effects in high dimensional settings.

12.4Exercises

12.4.1Solutions to Selected Exercises

Footnotes
  1. Hint: See fact 2.2.7.

  2. It is an interesting habit of economists to quibble endlessly about whether someone’s estimators are biased, even when their models are wildly speculative in terms of specific functional forms. (For example, do we really believe that log GDP per capita is a linear function of various measures of institutional quality and an Africa dummy, say, or even that this is a close depiction of reality? If not, what exactly does it mean to say that β^\hboldbeta is biased?)

  3. Hint: Use fact 5.1.13.

  4. Hint: Consider the regression model y=1β+u\boldy = \boldone \beta + \boldu.

References
  1. van Bergeijk, P. A., & Brakman, S. (2010). The Gravity Model in International Trade: Advances and Applications. Cambridge, UK: Cambridge University Press.
  2. White, H. (1980). A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity. Econometrica, 48(4), 817–838.
  3. Olley, G. S., & Pakes, A. (1996). The dynamics of productivity in the telecommunications equipment industry. Econometrica, 64(6), 1263–1297.
  4. Davidson, R., & MacKinnon, J. G. (2004). Econometric Theory and Methods. Oxford: Oxford University Press.
  5. Teoh, E. R. (2011). Effectiveness of antilock braking systems in reducing motorcycle fatal crash rates. Traffic Injury Prevention, 12(2), 169–173.
  6. Aschenbrenner, K., & Biehl, B. (1994). Improved safety through improved technical measures? In R. M. Trimpop & G. J. S. Wilde (Eds.), Challenges to Accident Prevention. The Issue of Risk Compensation Behaviour (pp. 81–89).
  7. Hayashi, F. (2000). Econometrics. Princeton: Princeton University Press.
  8. Kennedy, P. (2008). A Guide to Econometrics (6th ed.). Hoboken, NJ: Wiley Blackwell.
  9. Greene, W. (2011). Econometric Analysis (7th ed.). New York: Prentice Hall.
  10. Wooldridge, J. M. (2010). Econometric Analysis of Cross Section and Panel Data (2nd ed.). Cambridge: MIT Press.
  11. Cameron, A. C., & Trivedi, P. K. (2005). Microeconometrics: Methods and Applications. Cambridge, UK: Cambridge University Press.
  12. Ruud, P. A. (2000). An Introduction to Classical Econometric Theory. Oxford: Oxford University Press.
  13. Newey, W. K., & West, K. D. (1987). A simple, positive semi-definite, heteroskedasticity and autocorrelation consistent covariance matrix. Econometrica, 55(3), 703–708.
  14. Hansen, B. E. (2015). Econometrics. Textbook in preparation. http://www.ssc.wisc%20edu/~bhansen/econometrics
  15. Chen, X., Hong, H., & Nekipelov, D. (2011). Nonlinear models of measurement errors. Journal of Economic Literature, 49(4), 901–937.