core27 min studyLesson 257 in Mathematics

Generalized least squares

Whiten a known error covariance and understand what changes when weights must be estimated from the same data.

On this page

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 σ2Ω\sigma^2\Omega, where Ω is known, symmetric, positive definite, and does not depend on the response. A whitening matrix W satisfies WΩWT=IW\Omega W^{\mathsf T}=I. 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.

β^GLS=(XTΩ−1X)−1XTΩ−1Y,Cov⁡(β^GLS)=σ2(XTΩ−1X)−1\widehat\beta_{\mathrm{GLS}}=(X^{\mathsf T}\Omega^{-1}X)^{-1}X^{\mathsf T}\Omega^{-1}Y,\qquad \operatorname{Cov}(\widehat\beta_{\mathrm{GLS}})=\sigma^2(X^{\mathsf T}\Omega^{-1}X)^{-1}
These identities assume full column rank, the correct mean, and a known positive-definite covariance shape Ω. The estimator minimizes (Y−Xb)ᵀΩ⁻¹(Y−Xb).↔ Scroll wide equations horizontally.

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.

μ^=∑iYi/vi∑i1/vi,Var⁡(μ^)=1∑i1/vi\widehat\mu=\frac{\sum_i Y_i/v_i}{\sum_i1/v_i},\qquad \operatorname{Var}(\widehat\mu)=\frac1{\sum_i1/v_i}
This common-mean formula assumes uncorrelated observations with positive known variances vᵢ. Correlations require the full covariance matrix rather than these scalar inverse-variance weights.↔ Scroll wide equations horizontally.

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.

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.

  1. Inverse-variance weights are 11 and 1/41/4. Normalizing gives weights 4/54/5 and 1/51/5, so μ^=(4/5)2+(1/5)5=13/5=2.6\widehat\mu=(4/5)2+(1/5)5=13/5=2.6.

  2. Its variance is (4/5)2⋅1+(1/5)2⋅4=20/25=4/5(4/5)^2\cdot1+(1/5)^2\cdot4=20/25=4/5. The inverse-total-precision expression gives the same result, 1/(1+1/4)=4/51/(1+1/4)=4/5.

  3. The arithmetic mean is 3.53.5 with variance (1+4)/4=5/4(1+4)/4=5/4. Both are unbiased for μ, but the unweighted estimator has variance larger by 5/4−4/5=9/205/4-4/5=9/20.

The result

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.

Explore the model

Interactive lab

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.

See why a covariance transformation affects anglesThe 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. Current readings: Area scale · det A: 1.4; Singular values · σmax, σmin: 1.597, 0.876; Condition number · κ₂(A): 1.823. All parameters are adjustable with the labeled controls below.Matrix A with first row 1.4, 0.6 and second row zero, one; display interpolates between identity and A while final determinant remains 1.4.−4−2024−2−1012x · equal geometric scaleyA = [ 1.4 0.6 ; 0 1 ]Display blend: 0% · final values below
Interpolated geometryOriginal unit squareSelected final transform
Area scale · det A
1.4
Singular values · σmax, σmin
1.597, 0.876
Condition number · κ₂(A)
1.823
t = 0 s

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.

Check your understanding

For uncorrelated observations with known error standard deviations 1 and 3, what relative WLS weights correspond to inverse variance?

Try it yourself

Two observations share mean μ and have known covariance matrix (11/21/21)\begin{pmatrix}1&1/2\\1/2&1\end{pmatrix}. 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 43(1−1/2−1/21)\frac43\begin{pmatrix}1&-1/2\\-1/2&1\end{pmatrix}. Its equal row sums yield weights 1/2,1/21/2,1/2. The variance of the average is (1+1+2⋅1/2)/4=3/4(1+1+2\cdot1/2)/4=3/4. Treating the observations as independent would report 1/21/2, understating uncertainty despite producing the same coefficient estimate.

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.