Choose your reading route
eduKateSG · Why Mathematics? · Driscoll–Kraay Standard Errors: Cross-Sectional and Serial Dependence
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–35
Study and verify
Practise, inspect failure cases and read further.
Full chapter index · Practice and checking · Mathematics Learning Hub
Why is mathematics important when panel data have serial correlation over time and broad shocks that affect many units together? Driscoll–Kraay covariance aggregates regression score information by time and then applies a HAC kernel across periods, allowing fairly general cross-sectional dependence while protecting against temporal autocorrelation under suitable large-time conditions.
Did You Know? More individuals do not automatically rescue a very short panel. Driscoll–Kraay reliability is tied strongly to the number of time periods because the long-run covariance is estimated across time.
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–35 · Study and verify
- A student investigation
- Common misconceptions
- Connection to recent mathematics articles
- Guidance for students and parents
- Practice questions
- Frequently asked questions
- A reporting checklist
- Period scores reveal effective information
- Bandwidth in calendar language
- Final Driscoll–Kraay audit
- Useful next reading
A panel follows many units over multiple periods. Residuals can be related within a unit over time and across units in the same period. Ordinary HC treats rows as independent; one-way entity clustering may miss economy-wide or system-wide temporal shocks.
Statsmodels documents `cov_nw_groupsum` as a Driscoll–Kraay panel-robust covariance. It requires a time index, equally spaced periods, at least one observation per period and a selected maximum lag. Read the documentation.
For each period, aggregate or average relevant score contributions across cross-sectional units. The resulting sequence has one multivariate score summary per time. HAC weighting is then applied to contemporaneous and lagged products of that sequence.
Let gamma_0 be the time-score covariance at lag zero and gamma_j the lag-j covariance. A Bartlett version estimates gamma_0 plus weighted gamma_j and transposes through maximum lag L. Bread matrices map this long-run meat into coefficient covariance.
| gamma0 | gamma1 | L | w1 |
|---|---|---|---|
| 5 | 1.2 | 1 | 0.5 |
Suppose aggregated time scores give gamma_0=5 and gamma_1=1.2. With L=1, the Bartlett weight is 1−1/(1+1)=0.5. Long-run meat is 5+2×0.5×1.2=6.2. With bread 0.2 on both sides, variance is 0.248 and SE=sqrt(0.248)=0.4980.
| Long-run meat | Bread | Variance | SE |
|---|---|---|---|
| 6.2 | 0.2 | 0.248 | 0.498 |
A common period shock makes many units move together. Aggregating the scores by period retains their collective movement. Treating every unit-period row as independent would count a shared shock many times as separate information.
Period score aggregates can persist. HAC lag products reflect this persistence. Positive lag covariance often widens uncertainty, while negative covariance can reduce it; the direction is a property of the score sequence, not a guaranteed inflation rule.
Consistency is associated with enough time periods under regularity conditions. A panel with thousands of units and six years provides only a short series of period aggregates. The official documentation explicitly warns about short panels with mainly cross-sectional variation.
Lag one must have a consistent meaning. If periods are months, consecutive labels should represent consecutive months. Missing entire periods, irregular gaps or mixed frequencies require careful preprocessing or a method that understands actual time distances.
Maximum lag is a bandwidth. It should reflect sampling frequency, plausible persistence and a pre-specified rule or sensitivity plan. Too short omits dependence; too long estimates many noisy lag covariances from a finite time series.
Bartlett weights decline linearly with lag and are the documented default in the cited implementation. Uniform weights treat included lags equally. Name the kernel, because “Driscoll–Kraay” alone does not reveal the window used.
Implementations may offer no correction, a HAC-style correction or a cluster-style correction. Record the option and reference degrees of freedom. Corrections cannot overcome a fundamentally tiny time dimension.
Applied after OLS, Driscoll–Kraay changes coefficient covariance, tests and intervals, not fitted coefficients. If trends, seasonality or lagged responses belong in the conditional mean, include them separately.
Two-way clustering allows arbitrary dependence within two discrete cluster dimensions and is often justified by entity and time shocks. Driscoll–Kraay instead estimates a time long-run covariance after cross-sectional aggregation. Their asymptotic arguments and finite-sample behaviour differ.
Newey–West HAC treats one time-ordered score sequence. Driscoll–Kraay constructs such a sequence from panel score sums or averages by time, thereby allowing broad contemporaneous cross-sectional dependence.
Outcomes for many districts can share national shocks and temporal persistence. Driscoll–Kraay may be useful with a long annual or quarterly panel, while a panel of only a few years should be presented with strong caution.
Many sensors measured each hour can share weather or network disturbances and temporal persistence. The method can protect coefficient inference, but sensor calibration, missingness and changing network composition remain modelling issues.
Plot period score aggregates, inspect autocorrelation and report intervals across a small set of justified lags. Also compare entity-cluster and time-cluster results. Instability is evidence about limited information, not an invitation to choose a preferred threshold.
State the period unit, number of periods, aggregation, kernel, maximum lag, correction and Driscoll–Kraay interval.
The method does not fix nonstationarity, structural breaks, omitted mean dynamics, few periods, endogenous regressors, measurement error or invalid causal comparisons. Cross-sectional dependence must be sufficiently regular for the asymptotic argument.
Students can connect panel layouts, grouped sums, autocovariance and kernels by reducing a panel to a period-score sequence and repeating a Newey–West calculation.
Group regression score rows by time and sum each coefficient column. Sort periods, calculate lagged cross-products of the period vectors, apply kernel weights, assemble the long-run meat and multiply by the bread. Record period counts and gaps.
Validate the integer time index and equal spacing, fit the mean model, request the documented panel covariance with explicit lag and correction, then unit-test the gamma0=5, gamma1=1.2 example. Save period-score diagnostics.
The method appears in economics, climate panels, epidemiology, finance, infrastructure and network analysis. Responsible work also needs time-series knowledge, subject expertise and honest communication about short panels.
Simulate 100 units over 60 periods with a common period shock and AR(1) persistence. Compare HC, entity-cluster, time-cluster and Driscoll–Kraay intervals. Repeat with only 8 periods and explain the warning signs.
Driscoll–Kraay is not a cure for every panel, does not turn many units into many time periods, does not change coefficients and does not make structural breaks harmless.
The Newey–West HAC guide explains kernel-weighted lag covariance. The two-way cluster guide explains crossed group shocks. The Generalized Least Squares guide gives a model-based alternative.
Students should label the panel axes and count time periods before counting rows. Parents can ask why the chosen lag has a real-time meaning and whether a short-panel warning was checked.
- Recalculate the scalar long-run meat and SE.
- Explain time aggregation.
- Compare the method with one-series HAC.
- Diagnose a six-period panel.
- Explain why a missing trend is not repaired.
### Does the method change OLS coefficients? No.
### What dimension must be reasonably long? Time.
### Can periods be irregular without adjustment? Not under the documented equal-spacing setup.
### Is a larger lag always safer? No.
Name the sampling unit, model, target parameter, dependence structure, estimator, correction and validation checks. Show the calculation or reproducible code, report uncertainty as an interval, and separate what the method estimates from what the study design can support.
The period aggregate is the unit entering the long-run covariance. Many cross-sectional rows improve estimation in some ways, but a shared period shock remains one broad movement rather than thousands of independent shocks.
Translate L into days, months, quarters or years. A four-lag window represents four hours in hourly data but four years in annual data; the substantive meaning changes completely.
Confirm time ordering, equal spacing, adequate T, stable mean dynamics, lag and kernel rationale, correction setting and comparison with alternative dependence structures. Report short-panel limitations explicitly.
Continue through the Mathematics Learning Hub. Reproduce the worked example by hand, then verify it with documented software before applying the method to a larger dataset.
Extended practice laboratory
Practice case 1: Draw the panel
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 1. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Validate time index
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 2. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Count periods
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 3. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Aggregate scores by time
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 4. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Calculate gamma zero
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 5. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Calculate gamma one
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 6. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Choose bandwidth
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 7. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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 kernel weights
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 8. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Assemble long-run meat
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 9. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Apply bread
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 10. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Take square root
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 11. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Compare Newey-West
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 12. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Compare entity cluster
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 13. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Compare time cluster
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 14. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Reduce periods
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 15. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Add common shock
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 16. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Add serial persistence
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 17. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Insert a time gap
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 18. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Add structural break
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 19. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Change kernel
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 20. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Change correction
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 21. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Reject raw-row claim
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 22. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Report sensitivity
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 23. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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: Name limitations
Setup: Start from the article’s Driscoll–Kraay covariance worked mechanism for case 24. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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 Driscoll–Kraay covariance worked mechanism for case 25. Task: Change the named quantity, recompute the dependent result and compare it with the original.
Check: Preserve the sampling, group or time unit, verify the defining identity and state one validation check 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.