VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

Why Mathematics? | Generalized Least Squares: Correlated Errors and Covariance Weighting

Why is mathematics important when regression errors have unequal variances or move together? Generalized least squares replaces ordinary Euclidean distance with covariance-weighted distance, giving more influence to precise directions and accounting for correlation when the covariance model is credible.

Did You Know? Whitening transforms correlated, unequal-variance errors into a scale where ordinary least squares geometry applies.

Full chapter index

Chapters 1–4 · Understand the question
  1. The covariance question
  2. The documented method
  3. The GLS formula
  4. A worked example
Chapters 5–9 · Reproduce the example
  1. OLS comparison
  2. Whitening
  3. Weighted least squares
  4. Correlated errors
  5. Known versus estimated Sigma
Chapters 10–15 · Check assumptions
  1. Misspecified covariance
  2. Mean model still matters
  3. Units and scaling
  4. Positive definiteness
  5. Residual diagnostics
  6. Robust alternatives
Chapters 16–20 · Explore applications
  1. A covariance audit
  2. A decision example
  3. One-sentence conclusion
  4. Limits
  5. Transfer to learning
Chapters 21–35 · Study and verify
  1. A spreadsheet workflow
  2. A coding workflow
  3. Applications and careers
  4. A student investigation
  5. Common misconceptions
  6. Connection to recent mathematics articles
  7. Guidance for students and parents
  8. Practice questions
  9. Frequently asked questions
  10. A reporting checklist
  11. Deriving inverse-variance weights
  12. Correlation changes effective information
  13. Feasible GLS and uncertainty
  14. Final covariance audit
  15. Useful next reading

CHAPTER 1 OF 35 · Understand the question

1. The covariance question

Back to contents

Ordinary least squares treats the error covariance as sigma²I. GLS allows a general positive-definite covariance matrix Sigma.

Contents · Next chapter

CHAPTER 2 OF 35 · Understand the question

2. The documented method

Back to contents

Statsmodels documents GLS for a general error covariance matrix, while NIST describes weighted least squares for differing response variances. Read statsmodels and NIST.

Contents · Previous chapter · Next chapter

CHAPTER 3 OF 35 · Understand the question

3. The GLS formula

Back to contents

beta-hat_GLS=(X^T Sigma^−1 X)^−1 X^T Sigma^−1 y when the matrices are well-defined.

yVariance
101
144
Sensor inputs.

Contents · Previous chapter · Next chapter

CHAPTER 4 OF 35 · Understand the question

4. A worked example

Back to contents

Two measurements 10 and 14 have independent variances 1 and 4. Inverse-variance weights normalise to 0.8 and 0.2, giving estimate 10.8 and variance 0.8.

MethodEstimateVariance
GLS10.80.8
OLS121.25
Estimator comparison.

Contents · Previous chapter · Next chapter

CHAPTER 5 OF 35 · Reproduce the example

5. OLS comparison

Back to contents

The equal-weight mean is 12 with variance (1+4)/4=1.25, so correct precision weighting lowers variance.

Contents · Previous chapter · Next chapter

CHAPTER 6 OF 35 · Reproduce the example

6. Whitening

Back to contents

A factor L with L^T L=Sigma^−1 transforms y and X. OLS on Ly and LX equals GLS on the original scale.

Contents · Previous chapter · Next chapter

CHAPTER 7 OF 35 · Reproduce the example

7. Weighted least squares

Back to contents

Diagonal Sigma gives WLS. Each observation is weighted roughly by inverse error variance when those variances are known or well estimated.

Contents · Previous chapter · Next chapter

CHAPTER 8 OF 35 · Reproduce the example

8. Correlated errors

Back to contents

Off-diagonal covariance represents dependence across time, space, clusters or repeated measurements.

Contents · Previous chapter · Next chapter

CHAPTER 9 OF 35 · Reproduce the example

9. Known versus estimated Sigma

Back to contents

In practice Sigma is often estimated, producing feasible GLS. Uncertainty in that estimate matters, especially in small samples.

Contents · Previous chapter · Next chapter

CHAPTER 10 OF 35 · Check assumptions

10. Misspecified covariance

Back to contents

Wrong weights can reduce efficiency or distort uncertainty. A complicated covariance model is not automatically better.

Contents · Previous chapter · Next chapter

CHAPTER 11 OF 35 · Check assumptions

11. Mean model still matters

Back to contents

GLS corrects covariance geometry, not omitted predictors, nonlinear mean structure or causal design.

Contents · Previous chapter · Next chapter

CHAPTER 12 OF 35 · Check assumptions

12. Units and scaling

Back to contents

Weights must correspond to variance units. Arbitrary importance scores are not automatically statistical precision weights.

Contents · Previous chapter · Next chapter

CHAPTER 13 OF 35 · Check assumptions

13. Positive definiteness

Back to contents

Sigma must support a valid covariance geometry. Singular or nearly singular matrices require careful modelling and numerical methods.

Contents · Previous chapter · Next chapter

CHAPTER 14 OF 35 · Check assumptions

14. Residual diagnostics

Back to contents

Inspect whitened residuals as well as original residuals. Remaining dependence or changing spread signals an inadequate covariance model.

Contents · Previous chapter · Next chapter

CHAPTER 15 OF 35 · Check assumptions

15. Robust alternatives

Back to contents

Cluster-robust or heteroscedasticity-consistent standard errors can protect inference without claiming a fully known covariance, but they do not make OLS efficient.

Contents · Previous chapter · Next chapter

CHAPTER 16 OF 35 · Explore applications

16. A covariance audit

Back to contents

Name the source of heteroscedasticity or dependence, how parameters were estimated and which sensitivity models were compared.

Contents · Previous chapter · Next chapter

CHAPTER 17 OF 35 · Explore applications

17. A decision example

Back to contents

Repeated sensor readings may share drift. A covariance model prevents correlated repeats from being counted as independent information.

Contents · Previous chapter · Next chapter

CHAPTER 18 OF 35 · Explore applications

18. One-sentence conclusion

Back to contents

State the covariance model, transformed estimation and whether conclusions are sensitive to plausible alternatives.

Contents · Previous chapter · Next chapter

CHAPTER 19 OF 35 · Explore applications

19. Limits

Back to contents

GLS does not guarantee correct weights, causal identification, robustness to outliers or good prediction under distribution shift.

Contents · Previous chapter · Next chapter

CHAPTER 20 OF 35 · Explore applications

20. Transfer to learning

Back to contents

Students can begin with inverse-variance means, then generalise from diagonal weights to full covariance matrices.

Contents · Previous chapter · Next chapter

CHAPTER 21 OF 35 · Study and verify

21. A spreadsheet workflow

Back to contents

Build Sigma and its inverse, form the weighted cross-products, solve for coefficients and verify with a whitening transformation. Keep every matrix dimension, unit and intermediate quantity visible, then verify the defining identity.

Contents · Previous chapter · Next chapter

CHAPTER 22 OF 35 · Study and verify

22. A coding workflow

Back to contents

Use tested linear-algebra routines, save the design and model formula, check rank and conditioning, and test against a hand-worked example.

Contents · Previous chapter · Next chapter

CHAPTER 23 OF 35 · Study and verify

23. Applications and careers

Back to contents

GLS supports time series, geospatial analysis, longitudinal studies, engineering calibration and sensor fusion.

Contents · Previous chapter · Next chapter

CHAPTER 24 OF 35 · Study and verify

24. A student investigation

Back to contents

Combine two sensors with unequal variances, then add correlated repeated readings.

Contents · Previous chapter · Next chapter

CHAPTER 25 OF 35 · Study and verify

25. Common misconceptions

Back to contents

GLS is not simply “trust important rows more”; weights encode a covariance model that must be justified.

Contents · Previous chapter · Next chapter

CHAPTER 26 OF 35 · Study and verify

26. Connection to recent mathematics articles

Back to contents

The Gauss–Markov guide explains efficiency. The residual standard error guide explains noise scale.

Contents · Previous chapter · Next chapter

CHAPTER 27 OF 35 · Study and verify

27. Guidance for students and parents

Back to contents

Students should distinguish diagonal weights from full covariance. Parents can ask where the weights came from.

Contents · Previous chapter · Next chapter

CHAPTER 28 OF 35 · Study and verify

28. Practice questions

Back to contents

  • Recalculate the weighted mean.
  • Compare OLS variance.
  • Explain whitening.

Contents · Previous chapter · Next chapter

CHAPTER 29 OF 35 · Study and verify

29. Frequently asked questions

Back to contents

### Is WLS the same as GLS? WLS is the diagonal case.

### Must Sigma be known? Often it is estimated.

### Does GLS fix omitted variables? No.

Contents · Previous chapter · Next chapter

CHAPTER 30 OF 35 · Study and verify

30. A reporting checklist

Back to contents

Report the target, model, data unit, assumptions, calculation, diagnostics, validation and practical threshold. Separate descriptive evidence from causal interpretation.

Contents · Previous chapter · Next chapter

CHAPTER 31 OF 35 · Study and verify

31. Deriving inverse-variance weights

Back to contents

For independent measurements of one mean, minimise the variance sum(a_i² sigma_i²) subject to weights summing to one. A Lagrange multiplier gives a_i proportional to 1/sigma_i². With variances 1 and 4, raw precisions are 1 and 0.25, which normalise to 0.8 and 0.2. The estimate 10.8 therefore trusts the precise sensor more, for a statistical reason rather than a subjective importance score.

Contents · Previous chapter · Next chapter

CHAPTER 32 OF 35 · Study and verify

32. Correlation changes effective information

Back to contents

Repeated observations that share drift do not contribute as much independent information as their count suggests. Positive covariance makes certain averages less precise; negative covariance can make particular contrasts more precise. GLS uses the full inverse covariance to weight directions, not just rows. Display Sigma or its structured parameters so readers can see what dependence was assumed.

Contents · Previous chapter · Next chapter

CHAPTER 33 OF 35 · Study and verify

33. Feasible GLS and uncertainty

Back to contents

When Sigma is estimated, feasible GLS treats estimated covariance parameters as inputs. Large samples can make this practical, but small-sample uncertainty and model misspecification remain. Compare plausible covariance structures, inspect whitened residuals and report sensitivity. If the coefficient is stable but standard errors move, say so; if both move, explain the weighting mechanism.

Contents · Previous chapter · Next chapter

CHAPTER 34 OF 35 · Study and verify

34. Final covariance audit

Back to contents

Verify that Sigma is symmetric, has appropriate units and is positive definite or otherwise handled by a justified model. Explain how its parameters were estimated and whether the same data informed both mean and covariance. Compare GLS with OLS plus robust uncertainty, inspect original and whitened residuals, and stress plausible alternatives. The smallest standard error is not automatically the most credible result; it must come from a defensible covariance description. Preserve the alternative covariance fits, numerical diagnostics and decision consequences so another analyst can reproduce why the chosen weighting model was preferred. This makes the final choice transparent, testable and easier to revise.

Contents · Previous chapter · Next chapter

CHAPTER 35 OF 35 · Study and verify

35. Useful next reading

Back to contents

Continue through the Mathematics Learning Hub and reproduce the worked example before using software.

Contents · Previous chapter · Mathematics Learning Hub

Extended practice laboratory

Practice case 1: Write Sigma

Setup: Start from the article’s GLS worked example for case 1. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 2: Check dimensions

Setup: Start from the article’s GLS worked example for case 2. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 3: Invert Sigma

Setup: Start from the article’s GLS worked example for case 3. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 4: Build cross-products

Setup: Start from the article’s GLS worked example for case 4. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 5: Solve GLS

Setup: Start from the article’s GLS worked example for case 5. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 6: Work two sensors

Setup: Start from the article’s GLS worked example for case 6. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 7: Normalise weights

Setup: Start from the article’s GLS worked example for case 7. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 8: Calculate estimate

Setup: Start from the article’s GLS worked example for case 8. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 9: Calculate variance

Setup: Start from the article’s GLS worked example for case 9. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 10: Compare OLS

Setup: Start from the article’s GLS worked example for case 10. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 11: Build whitening factor

Setup: Start from the article’s GLS worked example for case 11. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 12: Transform y

Setup: Start from the article’s GLS worked example for case 12. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 13: Transform X

Setup: Start from the article’s GLS worked example for case 13. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 14: Fit whitened OLS

Setup: Start from the article’s GLS worked example for case 14. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 15: Add correlation

Setup: Start from the article’s GLS worked example for case 15. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 16: Use diagonal WLS

Setup: Start from the article’s GLS worked example for case 16. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 17: Estimate Sigma

Setup: Start from the article’s GLS worked example for case 17. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 18: Inspect whitened residuals

Setup: Start from the article’s GLS worked example for case 18. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 19: Compare robust SE

Setup: Start from the article’s GLS worked example for case 19. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 20: Check positive definite

Setup: Start from the article’s GLS worked example for case 20. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 21: Stress weights

Setup: Start from the article’s GLS worked example for case 21. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 22: Check influence

Setup: Start from the article’s GLS worked example for case 22. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 23: Reject importance weights

Setup: Start from the article’s GLS worked example for case 23. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 24: Reject causal claim

Setup: Start from the article’s GLS worked example for case 24. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.

Practice case 25: Write conclusion

Setup: Start from the article’s GLS worked example for case 25. Task: Change the named quantity, recompute dependent values and compare with the original.

Check: Check the defining identity, preserve units and state one diagnostic or validation step before interpretation. Show the arithmetic, name the response and predictor units, and separate the numerical result from the claim it supports. Then vary one defensible assumption, calculate again and explain whether the conclusion changed because of the data, the fitted model or the validation purpose. Finish with one compact table or graph that could reveal a failure hidden by the summary.