Generalized least squares
Whiten a known error covariance and understand what changes when weights must be estimated from the same data.
On this page
The question for today
What you’ll understand
- Derive GLS as ordinary least squares after whitening.
- Use inverse-variance weights for observations with unequal precision.
- Distinguish known-covariance GLS from feasible GLS and robust uncertainty.
Euclidean distance treats every observation direction as equally noisy and uncorrelated with the others. That is inappropriate when sensors have different precision or repeated measurements share disturbances. Generalized least squares changes the geometry according to a specified error covariance. It discounts noisy directions and accounts for correlations, while preserving the linear mean model. The efficiency guarantee is conditional on knowing the right covariance shape; replacing that shape with an estimate introduces another statistical problem rather than preserving every finite-sample claim automatically.
Whitening changes the noise geometry
Assume a fixed full-column-rank design, mean-zero errors, and covariance , where Ω is known, symmetric, positive definite, and does not depend on the response. A whitening matrix W satisfies . Multiplying both the response and the design by W produces a transformed mean model with spherical covariance. Ordinary least squares on that transformed model therefore has the Gauss–Markov property in the transformed coordinates. Positive definiteness makes whitening invertible and preserves design rank.
The transformed squared residual length equals a weighted quadratic form in the original residual. Taking its derivative gives the GLS normal equations and coefficient formula. A Cholesky factorization can implement whitening without explicitly computing a matrix inverse. The transformation does not require Gaussian errors for unbiasedness or BLUE efficiency. If the errors are additionally multivariate Gaussian and Ω is genuinely known, the usual exact Gaussian inference can be applied after whitening with the appropriate residual degrees of freedom.
Weights describe precision, not importance alone
If errors are uncorrelated and have unequal known variances, inverse covariance is diagonal. Weighted least squares then gives an observation weight proportional to inverse variance, not inverse standard deviation. Averaging independent estimates of one common mean with those weights gives more influence to more precise measurements. Multiplying all weights by the same positive constant leaves the coefficient estimate unchanged, although variance formulas must keep track of the corresponding scale convention.
Correlated noise cannot generally be handled by merely attaching a separate weight to each observation. Off-diagonal covariance says which combinations share information. Two highly positively correlated measurements can contribute much less new information than two independent ones with the same marginal variance. Conversely, negative correlation can improve the precision of an average. The covariance model should arise from the sampling design, physical measurement process, or a supported statistical structure, rather than weights chosen solely to produce a preferred fitted coefficient.
Estimated covariance changes the guarantee
In practice Ω is often unknown. Feasible GLS estimates a covariance structure, then substitutes it into the GLS calculation. The resulting weights depend on data, so the estimator is no longer necessarily a fixed linear function of Y. Its finite-sample unbiasedness and known-covariance BLUE proof do not transfer verbatim. Consistency and asymptotic inference require assumptions about the covariance estimator, mean model, sampling regime, and dependence; an arbitrary iterative reweighting rule is not automatically valid.
Another strategy retains ordinary least-squares coefficients and adjusts their estimated covariance using a heteroskedasticity- or dependence-robust method. That addresses uncertainty under specified large-sample conditions without claiming GLS efficiency. Neither strategy repairs a mean model with omitted structure or a nonzero conditional error mean. Keep the tasks distinct: choosing the mean, modeling covariance, calculating coefficients, and justifying uncertainty. A sophisticated weighting matrix cannot compensate for a scientific interpretation that the observed design does not support.
Work it through
Combine two measurements with unequal precision
Two uncorrelated measurements share mean μ, have observed values 2 and 5, and known variances 1 and 4. Compare inverse-variance GLS with their unweighted mean.
Inverse-variance weights are and . Normalizing gives weights and , so .
Its variance is . The inverse-total-precision expression gives the same result, .
The arithmetic mean is with variance . Both are unbiased for μ, but the unweighted estimator has variance larger by .
The weighted estimate favors the more precise observation and reduces variance under the specified covariance. The numerical value 2.6 is not guaranteed to be closer to the unknown μ on this particular occasion.
The living notebook
Explore the model
Interactive lab · matrix
See why a covariance transformation affects angles
Pause and Reset; set a=0.5 and b=0, then predict horizontal compression without shear. For a separate comparison Reset and set a=0.5 and b=1. The singular values and transformed grid now reflect directional mixing. This invertible triangular family illustrates transformations of geometry; it does not infer an error covariance, compute GLS coefficients, or certify that a chosen matrix whitens a dataset.
- Area scale · det A
- 1.4
- Singular values · σmax, σmin
- 1.597, 0.876
- Condition number · κ₂(A)
- 1.823
The selected matrix is A = [[a,b],[0,1]]. Playback interpolates geometry between the identity and A; readouts always describe A. Its determinant is a and its singular values come from AᵀA. Positive a makes every supported matrix invertible. This two-dimensional family is not a general eigensolver or a learned network. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forWhitening transforms both the response and design according to a justified covariance model.
Pause & reason
Check your understanding
Your turn
Try it yourself
Two observations share mean μ and have known covariance matrix . Find the GLS weights and variance of their common-mean estimate. Compare with the variance obtained by incorrectly assuming independence.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
The covariance is symmetric under exchanging the observations, and its inverse has equal row sums.
Compare with the solution
The inverse covariance is . Its equal row sums yield weights . The variance of the average is . Treating the observations as independent would report , understating uncertainty despite producing the same coefficient estimate.
Keep the idea
Take it with you
- Known positive-definite covariance permits an invertible whitening transformation.
- Inverse-variance weights differ from inverse-standard-deviation weights.
- Estimated covariance and robust standard errors need their own inferential justification.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.