5Maximum Likelihood Estimation and the Gauss–Markov Theorem
The least squares estimator of Chapter 4 was obtained by a purely geometric criterion: minimize the sum of squared errors. Two questions remain. First, if we are prepared to assume that the errors are normally distributed, what estimator does the more general principle of maximum likelihood give? Second, without assuming normality, is there any sense in which least squares is the best estimator? The answers are, respectively, “the same estimator of \(\boldsymbol\beta\)” and “yes, it is the best linear unbiased estimator”, the second being the celebrated Gauss–Markov theorem(Rao 1973; Montgomery, Peck, and Vining 2021).
5.1 Maximum likelihood estimation
Consider the model \(\mathbf y=\mathbf X\boldsymbol\beta+\boldsymbol\varepsilon\) and assume that \(\boldsymbol\varepsilon\sim\text{iid }N(\mathbf 0,\sigma^2\mathbf I)\). The normal density function of the error \(\varepsilon_i\) is
and the cross derivative \(\partial^2\ln L/\partial\boldsymbol\beta\partial\sigma^2=-\mathbf X'(\mathbf y-\mathbf X\boldsymbol\beta)/\sigma^4\) vanishes at \(\tilde{\boldsymbol\beta}\) because \(\mathbf X'\mathbf e=\mathbf 0\). The Hessian is therefore negative definite and the solution is a maximum.
5.2 Comparing the OLSE and the MLE
Coefficients. The OLSE of \(\boldsymbol\beta\) and the MLE of \(\boldsymbol\beta\) are the same: \(\hat{\boldsymbol\beta}=\tilde{\boldsymbol\beta}=(\mathbf X'\mathbf X)^{-1}\mathbf X'\mathbf y\). Hence the MLE of \(\boldsymbol\beta\) is also unbiased.
Error variance. The OLSE of \(\sigma^2\) is \(s^2=SS_{Res}/(n-p)\), which is unbiased. The MLE is
So \(\tilde\sigma^2\) is biased (downwards), with bias \(-p\sigma^2/n\). The bias vanishes as \(n\to\infty\), so \(\tilde\sigma^2\) is asymptotically unbiased and consistent. In small samples, and especially when \(p\) is not small relative to \(n\), \(s^2\) is preferred.
Assumptions. Least squares needs no distributional assumption to compute; maximum likelihood requires the distribution of the errors to be specified. When the errors are not normal (for example heavy tailed), maximum likelihood leads to a different estimator (see Chapter 16).
Efficiency under normality. Under normality, \(\hat{\boldsymbol\beta}\) attains the Cramér–Rao lower bound \(\sigma^2(\mathbf X'\mathbf X)^{-1}\) and is the minimum variance unbiased estimator among all unbiased estimators, linear or not.
Example 5.1 For the data of Example 4.1, compare the OLS and ML estimates of \(\sigma^2\).
Solution
\(SS_{Res}=25.459\), \(n=12\), \(p=3\). The OLS estimate is \(s^2=25.459/9=2.829\) and the ML estimate is \(\tilde\sigma^2=25.459/12=2.122\); indeed \(\tilde\sigma^2=\frac{9}{12}s^2\). The coefficient estimates are identical. In R, logLik(fit) reports the maximized log-likelihood, which uses \(\tilde\sigma^2\): here \(\ln L(\tilde{\boldsymbol\beta},\tilde\sigma^2)=-\frac n2[\ln(2\pi\tilde\sigma^2)+1]=-21.540\).
The triplet \(\left(\mathbf y,\ \mathbf X\boldsymbol\beta,\ \sigma^2\mathbf I\right)\), that is \(\left(\mathbf y,E(\mathbf y),V(\mathbf y)\right)\), is known as the Gauss–Markov set-up. No distributional assumption is made beyond the first two moments, and \(\mathbf X\) need not be of full rank.
Linear parametric functions and estimability
A linear parametric function is a linear combination \(\mathbf q'\boldsymbol\beta\) of the parameters. It is called estimable if there exists a linear function \(\mathbf k'\mathbf y\) with \(E(\mathbf k'\mathbf y)=\mathbf q'\boldsymbol\beta\) for all \(\boldsymbol\beta\), that is, if \(\mathbf q'=\mathbf k'\mathbf X\) for some \(\mathbf k\) (\(\mathbf q'\) lies in the row space of \(\mathbf X\)). When \(\mathbf X\) has full column rank, every \(\mathbf q'\boldsymbol\beta\) is estimable. In designed experiments, where \(\mathbf X\) is often not of full rank, only certain functions (such as treatment contrasts) are estimable.
Solutions of the normal equations
When \(\mathbf X'\mathbf X\) is singular, the normal equations \(\mathbf X'\mathbf X\boldsymbol\beta=\mathbf X'\mathbf y\) do not have a unique solution. A solution is
where \(\mathbf G\) is a generalized inverse (g-inverse) of \(\mathbf X'\mathbf X\), satisfying \(\mathbf X'\mathbf X\,\mathbf G\,\mathbf X'\mathbf X=\mathbf X'\mathbf X\). When \(\mathbf X'\mathbf X\) is non-singular, \(\mathbf G=(\mathbf X'\mathbf X)^{-1}\) and \(\boldsymbol\beta^0=\hat{\boldsymbol\beta}\). We use the following properties of g-inverses (Appendix A):
and \(\mathbf X\mathbf G\mathbf X'\) is the same (symmetric, idempotent) matrix \(\mathbf H\) for every choice of \(\mathbf G\). Although \(\boldsymbol\beta^0\) depends on \(\mathbf G\), \(\mathbf q'\boldsymbol\beta^0\) does not when \(\mathbf q'\boldsymbol\beta\) is estimable.
5.4 The Gauss–Markov theorem
Gauss–Markov theorem
Under the Gauss–Markov set-up, among the class of linear unbiased estimators of an estimable linear parametric function \(\mathbf q'\boldsymbol\beta\), the least squares estimator \(\mathbf q'\boldsymbol\beta^0\) has the minimum variance. That is, least squares estimators are BLUE (Best Linear Unbiased Estimators).
Proof. Consider the Gauss–Markov set-up \(\mathbf y=\mathbf X\boldsymbol\beta+\boldsymbol\varepsilon\), \(E(\mathbf y)=\mathbf X\boldsymbol\beta\), \(V(\mathbf y)=\sigma^2\mathbf I\). Let \(\mathbf q'\boldsymbol\beta^0\) be the least squares estimator of \(\mathbf q'\boldsymbol\beta\), where \(\boldsymbol\beta^0=\mathbf G\mathbf X'\mathbf y\) is a solution of the normal equations.
Step 1: any other linear unbiased estimator. Let \(\mathbf k'\mathbf y\) be any other linear unbiased estimator of \(\mathbf q'\boldsymbol\beta\). Then
Step 2: \(\mathbf q'\boldsymbol\beta^0\) is unbiased. Using Equation 5.7 and the g-inverse property \(\mathbf X\mathbf G\mathbf X'\mathbf X=\mathbf X\),
That is, \(\mathbf q'\boldsymbol\beta^0\) has minimum variance among the class of linear unbiased estimators of \(\mathbf q'\boldsymbol\beta\); the OLSE is BLUE. Equality holds only when \(V(\mathbf q'\boldsymbol\beta^0-\mathbf k'\mathbf y)=0\), i.e. \(\mathbf k'\mathbf y=\mathbf q'\boldsymbol\beta^0\), so the BLUE is unique. Hence proved. \(\blacksquare\)
5.4.1 An alternative proof for the full rank case
When \(\mathbf X\) has full column rank, any linear estimator of \(\boldsymbol\beta\) can be written \(\mathbf C\mathbf y\) with \(\mathbf C=(\mathbf X'\mathbf X)^{-1}\mathbf X'+\mathbf D\). Unbiasedness, \(E(\mathbf C\mathbf y)=\boldsymbol\beta+\mathbf D\mathbf X\boldsymbol\beta=\boldsymbol\beta\) for all \(\boldsymbol\beta\), requires \(\mathbf D\mathbf X=\mathbf 0\). Then
because the cross products vanish (\(\mathbf D\mathbf X=\mathbf 0\)). Since \(\mathbf D\mathbf D'\) is non-negative definite, every linear unbiased estimator has a covariance matrix at least as large as that of \(\hat{\boldsymbol\beta}\), and in particular \(V(\tilde\beta_j)\ge V(\hat\beta_j)\) for every \(j\).
Note
The Gauss–Markov theorem requires only \(E(\boldsymbol\varepsilon)=\mathbf 0\) and \(V(\boldsymbol\varepsilon)=\sigma^2\mathbf I\). Normality is not required.
“Best” is relative to linear unbiased estimators. A biased estimator (such as ridge regression, Chapter 11) or a nonlinear estimator (such as a robust estimator, Chapter 16) can have smaller mean squared error.
If \(V(\boldsymbol\varepsilon)=\sigma^2\mathbf V\) with \(\mathbf V\neq\mathbf I\), OLS is still unbiased but no longer best; the BLUE is then the generalized (weighted) least squares estimator of Chapter 12.
The theorem also implies that the best linear unbiased predictor of the mean response at \(\mathbf x_0\) is \(\mathbf x_0'\hat{\boldsymbol\beta}\).
5.5 R practical
d12 <-read.csv("csv/notes12.csv")fit <-lm(y ~ x1 + x2, data = d12)n <-nrow(d12); p <-length(coef(fit))SSres <-deviance(fit) # residual sum of squaresc(OLS = SSres / (n - p), ML = SSres / n)
#> OLS ML
#> 2.828777 2.121583
logLik(fit) # maximized log-likelihood
#> 'log Lik.' -21.54024 (df=4)
# Maximum likelihood by direct numerical optimizationnegll <-function(th) { b <- th[1:3]; s2 <-exp(th[4]) r <- d12$y -cbind(1, d12$x1, d12$x2) %*% b0.5* n *log(2* pi * s2) +sum(r^2) / (2* s2)}opt <-optim(c(0, 0, 0, 0), negll, method ="BFGS")round(c(opt$par[1:3], sigma2 =exp(opt$par[4])), 4) # same as OLS beta; SSres/n
#> sigma2
#> 5.3754 3.0118 -1.2855 2.1216
# A singular model: g-inverse solution and an estimable functionlibrary(MASS)X <-cbind(1, d12$x1, d12$x2, d12$x1 + d12$x2) # 4th column is redundantG <-ginv(t(X) %*% X) # Moore-Penrose g-inverseb0 <- G %*%t(X) %*% d12$yq <-c(1, 5, 8, 13) # q' = k'X, estimablec(estimate =sum(q * b0), fitted_from_lm =sum(coef(fit) *c(1, 5, 8)))
#> estimate fitted_from_lm
#> 10.15063 10.15063
Historical Insights
Gauss, Markov and Aitken
Gauss proved in 1821, without assuming normality, that least squares gives the linear unbiased estimates with the smallest variance. Nearly a century later, the Russian mathematician Andrey Markov (better known for Markov chains) restated the result in his textbook on probability (1912), and the theorem came to bear both names. The modern matrix statement and its extension to correlated errors were given by Aitken in 1935 (Aitken 1935), and C. R. Rao’s unified theory of linear estimation using generalized inverses extended it to models of less than full rank (Rao 1973).
Quotes to Inspire
“An approximate answer to the right problem is worth a good deal more than an exact answer to an approximate problem.” - John W. Tukey
5.6 Practical exercises
5.6.1 Practical 5.1: OLS and ML estimates of \(\sigma^2\)
For the milk yield data of Practical 4.1 (\(n=6\), \(p=3\)), compute the OLS and ML estimates of \(\sigma^2\), the bias factor of the ML estimate, and the maximized log-likelihood. Verify by direct numerical maximization of the likelihood.
Solution
\(SS_{Res}=2.2994\). The OLS estimate is \(s^2=2.2994/3=0.7665\) and the ML estimate is \(\tilde\sigma^2=2.2994/6=0.3832\). By Equation 5.5, \(E(\tilde\sigma^2)=\frac{n-p}{n}\sigma^2=0.5\sigma^2\): with only six observations and three parameters, the ML estimate is expected to be half the true variance. The maximized log-likelihood is \(-\frac n2[\ln(2\pi\tilde\sigma^2)+1]=-5.6363\), which equals logLik() in R. The coefficient estimates from maximizing the likelihood numerically are identical to OLS.
For the model \(y_i=\beta x_i+\varepsilon_i\) (through the origin) with \(x=(1,2,3,4)\), compare the variance of the least squares estimator \(\hat\beta=\sum x_iy_i/\sum x_i^2\) with that of the unbiased “ratio” estimator \(\tilde\beta=\sum y_i/\sum x_i\) and the “average slope” \(\check\beta=\frac1n\sum(y_i/x_i)\).
Solution
All three are linear and unbiased. Their variances are
The least squares estimator has the smallest variance, as the Gauss–Markov theorem guarantees. The simulation below confirms this.
Doing it in R
set.seed(567); x <-1:4; beta <-2est <-replicate(20000, { y <- beta * x +rnorm(4)c(LS =sum(x * y) /sum(x^2), ratio =sum(y) /sum(x), avg =mean(y / x))})rowMeans(est) # all close to 2: unbiased
#> LS ratio avg
#> 2.000050 2.000284 2.000417
apply(est, 1, var) # LS has the smallest variance
#> LS ratio avg
#> 0.03301223 0.03999283 0.08935716
The likelihood function is the __________ density of the errors regarded as a function of the parameters.
Under normal errors, the MLE of \(\boldsymbol\beta\) is __________ the OLSE of \(\boldsymbol\beta\).
The MLE of \(\sigma^2\) is \(\tilde\sigma^2=\) __________.
\(E(\tilde\sigma^2)=\) __________, so \(\tilde\sigma^2\) is biased.
The triplet \((\mathbf y,\mathbf X\boldsymbol\beta,\sigma^2\mathbf I)\) is called the __________ set-up.
A linear parametric function \(\mathbf q'\boldsymbol\beta\) is estimable if \(\mathbf q'=\) __________ for some \(\mathbf k\).
A matrix \(\mathbf G\) with \(\mathbf A\mathbf G\mathbf A=\mathbf A\) is called a __________ of \(\mathbf A\).
BLUE stands for __________.
The Gauss–Markov theorem does not require the assumption of __________.
If \(V(\boldsymbol\varepsilon)=\sigma^2\mathbf V\), the BLUE is the __________ least squares estimator.
Short-answer questions
Write the likelihood function of the normal linear regression model.
Derive the MLE of \(\boldsymbol\beta\) and \(\sigma^2\).
Show that the MLE of \(\sigma^2\) is biased and find its bias.
Compare OLSE and MLE in linear regression.
Define the Gauss–Markov set-up.
What is meant by an estimable linear parametric function?
State and prove the Gauss–Markov theorem.
Why is normality not needed for the Gauss–Markov theorem?
Can a biased estimator be better than the BLUE? Explain.
Give the full rank proof of the Gauss–Markov theorem.
Numerical and conceptual questions
Answers are given at the end of the chapter.
In a regression with \(n=20\), \(p=4\), \(SS_{Res}=48\), find \(s^2\) and \(\tilde\sigma^2\).
For Question 1, find the bias of \(\tilde\sigma^2\) if \(\sigma^2=3\).
For what sample size is the bias of \(\tilde\sigma^2\) less than 5% of \(\sigma^2\) when \(p=5\)?
Write \(\ln L\) at its maximum in terms of \(SS_{Res}\) and \(n\).
Two linear unbiased estimators of \(\beta_1\) have variances \(0.40\) and \(0.25\), and the OLSE has variance \(0.25\). Which is BLUE and why?
In the model \(y_{ij}=\mu+\tau_i+\varepsilon_{ij}\) with two treatments, is \(\tau_1\) estimable? Is \(\tau_1-\tau_2\)?
Show that \(\mathbf G=(\mathbf X'\mathbf X)^{-1}\) satisfies the definition of a g-inverse when \(\mathbf X'\mathbf X\) is non-singular.
If \(\mathbf C\mathbf y\) is unbiased for \(\boldsymbol\beta\) with \(\mathbf C=(\mathbf X'\mathbf X)^{-1}\mathbf X'+\mathbf D\), show that \(\mathbf D\mathbf X=\mathbf 0\).
By Equation 5.5, bias \(=-p\sigma^2/n=-4(3)/20=-0.6\).
\(p/n<0.05\Rightarrow n>100\).
Substituting \(\tilde\sigma^2=SS_{Res}/n\) into Equation 5.2: \(\ln L_{\max}=-\frac n2\left[\ln\left(2\pi SS_{Res}/n\right)+1\right]\).
The OLSE (variance 0.25) is BLUE; by the Gauss–Markov theorem no linear unbiased estimator has smaller variance, and the BLUE is unique.
\(\tau_1\) alone is not estimable (\(\mathbf X\) is not of full rank; \(\mu\) and \(\tau_1\) cannot be separated). \(\tau_1-\tau_2\) is estimable: it is the expectation of \(\bar y_1-\bar y_2\).
\(E(\mathbf C\mathbf y)=(\mathbf X'\mathbf X)^{-1}\mathbf X'\mathbf X\boldsymbol\beta+\mathbf D\mathbf X\boldsymbol\beta=\boldsymbol\beta+\mathbf D\mathbf X\boldsymbol\beta\); this equals \(\boldsymbol\beta\) for all \(\boldsymbol\beta\) only if \(\mathbf D\mathbf X=\mathbf 0\).
Aitken, A. C. 1935. “On Least Squares and Linear Combination of Observations.”Proceedings of the Royal Society of Edinburgh 55: 42–48. https://doi.org/10.1017/S0370164600014346.
Montgomery, Douglas C., Elizabeth A. Peck, and G. Geoffrey Vining. 2021. Introduction to Linear Regression Analysis. 6th ed. Hoboken, NJ: John Wiley & Sons.
Rao, C. Radhakrishna. 1973. Linear Statistical Inference and Its Applications. 2nd ed. New York: John Wiley & Sons.