Why Panel HAC Covariance Is Needed
In panel regression, observations from the same unit may remain statistically related over time. A firm’s unobserved productivity, for example, may persist from one year to the next. If that serial dependence is ignored, a covariance estimator that treats every unit-time observation as independent can misstate coefficient uncertainty. Panel HAC covariance estimation allows this within-unit serial dependence while relying on a different restriction: score processes from distinct units are independent.
The estimator builds a time-series HAC covariance estimate for each unit’s score contributions, then adds those unit-level estimates. It does not add cross-products between different units. That distinction is central: this procedure addresses serial dependence within units, not dependence shared across units.
From Unit Scores to the Sandwich
For ordinary least squares, write \(X\) for the stacked design matrix and \(Q=X'X=\sum_i\sum_t x_{it}x_{it}'\). Assume \(X\) has full column rank, so \(Q\) is positive definite and \(Q^{-1}\) exists. The OLS estimator satisfies
This expression shows why the natural unit of aggregation is the unit-level score sum \(S_i\). Conditional on the regressors, suppose the score processes are independent across units and have mean zero. Then the covariance of their total is the sum of their covariances: cross-unit covariance terms are zero. Consequently,
Within a unit, however, scores from different periods need not be independent. Expanding the variance of \(S_i\) includes the contemporaneous score products and all cross-period products. Grouping those cross-period terms by their calendar-time lag gives a lag-zero term and, for each positive lag \(h\), a term and its transpose. The sample estimator replaces the unknown score products by fitted score products and weights higher lags.
The two appearances of \(Q^{-1}\) are the “bread,” while \(\hat\Omega_{\mathrm{HAC}}\) is the “meat.” The formula requires full column rank; positive semidefiniteness of \(Q\) alone would not ensure that its inverse exists. If the design is rank deficient, one needs a separate parameterization or generalized-inverse treatment and the corresponding assumptions.
Kernel Weights and Bandwidth
A kernel assigns a weight to each included lag. A standard choice is the Bartlett kernel, with weights
Thus, at bandwidth \(L=1\), the lag-one products receive weight \(1/2\). At \(L=2\), lag one receives weight \(2/3\), and lag two receives weight \(1/3\). The lag-zero products always receive weight one. Bartlett weights taper toward zero at the cutoff and yield a positive-semidefinite HAC meat under the standard construction. Other kernels are possible, but their weights and regularity properties must be appropriate for HAC estimation.
The bandwidth \(L\) is the largest calendar-time lag included. A small bandwidth omits more long-lag dependence; a larger bandwidth includes more estimated cross-products, which can increase sampling variability. Under long time-series asymptotics, standard HAC consistency conditions typically require the bandwidth to grow while remaining small relative to the time dimension, such as \(L\to\infty\) and \(L/T\to0\), together with suitable weak-dependence and moment conditions. These are asymptotic guidance, not a guarantee that one bandwidth is best in every finite sample. Sensitivity to reasonable bandwidth choices should be examined.
Worked Example: Calculating a Bartlett Panel HAC Meat
Consider a hypothetical scalar regression with \(Q=20\) and three periods for each of two units. The fitted score contributions are \(1,2,-1\) for unit A and \(0,1,-3\) for unit B. Each unit’s sequence sums to \(2\) and \(-2\), respectively, so the total fitted score is zero, as required by the OLS normal equations. The calculation below uses Bartlett bandwidth \(L=1\), whose lag-one weight is \(1-1/2=0.5\).
At lag zero, add the squared scores:
The within-unit lag-one products are \(1(2)+2(-1)=0\) for A and \(0(1)+1(-3)=-3\) for B. Including the two symmetric terms and the Bartlett weight gives
The estimated coefficient variance and standard error are therefore
In this hypothetical example, the estimated standard error is \(0.1803\) coefficient units. This calculation illustrates the estimator’s arithmetic; it does not by itself establish that the independence and dependence assumptions hold for any application.
Worked Example: Comparing Bandwidths
For a second hypothetical scalar score calculation, let \(Q=10\), with scores \(1,2,-3\) for unit A and \(-1,0,1\) for unit B. Both unit sequences sum to zero, so the aggregate fitted score satisfies the OLS first-order condition. Compare Bartlett bandwidths \(L=0,1,2\).
For \(L=0\), only the squared scores enter:
For \(L=1\), the sum of the within-unit lag-one products is \((1\cdot2+2\cdot(-3))+((-1)\cdot0+0\cdot1)=-4\). Its weight is \(1/2\), so
For \(L=2\), the total lag-one product remains \(-4\), and the total lag-two product is \(1(-3)+(-1)(1)=-4\). The weights are \(2/3\) and \(1/3\), respectively:
Here the estimated standard error decreases as the bandwidth grows because the included lagged score products are negative. There is no general rule that a larger bandwidth must increase the estimated standard error; the direction depends on the observed score products and weights.
Worked Example: Calendar-Time Lags in an Unbalanced Panel
Suppose a hypothetical unit is observed in periods 1, 2, and 4, with score contributions \(2,-1,-1\), respectively. The scores sum to zero. With bandwidth \(L=1\), the lag-zero contribution is
Only periods 1 and 2 form an observed pair at calendar lag one; their product is \(2(-1)=-2\). Periods 2 and 4 are two periods apart, not one, so they do not enter the lag-one sum. With Bartlett weight \(1/2\), and a stipulated scalar \(Q=6\), the meat and standard error are
Treating the three observed records as consecutive positions would incorrectly assign the period-2 and period-4 scores to lag one. HAC lags refer to elapsed calendar time, not merely to adjacency in a stored data table.
Assumptions and Interpretation
Panel HAC inference relies on a structure that should be stated explicitly. The linear estimating equation must be correctly specified for the target coefficient, and the regressors must satisfy conditions that make the score mean zero (for example, suitable exogeneity). The design must have full column rank for the displayed inverse-based sandwich. Across units, score processes must be independent, or sufficiently weakly dependent for an alternative theory to apply; this estimator’s defining assumption is that cross-unit score covariance is absent. Within units, serial dependence is permitted but must be sufficiently controlled for the chosen HAC approximation to be informative.
For consistency, additional regularity conditions are needed, including suitable moments, stable design behavior, and an asymptotic regime in which the relevant score covariance can be estimated. With a growing time dimension, bandwidth conditions such as those described above are commonly used. Standard errors from this estimator support large-sample inference, such as asymptotic Wald tests and confidence intervals, rather than exact finite-sample claims. If a model uses transformed or otherwise non-OLS estimating equations, the score and bread must be those of that estimator; the OLS formula should not be applied mechanically.
Common Mistakes
- Assuming cross-sectional dependence is handled. The meat sums unit-specific terms and omits cross-unit score products. Shared shocks that correlate scores across units violate the intended dependence structure.
- Calling bandwidth a number of observations rather than a time separation. In an unbalanced panel, a missing period does not make the next observed record a lag-one observation.
- Assuming the standard error must rise with bandwidth. Lagged products can be negative, as in the second worked example, and can reduce the meat.
- Using an inverse without checking rank. The sandwich requires \(Q^{-1}\); full column rank of \(X\) is what makes that inverse well-defined.
- Interpreting the calculation as proof of the assumptions. A HAC formula accommodates a specified score-dependence pattern; it does not establish that the pattern is appropriate for the data.
Check Your Understanding
Try these questions before reviewing the worked examples.
- Why does cross-sectional independence lead the panel HAC meat to sum unit-level terms without adding cross-products between distinct units?
- With Bartlett bandwidth \(L=3\), what are the weights on lags one and three?
- For one unit observed in periods 2 and 5, which lag does the pair contribute to?
- Why does a negative sum of lagged score products make it possible for a larger bandwidth to reduce the estimated standard error?
- What condition on \(X\) ensures that the displayed \(Q^{-1}\) sandwich is defined?