Choose your reading route
eduKateSG · Why Mathematics? · Newey–West HAC: Heteroscedasticity and Autocorrelation Consistent Standard Errors
Start with the question, audit the worked example, or jump to the assumptions and practice. Every chapter stays open for uninterrupted reading.
Understand the question
Define the quantity and follow the mechanism.Route 2 · Chapters 6–11
Reproduce the example
Audit the numbers one step at a time.Route 3 · Chapters 12–18
Check assumptions
See where design and calibration matter.Route 4 · Chapters 19–24
Explore applications
Connect the method to a concrete investigation.Route 5 · Chapters 25–36
Study and verify
Practise, inspect failure cases and read further.
Full chapter index · Practice and checking · Mathematics Learning Hub
Why is mathematics important when regression residuals are both unequal in variance and correlated across nearby time points? Newey–West heteroscedasticity and autocorrelation consistent covariance, usually called HAC, estimates a long-run score variance by combining lagged autocovariances with declining weights. It preserves the OLS coefficients while changing their estimated uncertainty.
Did You Know? With a Bartlett kernel and maximum lag L, lag j receives weight 1−j/(L+1). Nearby covariance receives more weight, while covariance beyond the selected lag is omitted from the estimator.
Full chapter index
Chapters 1–5 · Understand the question
Chapters 6–11 · Reproduce the example
Chapters 12–18 · Check assumptions
Chapters 19–24 · Explore applications
Chapters 25–36 · Study and verify
A positive residual today may be followed by a positive residual tomorrow because shocks persist. Conventional and row-level HC formulas omit these cross-time products. HAC adds weighted lagged score covariances so coefficient uncertainty reflects short-range serial dependence as well as heteroscedasticity.
Statsmodels documents HAC covariance with a required maximum lag and a default Bartlett weighting function. Read the HAC documentation. The robust covariance API explains `maxlags`, kernel choice and available small-sample corrections. Read the API.
For a scalar score sequence s_t, the long-run variance is gamma_0 plus two times the sum of autocovariances gamma_j across positive lags. In a regression, scores are vectors x_t e_t, so each gamma_j is a matrix. HAC estimates a weighted, truncated version of that sum.
With maximum lag L, the Bartlett weight at lag j is w_j=1−j/(L+1) for j=1,…,L. The weight decreases linearly to zero just beyond L. Symmetric positive and negative lags are represented by adding a lag matrix and its transpose.
| Quantity | Value |
|---|---|
| gamma0 | 4 |
| gamma1 | 1.5 |
| gamma2 | 0.5 |
| L | 2 |
Suppose a scalar score has estimated gamma_0=4, gamma_1=1.5 and gamma_2=0.5, with L=2. The weights are 2/3 and 1/3. Long-run variance is 4+2[(2/3)(1.5)+(1/3)(0.5)]=6.3333. If each bread factor is 0.1, coefficient variance is 0.06333 and the standard error is sqrt(0.06333)=0.2517.
| w1 | w2 | Long-run variance | Coefficient SE |
|---|---|---|---|
| 2/3 | 1/3 | 6.3333 | 0.2517 |
HC covariance uses contemporaneous squared scores, analogous to gamma_0. Serial dependence adds off-time products. When positive autocorrelation is present, omitting them often understates uncertainty, but negative autocorrelation can have the opposite effect.
HAC requires observations in the correct time order and usually equally spaced or meaningfully indexed intervals. Sorting by outcome, mixing entities or ignoring gaps produces lag pairs that do not represent temporal neighbours.
A larger L includes more possible dependence but estimates more noisy autocovariances. A smaller L can omit relevant persistence. Choice can draw on sampling frequency, subject knowledge, pre-specified rules and sensitivity analysis; it should not be selected merely to cross a p-value threshold.
The Bartlett kernel is common and yields a positive-semidefinite construction under standard implementation. Other kernels trade bias and variance differently. Report the kernel rather than writing only “Newey–West”.
HAC allows the score variance to change over time while also representing serial correlation. It is therefore broader than a homoscedastic autocorrelation correction. The H in HAC matters.
Applying HAC covariance after OLS does not alter the fitted coefficients, residual sequence or predictions. Standard errors, tests and intervals change. If the dynamics belong in the conditional mean, add lags or other structure rather than asking covariance correction to absorb predictable patterns.
A residual autocorrelation plot can signal omitted seasonality, trend, delayed effects or autoregressive errors. HAC protects uncertainty under suitable dependence but does not tell which mechanism generated it. Forecasting often benefits from modelling the mechanism directly.
HAC consistency relies on regularity and dependence conditions such as a stable long-run covariance and sufficiently decaying correlations. A structural break, unit root or long memory can violate the simple approximation. Diagnose the series before treating HAC as universal.
Lag one means adjacent rows in the algorithm, not automatically one day or one month. For irregular observations, calendar-aware models or alternative covariance methods may be needed. State the actual time unit behind every lag.
Stacking multiple people or firms and running ordinary HAC across the boundary between entities creates false neighbours. Panel dependence may require cluster, panel HAC or two-way methods with a clearly specified entity and time structure.
Moving averages, rolling returns and overlapping forecast horizons mechanically induce serial correlation. HAC can be appropriate, but the maximum lag should reflect how overlap creates dependence rather than being chosen without a design argument.
A regression of returns on a factor may use time-ordered residuals with changing volatility and short-run dependence. HAC can adjust coefficient uncertainty, while risk modelling, nonstationarity and multiple testing remain separate tasks.
Daily pollution residuals may be serially correlated because weather systems persist. HAC can acknowledge local dependence, but seasonality, meteorology and policy changes belong in the mean or design when they affect the target question.
Report the main coefficient and HAC interval across a small set of pre-justified lag lengths. Add residual autocorrelation plots and the sample frequency. If conclusions change sharply, present that instability rather than declaring one lag correct after the fact.
State the time ordering, kernel, maximum lag, finite-sample correction and that HAC covariance was applied to unchanged OLS coefficients.
Newey–West HAC does not fix nonstationarity, structural breaks, omitted dynamics, endogenous regressors, cross-sectional clusters, few time periods, measurement error or an invalid causal design.
Students can calculate Bartlett weights and a three-lag long-run variance by hand, then connect time-series plots, autocovariance and matrix sandwich ideas.
Place scores in time order. Compute lag-zero products, then lag-j cross-products for each j up to L, average consistently, multiply by Bartlett weights and add transpose terms. Record the time unit, L and any denominator convention.
Sort and validate the time index before fitting. Request HAC covariance with explicit `maxlags` and kernel, then test the documented example against the hand calculation. Save code, software version and sensitivity results for neighbouring lag choices.
HAC inference appears in economics, finance, climate analysis, epidemiology, operations and policy evaluation. Strong practice also requires knowledge of time-series design, data provenance, structural change and clear communication of what a covariance correction can support.
Simulate a regression with AR(1) errors at several persistence levels and with changing variance. Compare conventional, HC and HAC interval coverage. Repeat after omitting a time trend to see why covariance repair cannot replace a missing mean component.
Newey–West does not make a nonstationary series stationary, choose a lag automatically for every problem, change coefficients or guarantee larger standard errors. It is not the same as clustering an arbitrary entity panel.
The White sandwich guide explains lag-zero robust covariance. The Generalized Least Squares guide explains model-based correlation weighting. The residual standard error guide explains why one scalar noise summary cannot represent every pattern.
Students should draw the time order, label the lag unit and calculate Bartlett weights. Parents can ask what happens if the lag choice changes and whether the residual pattern suggests a missing dynamic. That keeps the analysis tied to mechanism and validation.
- Recompute the long-run variance.
- Explain the factor of two.
- Compare L=0 with HC covariance.
- Identify a false panel boundary.
- Name one sign of nonstationarity.
### Does HAC change the OLS slope? No.
### Does it allow unequal variance? Yes.
### Is a larger maximum lag always safer? No; it can add noisy autocovariance estimates.
### Can it repair a missing trend? No.
Name the sampling unit, regression formula, target coefficient, dependence structure, covariance estimator and finite-sample choices. Show the conventional and robust uncertainty side by side when that comparison is useful. State what changed, what did not change and which assumptions remain open.
For a scalar stationary sequence, positive and negative lag autocovariances match, so the positive-lag contribution is doubled. In the matrix case, add each lag matrix and its transpose rather than blindly multiplying a nonsymmetric matrix by two.
Maximum lag is also called a bandwidth in common implementations. It controls which temporal distances enter the covariance estimate. Translate it into real time: L=4 means four quarters for quarterly data but only four days for daily data.
Confirm correct ordering and spacing, a stable mean specification, a defensible kernel and lag, enough time observations, and sensitivity to nearby lags. Inspect breaks and residual dependence, then state which uncertainty claims remain conditional on weak-dependence assumptions.
Continue through the Mathematics Learning Hub. Reproduce the arithmetic by hand, then compare it with documented software output and explain any difference before relying on the result.
Extended practice laboratory
Practice case 1: Sort the time index
Setup: Start from the article’s Newey–West HAC worked mechanism for case 1. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Name the time unit
Setup: Start from the article’s Newey–West HAC worked mechanism for case 2. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Build score sequence
Setup: Start from the article’s Newey–West HAC worked mechanism for case 3. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Calculate lag zero
Setup: Start from the article’s Newey–West HAC worked mechanism for case 4. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Calculate lag one
Setup: Start from the article’s Newey–West HAC worked mechanism for case 5. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Calculate lag two
Setup: Start from the article’s Newey–West HAC worked mechanism for case 6. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Choose maximum lag
Setup: Start from the article’s Newey–West HAC worked mechanism for case 7. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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 Bartlett weights
Setup: Start from the article’s Newey–West HAC worked mechanism for case 8. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Combine autocovariances
Setup: Start from the article’s Newey–West HAC worked mechanism for case 9. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Apply the bread
Setup: Start from the article’s Newey–West HAC worked mechanism for case 10. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Take the square root
Setup: Start from the article’s Newey–West HAC worked mechanism for case 11. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Compare HC at lag zero
Setup: Start from the article’s Newey–West HAC worked mechanism for case 12. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Increase persistence
Setup: Start from the article’s Newey–West HAC worked mechanism for case 13. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Add negative correlation
Setup: Start from the article’s Newey–West HAC worked mechanism for case 14. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Change bandwidth
Setup: Start from the article’s Newey–West HAC worked mechanism for case 15. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Change kernel
Setup: Start from the article’s Newey–West HAC worked mechanism for case 16. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Insert a time gap
Setup: Start from the article’s Newey–West HAC worked mechanism for case 17. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Create a panel boundary
Setup: Start from the article’s Newey–West HAC worked mechanism for case 18. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Add a missing trend
Setup: Start from the article’s Newey–West HAC worked mechanism for case 19. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Inspect structural break
Setup: Start from the article’s Newey–West HAC worked mechanism for case 20. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Check small-sample option
Setup: Start from the article’s Newey–West HAC worked mechanism for case 21. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Reject an automatic-lag claim
Setup: Start from the article’s Newey–West HAC worked mechanism for case 22. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Report lag sensitivity
Setup: Start from the article’s Newey–West HAC worked mechanism for case 23. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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: Name remaining assumptions
Setup: Start from the article’s Newey–West HAC worked mechanism for case 24. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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 the conclusion
Setup: Start from the article’s Newey–West HAC worked mechanism for case 25. Task: Change the named quantity, recompute the affected covariance terms and compare with the original.
Check: Check the defining identity, keep the observation or time unit explicit, and state one diagnostic before interpreting the interval. 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.