Variance of OLS with Non-Spherical Errors
Variance of OLS with Non-Spherical Errors
Krishna Pendakur
February 15, 2016
1 Efficient OLS
1. Consider the model
Y = Xβ + ε
0
E [X ε] = 0K
E [εε0 ] = Ω = σ 2 IN .
3. Its bias is
h i h i
−1 −1
E β̂OLS −β = E (X 0 X) X 0 Xβ + (X 0 X) X 0 ε − β
h i
−1 −1
= E (X 0 X) X 0 ε = (X 0 X) 0K = 0K
The variance of the estimated parameter vector is the expectation of the square of
(X 0 X)−1 X 0 ε, which is the deviation between the estimate and its mean (which happily
is its target):
h i 0
V β̂OLS = E β̂OLS − β β̂OLS − β
h i
−1 −1
= E (X 0 X) X 0 εεX (X 0 X)
−1 −1
= (X 0 X) X 0 E [εε0 ] X (X 0 X)
−1 −1
= (X 0 X) X 0 σ 2 IN X (X 0 X)
−1 −1
= σ 2 (X 0 X) X 0 X (X 0 X)
−1
= σ 2 (X 0 X)
1
(a) Let
Y = Xβ + ε
E [ε] = 0N ,
E [εε0 ] = Ω = σ 2 IN ,
E [CY ] − β = β + DXβ + 0 − β
E[ε] = 0N =⇒ E [D0 ε] = 0K . Unbiasedness thus requires DX = 0.
(d) As with the OLS estimator, since it is unbiased, CY − β = Cε. Its variance is
the expectation of the square of this:
V [CY ] = V [Cε] = σ 2 CC 0
−1 −1 −1 −1
= σ 2 [(X 0 X) X 0 X (X 0 X) + DX (X 0 X) + (X 0 X) X 0 D0 + DD0 ]
−1
= σ 2 [(X 0 X) + 0 + 0 + DD0 ]
(e) Since DD0 is a square, it is positive semidefinite, and its minimum is zero when
D = 0. Consequently, the lowest-variance unbiased estimator for the homoskedas-
tic linear model is when D = 0, which is the OLS estimator.
h i
5. Getting back to V β̂ = σ 2 (X 0 X)−1 , a problem is that σ 2 is not observed. So, we
don’t yet have a useful object.
e = Y − X β̂OLS .
2
e is a linear transformation of ε. However, although I − X (X 0 X)−1 X 0 is an N xN
matrix, it is not a full rank matrix: its columns are related. Indeed, this N xN weighting
matrix is all driven by the identity matrix, which has rankN , and the matrix X, which
only has K columns. The full matrix I − X (X 0 X)−1 X 0 has rank N − K.
(a) for any matrix Z, denote its projection matrix PZ = Z(Z 0 Z)−1 Z 0 and its error
projection as MZ = I − Z(Z 0 Z)−1 Z 0
(b) These are convenient. We can write the OLS estimate of Xβ as
X β̂OLS = PX Y,
e = MX Y
and also,
e = MX ε
(c) We say stuff like “The matrix PX projects X onto Y .”
(d) These matrices have a few useful properties:
i. they are symmetric.
ii. they are idempotent, which means they equal their own square: PZ PZ = PZ ,
MZ MZ = MZ
e = MX ε
so,
E [e0 e] = E [ε0 MX MX ε]
= E [ε0 MX ε]
h i
0 0 0 −1 0
= E [ε ε] − E ε X (X X) X ε
= N σ 2 − Kσ 2
E [e0 e]
= σ2.
N −K
3
So, we can use an estimate
2 e0 e
σ̂ =
N −K
An estimate of the variance of the OLS estimator is thus given by
h i
−1
V̂ β̂OLS = σ̂ 2 (X 0 X) .
Now, we can compute the BLUE estimate, and say something about its bias (zero)
and its sampling variability.
9. Time to crack open Kennedy for Ballentines (Kennedy, Peter E. 2002. More on Venn
Diagrams for Regression, Journal of Statistics Education Volume 10, Number 1), linked
on the course website. Go through ε vs cov(X, Y ) and the 2 regressor case.
4
i. Consider a model with 2 columns in X and no constant, and let the columns
of X be positively correlated.
ii. Then, X 0 X has elements Xj0 Xk for j, k = 1, 2. Its diagonals are the sum
of squares of each column (call them a and b), and its off-diagonal is the
a c
cross-product (call that c). So, X 0 X is given by . Then, (X 0 X)−1
c b
1 b −c b a
is given by ab−c2 , whose diagonal elements are ab−c 2 and ab−c2 .
−c a
These elements increase as c, the cross-product of the columns, increases. So,
more correlation of the X’s means higher variance of the estimates.
(e) If the columns of X covary a lot, then although we have less precision on any
one regressor’s coefficient, we may have a lot of precision on particular linear
combinations of coefficients.
i. Suppose the two variables mentioned above strongly positively covary, so that
c is positive and big. The covariance of the two coefficients is −c/(ab − c2 ).
When c goes up, the numerator goes up and the denominator goes down,
so the overall ratio goes up a lot. Since a, b are both sums of squares, they
are positive. The cross-product c cannot exceed a or b, so the denominator
is positive. Thus, these positively covarying regressors would result in esti-
mated coefficients that each have high variance, but are strongly negatively
correlated.
ii. Consider the variance of the sum of the two coefficients: V (β1 + β2 ) =
1
ab−c2
(b + b − 2c). The larger is c, the smaller is this variance.
11. The Frisch-Waugh-Lovell Theorem can be expressed in a simple way using projection
matrices. Let
Y = X1 β1 + X2 β2 + ε
and consider premultiplying the whole thing by the error-maker matrix for X2 , MX2 .
This gives
MX2 Y = MX2 X1 β1 + MX2 X2 β2 + MX2 ε.
The projection of X2 onto itself is perfect, so it has no error, so MX2 X2 = 0. Thus, we
have
MX2 Y = MX2 X1 β1 + MX2 ε.
Writing Ŷ = MX2 Y and X̂1 = MX2 X1 , we have
Ŷ = X̂β1 + MX2 ε.
5
(a) so you can regress Ŷ on X̂ to get an estimate of β1 .
(b) In terms of Kennedy’s Ballentines, M X2 Y is the part of Y that has had X2 cleaned
out of it, and MX2 X1 is the part of X1 that has had X2 cleaned out of it.
2 NonSpherical errors
1. In a model
Y = g (X, β) + ε,
if errors satisfy
E [εε0 ] = σ 2 IN ,
we call them spherical. Independently normal errors are spherical, but the assump-
tion of independent normality is much stronger than the assumption that errors are
spherical, because normality restricts all products of all powers of all errors. In con-
trast, the restriction that errors are spherical restricts only the squares of errors and
cross-products of errors:
E (εi )2 = σ 2 ,
E [εi εj ] = 0,
for all i 6= j. This means that there are no correlations in errors across ob-
servations. This rules out over-time correlations in time-series data, and spatial
correlations in cross-sectional data.
(a) Imagine that we have a linear model with a constant α and one regressor (the
vector X):
Y = α + Xβ + ε,
E [ε] = 0N
E [εε0 ] = Ω =
6 σ 2 IN
where
0 0 0
Ω = 0 IN −2 0 .
0 0 0
That is, we have an environment where we know that the first and last observation
have a error term of zero, and all the rest are of the usual kind.
6
i. Consider a regression line that connects the first and last data points, and
ignores all the rest. This regression line is exactly right. Including other data
in the estimate only adds wrongness. Thus, the best linear unbiased estimator
in this case is the line connecting the first and last dots. Consequently, OLS
is inefficient—it does not have the lowest variance.
ii. The point is that you want to pay close attention where the errors have low
variance and not pay much attention where the errors have high variance.
(b) Alternatively, imagine that
σ2 0 0
2 0
Ω = 0 σ ιN −1 ιN −1 0 .
0 0 σ2
Y = α + Xβ + ε,
E [ε] = 0N
E [εε0 ] = Ω
Here, if Ω 6= σ 2 IN , you have some known form of nonspherical errors: either het-
eroskesticity, or correlations across observations. Note that E [ε] = 0 ⇒ E[X 0 ε] = 0
for fixed X.
2. We know that OLS is the efficient estimator given homoskedastic errors, but what
about the above case?
3. The trick is to convert this problem back to a homoskedastic problem. Consider pre-
multiplying Y and X by Ω−1/2
7
Here is a model with the error term premultiplied by this weird inverse-matrix-square-
root thing.
4. What is the mean and variance of this new transformed error term?
E Ω−1/2 ε = Ω−1/2 E [ε] = 0
= Ω−1/2 ΩΩ−1/2
= Ω−1/2 Ω1/2 Ω1/2 Ω−1/2 = IN IN = IN
(see Kennedy’s appendix “All About Variance” for more rules on variance computa-
tions).
5. So the premultiplied model is homoskedastic with unit variance errors.
6. Given that the coefficients in the transformed model are the same as those in the
untransformed model, we can estimate them by using OLS on the transformed model.
7. Tranforming data by a known variance matrix and then applying OLS is called Gen-
eralised Least Squares (GLS).
8. We refer to the matrix
T = Ω−1/2
as the Transformation Matrix.
9. GLS in Stata is
10. reg TY TX
8
2. The transformation matrix T amounts to multiplying each Y and each X by the square
root of the sample size used in each country.
3. One need not include the scalar σ in T , because leaving it out just loads it on to the
second stage which would have variance σ 2 IN instead of IN .
4. This strategy, in which you premultiply each observation separately, rather than pre-
multiplying a whole vector of Y and a whole matrix of X, is appropriate when the
covariance matrix is diagonal as it is in the grouped mean data case. This strategy is
referred to as Weighted Least Squares (WLS).
(a) in Stata,
(b) reg Y X [aweight=S]
(Actually, this is a bit stronger than what is needed: you just need θi orthogonal
to Xit , but the differing subscripts makes that assumption notationally cumber-
some.) The fact that θi are mean zero no matter what value X takes is strong.
For example, if X includes education and θi is meant to capture smartness, we
would expect correlation between them. We also need the variance of θi to be in-
dependent of X. For example, if half of all people are lazy and lazy people never
go to college, then the variance of θi would covary positively with X observed
post-secondary schooling.
9
(b) Given the assumption on θi , we get
where
uit = θi + εit
is a composite error term which satisfies exogeneity, but does not satisfy the
spherical error term requirement for efficiency of OLS.
(c) One could use OLS of Y on X and get unbiased consistent estimates of β. The
reason is that the nonspherical error term only hurts the efficiency of the OLS
estimator; it is still unbiased.
(d) However, this approach leaves out important information that could improve the
precision of our estimate. In particular, we have assumed that the composite
errors have a chunk which is the same for every t for a given i. There is a GLS
approach to take advantage of this assumption. If we knew the variance of the θi
terms, σθ2 , and knew the variance of the true errors, σε2 , we could take advantage
of this fact.
(e) Under the model, we can compute the covariance of errors of any two observations:
Ω = E [uit ujs ] = E[(θi + εit )(θj + εjs )] = I[i = j]σθ2 + I[s = t]σε2
where I[.] is the indicator function. This covariance matrix is block diagonal,
where each block consists of the sum of the two variances σθ2 and σε2 on the
diagonal, and just σθ2 off the diagonal. These blocks lie on the diagonal of the
big matrix, and the off-diagonal blocks are all zero. (see Green around p 295 for
further exposition). So, Ω has diagonal elements equal to σθ2 + σε2 and within-
person off-diagonal elements equal to σθ2 and across-person off-diagonal elements
equal to 0.
(f) FGLS requires a consistent estimate of the two variances. A fixed effects model
can be run in advance to get estimates of these variances. Or, one could run OLS
and construct an estimate of the error covariance matrix directly. Either yields a
consistent estimate.
i. reg Y X [Link]
ii. compute the variance of the person dummies for σθ2 and use the estimate of
the variance of the fixed effects error term for σε2 .
iii. reg Y X
iv. take the average squared error as an estimate of σε2 and the average cross-
product of errors for a given person as an estimate of σθ2 + σε2 .
(g) Now, form Ω and T and run GLS.
(h) The FGLS estimator uses a consistent pre-estimate of Ω, but this estimate is
only exactly right asymptotically. Thus, the FGLS estimator is only efficient
asymptotically. In the small-sample, it could be kind of crappy because the pre-
estimate of Ω might be kind of crappy.
10
4. The trick with FGLS is that the covariance matrix Ω has N (N − 1)/2 elements (it is
symmetric, so it doesn’t have N xN elements). Thus, it always has more elements than
you have observations. So, you cannot estimate the covariance matrix of the errors
without putting some structure on it. We’ll do this over and over later on.
4 Inefficient OLS
1. What if errors are not spherical? OLS is inefficient, but so what? Quit your bellyachin’—
it still minimizes prediction error, it still forces orthogonality of errors to regressors, it
is still easy to do, easy to explain, just plain easy.
2. But, with non-spherical errors, the variance of the OLS estimated coefficient is different
from when errors are spherical. Consider the model
Y = Xβ + ε
0
E [X ε] = 0K
E [εε0 ] = Ω =
6 σ 2 IN .
Recall that
h i h i
−1 −1
E β̂OLS − β = E (X 0 X) X 0 Xβ + (X 0 X) X 0 ε − β
h i
−1 −1
= E (X X) X ε = (X 0 X) 0K = 0K
0 0
The variance of the estimated parameter vector is the expectation of the square of this
quantity:
h i 0
V β̂OLS = E β̂OLS − β β̂OLS − β
h i
0 −1 0 0 −1
= E (X X) X εεX (X X)
−1 −1
= (X 0 X) X 0 E [εε0 ] X (X 0 X)
−1 −1
= (X 0 X) X 0 ΩX (X 0 X) .
3. It seems like you could do something like with the spherical case to get rid of the bit
with Ω: After all E [εε0 ] = Ω, so perhaps we could just substitute in some errors. For
example, we could compute
−1 −1
(X 0 X) X 0 ee0 X (X 0 X) .
Unfortunately, since OLS satisfies the moment condition X 0 e = 0, this would result in
−1 −1
(X 0 X) 0K 00K X (X 0 X) = 0K 00K .
11
4. The problem for estimating Ω is the same as with FGLS: Ω has too many parameters to
consistently estimate without structure. You might think that a model like that used
for WLS might be restrictive enough: you reduce Ω to just N variance parameters
and no off-diagonal terms. Unfortunately, with N observations, you cannot estimate
N parameters consistently.
5. Robust Standard Errors.
(a) The trick here is to come up with an estimate of X 0 ΩX (which is a KxK ma-
trix). There are many strategies, and they are typically referred to as ’robust’
variance estimates (because they are robust to nonspherical errors) or as ’sand-
wich’ variance estimates, because you sandwich an estimate Xd 0 ΩX inside a pair
−10
of (X 0 X) ’s. For the same reason as above, you cannot substitute ee0 for Ω,
because you’d get Xd 0 ΩX = X 0 ee0 X = 0.
(b) General Heteroskedastic errors. Imagine that errors are not correlated with each
other, but they don’t have identical variances. We use the Eicker-White Hetero-
robust variance estimator.
i. First, restrict Ω to be a diagonal matrix with diagonal elements σi2 and off-
diagonal elements equal to 0. This is the structure you have imposed on the
model: diagonal Ω.
ii. Then, construct an estimate of X 0 ΩX that satisfies this structure:
0 ΩX = X 0 DX
Xd
where D is a diagonal matrix with (ei )2 on the main diagonal.
(c) You cannot get a consistent estimate of D, because D has N elements: adding
observations will not increase the precision of the estimate of any element of D.
(d) However, X 0 DX is only KxK, which does not grow in size with N . Recall that
asymptotic variance is equal to the variance divided by N , and it is used because
the variance goes to 0 as the sample size goes to infinity. To talk about variance
as the sample size grows, you have to reflate it by something, in this case N .
(The choice of what to reflate it by underlies much of nonparametric econometric
theory—in some models, you have to reflate by N raised to a power less than 1).
So, h i 1 −1 −1
asy.V β̂OLS = (X 0 X) X 0 ΩX (X 0 X) ,
N
and
h i 1 −1 0 ΩX (X 0 X)−1 =
asy.V̂ β̂OLS = (X 0 X) Xd
N
0
−1 X ΩX −1
d
(X 0 X) (X 0 X) .
N
Consider a model where X = 1, a column of ones. Then,
0 ΩX 0 DX
PN 2
Xd Xd i=1 (ei )
= = .
N N N
12
As N grows, this thing gets closer and closer to the average σi2. .
(e) In Stata, you can get the hetero-robust standard errors as follows:
(f) reg Y X, robust
13
where C is block diagonal, with elements equal to ei ej (or their average) in the
blocks and zero elsewhere. Then,
h i 1 −1 −1
asy.V̂ β̂OLS = (X 0 X) X 0 CX (X 0 X) .
N
(e) In Stata,
(f) reg Y X, cluster(g)
(g) A question for you: why can’t we go maximally general, and have just 1 big
cluster?
14