Inference for Linear Models
Gauss–Markov, standard errors, confidence intervals and their assumptions.
A regression coefficient is an estimate, and an estimate without an error bar is half an answer. Under two moment assumptions least squares is the best linear unbiased estimator; add Gaussian noise and every interval and test becomes exact. This lesson proves both, then shows what breaks when the noise variance changes, when there are many features, and when the model was chosen by looking at the data.
What you’ll learn
- State and prove the Gauss–Markov theorem, and explain what "best linear unbiased" does and does not rule out.
- Derive the distributions of and under Gaussian noise, and build -tests, confidence intervals, prediction intervals and -tests.
- Compute heteroscedasticity-consistent (sandwich) standard errors and explain when even they fail.
- Explain why classical inference after data-driven model selection is invalid, and describe valid alternatives.
Assumptions and the Gauss–Markov theorem
Treat the design as fixed (or condition on it), with full column rank, and assume with
- (A1) : the linear model for the mean is correct;
- (A2) : the errors are uncorrelated and have a common variance (homoscedastic).
No distribution is assumed. Since , (A1) makes least squares unbiased and (A2) gives .
Unbiasedness for every means for all , that is . Write as least squares plus a correction ; then :
Compute the covariance with (A2). The cross terms contain or its transpose, so they vanish:
is positive semidefinite, with , which vanishes for every only when .
Gauss proved the theorem in the 1820s; it also carries Andrey Markov's name. Read its fine print:
- Biased estimators can win. Ridge regression is biased and has smaller mean squared error than least squares for a suitable , often by a lot when features are collinear (Convergence lesson Ridge Regression in Depth).
- Nonlinear estimators can win. With heavy-tailed noise, Huber's or absolute-loss estimators can be far more precise than least squares, and hence than every linear unbiased estimator (Convergence lesson Robust Regression).
- Correlated or unequal noise. If with known , least squares is still unbiased but no longer best; the BLUE is generalized least squares, (Aitken, 1935).
- Gaussian noise removes the word "linear". If , the Fisher information for is , and attains the Cramér–Rao bound: least squares is then the best of all unbiased estimators.
Gaussian noise: exact distributions
(a) is an affine function of a Gaussian vector, hence Gaussian, with the mean and covariance computed earlier.
The mean of RSS needs only (A1) and (A2), not normality. Write and use : the residuals live in an -dimensional space, and dividing by corrects for it.
(b) Diagonalize the projection , with eigenvalues equal to 1 and the rest 0. The vector is standard Gaussian, so RSS is a sum of independent squared standard normals:
(c) depends on only through , and RSS only through . These are jointly Gaussian and uncorrelated, hence independent. A standard normal divided by an independent is .
| Question | Interval or test (level , ) |
|---|---|
| Where is ? | Confidence interval ; test with |
| Where is the mean response ? | |
| Where will a new fall? | Prediction interval |
| Do linear restrictions hold (a smaller nested model)? | under the restrictions; for one coefficient |
For the four points , , , : slope , and , so . What is the -statistic for testing a zero slope?
Show the answer
5.19
and , so . With only 2 degrees of freedom the 97.5% quantile is (not 1.96), giving the 95% interval and a two-sided -value of about (for 2 degrees of freedom the tail has the closed form ).
Unequal variances and sandwich standard errors
Suppose (A2) fails: the errors are still uncorrelated, but varies, . Least squares stays unbiased, but its covariance becomes a sandwich:
and the classical can be too small or too large, depending on whether the large variances sit at high-leverage points. White (1980) showed that the "meat" can be estimated without modeling at all, by plugging in squared residuals: . The resulting estimator is consistent as with fixed.
| Estimator | Idea | |
|---|---|---|
| HC0 (White, 1980) | consistent, but too small in small samples, because under homoscedasticity | |
| HC1 | a global degrees-of-freedom correction | |
| HC2 | exactly unbiased when the errors are in fact homoscedastic | |
| HC3 | close to the jackknife estimator, which MacKinnon & White (1985) found the most reliable in small samples; more conservative |
Two warnings. First, these are large-sample results with fixed: when the number of covariates grows in proportion to , the usual Eicker–White estimators become inconsistent, and Cattaneo, Jansson & Newey (2018) derive a corrected formula. Second, the sandwich is more than a patch for heteroscedasticity. If the mean is not linear at all, least squares with random design estimates the best linear approximation , and the sandwich is the correct asymptotic covariance for that target, while the classical formula is not (Convergence lesson When the Model Is Wrong).
A residual plot shows a funnel: the spread grows with . Which statement about ordinary least squares is correct?
- The coefficients are biased, so the fit must be discarded
- The coefficients are still unbiased, but the classical standard errors are unreliable; sandwich standard errors (or weighted least squares) fix the inference
- Nothing changes, because Gauss–Markov needs only
- The is invalid, but the standard errors are fine
Show the answer
B. The coefficients are still unbiased, but the classical standard errors are unreliable; sandwich standard errors (or weighted least squares) fix the inference
Unbiasedness needs only (A1). Heteroscedasticity breaks (A2), so is the wrong covariance and least squares is no longer BLUE; weighted least squares with weights would be, if the variances were known. Sandwich standard errors repair the inference without modeling them.
Inference after selection
Every interval above assumes the model was fixed before looking at the data. In practice analysts screen variables, run stepwise searches, try transformations, and keep what looks significant. Selection favors variables whose estimates came out large by chance, so the reported intervals undercover and the p-values are too small. Even consistent selection does not rescue classical inference uniformly over the parameter space; Leeb & Pötscher (2005) explain why, and discuss an impossibility result: the finite-sample distribution of a post-selection estimator cannot even be estimated uniformly consistently.
You test 50 features that have no effect at all, each at level , and keep the most significant one. If the 50 tests were independent, what is the chance that at least one comes out "significant"?
Show the answer
92 %
. Reporting the winner's -value as if it had been chosen in advance is the classic multiple-comparisons trap: a model built this way almost always "finds" something.
| Remedy | How it works | Cost |
|---|---|---|
| Sample splitting | select on one half of the data, do classical inference on the other | less data for each task; results depend on the split |
| Simultaneous intervals (PoSI; Berk, Brown, Buja, Zhang & Zhao, 2013) | widen the intervals until they hold simultaneously for every submodel, so any selection rule, even an informal one, is covered | conservative, though less so than Scheffé's bound |
| Conditional (selective) inference | compute -values conditional on the selection event, for example on which variables the lasso picked | requires a precisely specified selection procedure |
Key takeaways
- Gauss–Markov: with mean-zero, uncorrelated, equal-variance errors, least squares has the smallest covariance among linear unbiased estimators. Biased (ridge) or nonlinear (robust) estimators can still beat it, and with Gaussian errors it is the best of all unbiased estimators.
- Under Gaussian noise, , independently, and -intervals, prediction intervals and -tests are exact. is unbiased even without normality.
- With unequal variances least squares stays unbiased but needs the sandwich covariance; HC0–HC3 estimate it from squared residuals, and they too fail when does not vanish.
- Selecting a model with the data and then reporting classical intervals is invalid. Sample splitting, simultaneous (PoSI) intervals and conditional inference are valid alternatives.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Which assumption is not needed for the Gauss–Markov theorem?
- The errors have mean zero
- The errors are normally distributed
- The errors are uncorrelated
- The errors have a common variance
Show the answer
B. The errors are normally distributed
Gauss–Markov uses only the first two moments: and (uncorrelated, equal variances). Normality is needed for exact and distributions, and it upgrades "best linear unbiased" to "best unbiased".
As the sample size grows (with a well-behaved design), what happens to a 95% confidence interval for the mean response at and to a 95% prediction interval for a new ?
- Both shrink to zero width
- Both stay the same width
- The prediction interval shrinks to zero; the confidence interval does not
- The confidence interval shrinks to zero; the prediction interval approaches about
Show the answer
D. The confidence interval shrinks to zero; the prediction interval approaches about
as data accumulate, so the uncertainty about the mean vanishes. A new observation still carries its own noise, the "1 +" under the square root, which no amount of data removes.
Why is estimated by rather than ?
- Because : the residuals are confined to an -dimensional subspace
- Because dividing by would make the estimate too large
- Because it is required for the residuals to sum to zero
- It is a convention with no effect on bias
Show the answer
A. Because : the residuals are confined to an -dimensional subspace
has mean . Fitting coefficients absorbs dimensions of noise, so RSS/ underestimates , badly when is a sizable fraction of .
An analyst picks 5 of 50 candidate predictors by stepwise selection, refits by least squares, and reports the usual 95% intervals for the 5 coefficients. What is wrong?
- Nothing, provided the residuals look normal
- The intervals are too wide, because 45 predictors were dropped
- The intervals ignore the selection step and typically cover the targets less than 95% of the time
- Least squares is biased once any predictor is dropped
Show the answer
C. The intervals ignore the selection step and typically cover the targets less than 95% of the time
Variables are kept because their estimates looked large in this sample, so the usual intervals are centered on optimistically selected values and undercover. Split the sample, use simultaneous (PoSI) intervals, or condition on the selection event.
Further reading
- G. Casella & R. L. Berger, Statistical Inference, 2nd ed. (Duxbury, 2002), chapter 11.
- H. White, "A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity," Econometrica 48(4), 817–838 (1980).
- J. G. MacKinnon & H. White, "Some heteroskedasticity-consistent covariance matrix estimators with improved finite sample properties," Journal of Econometrics 29(3), 305–325 (1985).
- R. Berk, L. Brown, A. Buja, K. Zhang & L. Zhao, "Valid post-selection inference," Annals of Statistics 41(2), 802–837 (2013).
- H. Leeb & B. M. Pötscher, "Model selection and inference: facts and fiction," Econometric Theory 21(1), 21–59 (2005).