Why Method Choice Depends on the Dependence Pattern
A panel regression can have a well-defined coefficient estimate and still have misleading uncertainty estimates. The key question is how the regression errors, or equivalently the score contributions used to estimate the coefficients, depend across units and time. Treating dependent observations as independent can make standard errors too small and tests reject too often. But choosing a robust covariance estimator is not a generic repair: each estimator allows some forms of dependence and relies on others being absent or sufficiently limited.
This tutorial gives a selection framework for five approaches: unit clustering, two-way clustering, panel heteroskedasticity-and-autocorrelation-consistent (HAC) covariance estimation, Driscoll–Kraay (DK) inference, and common-factor methods. The choice depends on the dependence pattern, the panel dimensions, and the asymptotic regime supporting inference. Diagnostics can inform that choice, but they do not establish every condition required for validity.
Match the Estimator to the Dependence
Unit clustering permits arbitrary heteroskedasticity and dependence over time within a unit. It treats different units’ score sums as independent, or requires their dependence to be negligible under the asymptotic approximation. The unit-level score is \(\hat{g}_i=\sum_{t=1}^T\hat{\psi}_{it}\), so the cluster meat is the sum of the outer products \(\hat{g}_i\hat{g}_i'\). This is a natural choice when units are the independent sampling clusters and the main concern is serial dependence within each unit. Its conventional justification relies on having many independent (or suitably weakly dependent) units; a large number of observations within only a few units does not substitute for many clusters.
Two-way clustering by unit and time permits dependence between observations sharing a unit and dependence between observations sharing a period. It uses inclusion–exclusion: add the unit-cluster meat and the time-cluster meat, then subtract the cell-level meat because each observation belongs to both a unit and a time cluster. Its justification requires adequate numbers of clusters in both dimensions, as well as negligible dependence between observations that share neither a unit nor a time period. Two-way clustering is not a general solution to spatial spillovers between different units across different periods.
Panel HAC estimates serial dependence within units by adding lagged score products within each unit. Like unit clustering, its usual form assumes that dependence across different units is absent or negligible. It is useful when within-unit serial dependence is the target, particularly when the time dimension is long enough to estimate the relevant lag covariance. A bandwidth determines how many lags contribute and how strongly they are weighted; it cannot make a short time series informative about long-run dependence.
Driscoll–Kraay inference applies HAC estimation to scores aggregated across units in each time period. This allows cross-sectional dependence as well as serial dependence, subject to the conditions supporting the long-run covariance estimate. Its central asymptotic support comes from a sufficiently long time dimension, with appropriate time dependence and bandwidth conditions. It is therefore not an automatic choice merely because a test detects cross-sectional dependence: when \(T\) is short, its long-run covariance estimate may be unreliable.
Common-factor methods address dependence attributed to shared latent shocks, rather than relying only on a covariance correction. A factor representation such as \(u_{it}=\lambda_i'f_t+e_{it}\) separates common factors \(f_t\), with unit-specific loadings \(\lambda_i\), from the remaining error \(e_{it}\). Depending on the model and estimator, common factors may be estimated, or common correlated effects may be used to account for them. The resulting inference must account for how these factors or controls were estimated. This approach is appropriate when pervasive common shocks are substantively plausible and the factor structure is a reasonable model—not simply whenever errors are correlated.
| Method | Dependence it is designed to accommodate | Key requirement to assess |
|---|---|---|
| Unit clustering | Arbitrary dependence within a unit | Many independent or suitably weakly dependent units |
| Two-way clustering | Dependence within units and within periods | Enough clusters in both dimensions; limited dependence outside shared clusters |
| Panel HAC | Serial dependence within units | Cross-unit dependence is negligible; time dimension supports lag estimation |
| Driscoll–Kraay | Cross-sectional and serial dependence in aggregated scores | A sufficiently informative time dimension and valid long-run covariance conditions |
| Common-factor methods | Pervasive dependence from shared latent shocks | A credible factor specification and valid inference after factor adjustment or estimation |
What the Covariance Formulas Reveal
The formulas make the assumptions visible. For unit clustering, sum scores over time first, then take outer products across units. For two-way clustering, form score sums over each unit and each period, and subtract the cell products. For panel HAC, add lagged products within each unit. In all these expressions, finite-sample multipliers are omitted; implementations may apply corrections that affect reported standard errors.
For panel HAC, let \(L\) be the chosen maximum lag and \(w_\ell\) its weight at lag \(\ell\). A common form includes the contemporaneous products and both orientations of each lagged product:
DK instead constructs period-level aggregate scores \(\hat{s}_t=\sum_i\hat{\psi}_{it}\) and applies a HAC calculation over \(t\) to those aggregates. The different order of operations matters: cross-products of aggregate scores include products from different units in the same or nearby periods, which unit-level HAC omits. A factor approach changes the error representation or the estimating procedure; it is not just another label for either of these covariance formulas.
Worked Example: Unit-Clustering Meat
Suppose a hypothetical regression has 40 units. To keep the arithmetic concise, suppose the estimated scalar score sums \(\hat{g}_i=\sum_t\hat{\psi}_{it}\) take the values \(1,-1,0.5,-0.5\), each for 10 units. Assume the bread is \(\hat{Q}=100\). The data are being used only to illustrate the covariance calculation; assume, for method selection, that different units are independent and within-unit dependence is the concern.
The unit-cluster meat is the sum of squared unit score sums: \(10(1^2+(-1)^2+0.5^2+(-0.5)^2)=10(1+1+0.25+0.25)=25\). The scalar sandwich variance is therefore \(\hat{V}=\hat{Q}^{-1}\hat{\Omega}_{\mathrm{unit}}\hat{Q}^{-1}=25/100^2=0.002500\), and the corresponding standard error is \(\sqrt{0.002500}=0.05000\) in the coefficient’s units.
This calculation uses variation across unit-level score sums, not variation across all 40\(T\) observations treated as independent. Unit clustering is a plausible choice here only if the assumption about cross-unit dependence and the many-unit approximation are defensible.
Worked Example: Two-Way Inclusion–Exclusion
For a small hypothetical score array, suppose there are three units and three periods, with scalar scores as follows. Suppose the bread is \(\hat{Q}=10\), and omit finite-sample corrections.
| Unit | Period 1 | Period 2 | Period 3 |
|---|---|---|---|
| 1 | 1 | 0 | 1 |
| 2 | 0 | 1 | -1 |
| 3 | 1 | -1 | 0 |
The unit sums are \(2,0,0\), so the unit-cluster contribution is \(2^2+0^2+0^2=4\). The period sums are \(2,0,0\), giving a time-cluster contribution of \(4\). The cell contribution is the sum of squared entries: \(1+0+1+0+1+1+1+1+0=6\). Thus the two-way meat is \(4+4-6=2\), the sandwich variance is \(2/10^2=0.02000\), and the standard error is \(\sqrt{0.02000}=0.1414\).
The subtraction prevents counting each cell’s contribution twice. The small array is not enough to justify large-cluster inference; this is an arithmetic illustration, not evidence that two-way clustering is reliable with only three units and three periods.
Worked Example: Panel HAC Versus Driscoll–Kraay
Consider a hypothetical scalar regression with \(\hat{Q}=10\), a bandwidth of one lag, and Bartlett weight \(w_1=0.5\). Suppose the aggregate period scores for six periods are \((1,2,-1,1,0,-1)\). The contemporaneous contribution is \(1^2+2^2+(-1)^2+1^2+0^2+(-1)^2=8\). The five adjacent cross-products sum to \(1(2)+2(-1)+(-1)(1)+1(0)+0(-1)=-1\). Hence the HAC meat is \(8+2(0.5)(-1)=7\), the sandwich variance is \(7/10^2=0.07000\), and the standard error is \(\sqrt{0.07000}=0.2646\).
If these are scores summed across units in each period, this calculation illustrates the DK construction. If instead they are scores for one unit and the calculation is repeated within each unit before summing, it illustrates panel HAC. The arithmetic is similar, but the dependence each method retains differs. Six periods are too few to rely on the usual long-time-series justification for DK; a small illustrative standard error calculation does not resolve that limitation.
A Practical Selection Sequence
A defensible choice begins with the estimator and its intended asymptotics, not with whichever method produces the largest standard error. The following sequence makes the decision explicit.
Ask whether errors plausibly persist within units, share period-specific shocks, exhibit broader cross-unit dependence, or reflect pervasive latent factors. Use the panel’s design and subject matter as well as residual diagnostics.
Count units and periods separately. Unit clustering needs a credible many-unit approximation. Two-way clustering needs enough clusters in both dimensions. HAC methods need enough periods to estimate serial covariance; DK in particular relies on time-series asymptotics.
If dependence is plausibly generated by pervasive common shocks, consider whether a factor or common-correlated-effects specification is needed. A robust covariance estimate alone does not remove bias from an omitted common component correlated with regressors.
Report which dependence the method allows, what residual dependence it rules out or restricts, which dimension is treated as large, and how uncertainty from any estimated factors or controls is handled.
Dependence tests are useful evidence, not a complete selection algorithm. A failure to reject cross-sectional independence does not prove independence, especially when the test has limited power. Conversely, a rejection identifies a problem for methods that require independence, but it does not by itself distinguish common factors from spatial, network, or other sources of dependence. Factor diagnostics and substantive understanding can help characterize the pattern, but results remain conditional on model assumptions.
Common Mistakes and the Main Takeaway
- “Clustered standard errors allow any dependence.” Unit clustering allows dependence within a unit, not arbitrary dependence between units. Use a method whose assumptions cover the suspected cross-unit pattern.
- “Two-way clustering handles every form of cross-sectional dependence.” It handles shared-unit and shared-period dependence under its conditions. Dependence between different units in different periods may remain unaccounted for.
- “A cross-sectional-dependence test rejects, so DK is automatically valid.” DK also needs a suitable time dimension and long-run covariance conditions. With short \(T\), the relevant asymptotic approximation may be poor.
- “A factor-robust standard error fixes an omitted common factor.” If the common component affects coefficient estimation, correcting only the covariance may not address the estimator’s problem. The specification or estimator may need to account for the factor itself.
- “Choose the largest standard error and the inference is safe.” A larger number does not validate an estimator whose dependence assumptions or asymptotics are inappropriate.
Check Your Understanding
For each question, identify the dependence or asymptotic issue that should guide the choice.
- A panel has many units but only a few periods. What limitation should be considered before using Driscoll–Kraay inference?
- What forms of dependence does two-way clustering by unit and period target, and what kind of dependence may it still miss?
- In what respect does panel HAC differ from unit clustering, and what additional panel dimension does it need to estimate lag dependence?
- Why might a covariance correction alone be inadequate when a pervasive common shock is correlated with regressors?
- Why does rejecting a test of cross-sectional independence not, by itself, establish that a particular alternative method is valid?