Tutorials › Econometrics (Graduate) › Prewhitening for HAC Covariance Estimation

Clustered and Dependent Errors · Tutorial 139 of 952

Prewhitening for HAC Covariance Estimation

Learn how to prewhiten regression scores, estimate their HAC covariance, and recolor it to obtain a covariance estimate on the original scale.

Advanced 11 min read

What You'll Learn

  • Define regression scores and the autoregressive prewhitening filter used in HAC estimation
  • Derive the recoloring formula for the long-run covariance matrix
  • Calculate scalar and multivariate prewhitened HAC estimates
  • Convert the long-run covariance estimate into a regression coefficient covariance matrix
  • Assess stability, residual dependence, bandwidth, and finite-sample risks

Why Prewhiten a HAC Estimate?

HAC inference estimates uncertainty while allowing regression errors to be heteroskedastic and serially dependent. Its accuracy can depend on how well a finite bandwidth and kernel capture the serial dependence in the regression scores. If those scores are highly persistent, a finite-bandwidth estimate may capture their long-run covariance poorly. Prewhitening offers one adjustment: fit a short autoregressive filter to the scores, estimate a HAC covariance for the filtered sequence, and then recolor that covariance to put it back on the original scale.

Prewhitening is a covariance-estimation step, not a new regression model for the outcome. The regression coefficient estimate is unchanged; the procedure modifies the estimated covariance used for standard errors and inference. Its benefit depends on the filter and the remaining dependence being estimated well. Filtering does not automatically improve an estimate, and the recoloring step is essential.

Scores and the Prewhitening Filter

For a linear regression with \(T\) ordered observations and \(k\) regressors, let \(x_t\) be the \(k\)-vector of regressors for observation \(t\), and let \(\hat u_t\) be its fitted regression residual. The estimated score is the \(k\)-vector \(\hat g_t=x_t\hat u_t\). The long-run covariance of the scores is the object used in the HAC sandwich covariance estimator. It accounts for both contemporaneous score variation and covariation across time.

Definition: A VAR(1) prewhitening filter models the score sequence as \(g_t=A g_{t-1}+v_t\), where \(A\) is a \(k\times k\) coefficient matrix and \(v_t\) is the filtered innovation. In practice, \(A\) is estimated from the observed scores, giving residuals \(\hat v_t=\hat g_t-\hat A\hat g_{t-1}\) for \(t=2,\ldots,T\). Prewhitening estimates the HAC covariance of \(\hat v_t\); recoloring transforms that estimate back to the scale of the original scores.

The autoregressive filter is commonly fitted by least squares, regressing each component of \(\hat g_t\) on the lagged score vector \(\hat g_{t-1}\). This is a multivariate regression through the origin; an intercept is not part of the stated filter. Because one lag is needed, the filtered sequence has \(T-1\) observations. A HAC estimator with a chosen kernel and bandwidth is then applied to that sequence, using a consistent normalization for its length.

A standard stability condition is that all eigenvalues of \(A\) have absolute value less than one. It ensures that the autoregressive filter has a stable long-run multiplier \((I-A)^{-1}\). The corresponding estimated condition is checked using the eigenvalues of \(\hat A\). If an estimated eigenvalue is very close to one, recoloring can amplify estimation error substantially.

Worked Example: Scalar Prewhitening and Recoloring

Suppose a hypothetical scalar score sequence follows \(g_t=0.6g_{t-1}+v_t\), where the innovations are serially uncorrelated and have variance \(\operatorname{Var}(v_t)=4\). Assume the filter is stable, since \(|0.6|<1\). What is the long-run variance of the original scores?

For a stable scalar AR(1), the long-run multiplier is \(1/(1-\rho)\), where \(\rho\) is the autoregressive coefficient. Recoloring multiplies the innovation long-run variance by the square of this multiplier:

$$ \Omega_g=\frac{\Omega_v}{(1-\rho)^2} =\frac{4}{(1-0.6)^2} =\frac{4}{0.16} =25. $$

The original score sequence therefore has a long-run variance of 25 in squared score units. The filtered sequence has innovation variance 4 in squared score units. Reporting 4 as the HAC estimate for the original scores would omit the recoloring adjustment and would understate their long-run variance in this example.

Deriving the Recoloring Formula

Let \(\Omega_g\) denote the long-run covariance matrix of the stationary score process \(g_t\), and let \(\Omega_v\) denote the long-run covariance matrix of the filtered process \(v_t\). A long-run covariance is the sum of the lag covariances over all integer lags, when this sum exists. Under the stable VAR(1) relation, the score can be written as a linear filter of current and past innovations:

$$ g_t=v_t+A v_{t-1}+A^2v_{t-2}+\cdots. $$

At long-run frequency, the matrices multiplying the innovations sum to \(I+A+A^2+\cdots=(I-A)^{-1}\). Equivalently, summing the VAR equation over a long stretch of observations gives \((I-A)\) times the accumulated scores equal to the accumulated innovations, up to boundary terms. For a stable process, those boundary terms do not contribute to the covariance per observation in the long run. Thus the long-run score variation is the innovation long-run variation transformed by \((I-A)^{-1}\) on the left and its transpose on the right.

Result: For a stable VAR(1) score process with a well-defined long-run covariance, the long-run covariance matrices satisfy
$$ \Omega_g=(I-A)^{-1}\Omega_v(I-A')^{-1}. $$

The transpose on the right is important: covariance matrices transform as \(B\Omega B'\) when a vector is multiplied by a matrix \(B\). In an empirical procedure, replace \(A\) by \(\hat A\) and \(\Omega_v\) by a HAC estimate \(\hat\Omega_v\) computed from the filtered residual scores. The resulting estimate is the recolored HAC estimate \(\hat\Omega_g\). The filter need not eliminate every serial correlation; the HAC step still estimates the remaining long-run covariance of the filtered scores.

For example, using the usual lag-covariance convention, define \(\hat\Gamma_h\) for \(h\geq 0\) as the lag-\(h\) covariance estimate for the filtered scores, with \(\hat\Gamma_h\) formed from products \(\hat v_t\hat v_{t-h}'\). A kernel HAC estimate with bandwidth \(L\) has the form

$$ \hat\Omega_v =\hat\Gamma_0+ \sum_{h=1}^{L}w_h(\hat\Gamma_h+\hat\Gamma_h'), $$

where \(w_h\) is the selected kernel weight at lag \(h\). The kernel and bandwidth govern the residual HAC calculation; recoloring is a separate matrix transformation applied afterward. With these definitions, if \(\hat Q=X'X/T\), the estimated covariance matrix of the OLS coefficient vector is

$$ \widehat{\operatorname{Var}}(\hat\beta) =\frac{1}{T}\hat Q^{-1}\hat\Omega_g\hat Q^{-1}. $$

Here \(X\) is the regression design matrix, and the formula assumes \(\hat Q\) is nonsingular. It is equivalent to using the unnormalized HAC “meat” in the usual sandwich form; keeping track of the \(1/T\) normalization avoids accidentally multiplying or dividing the covariance by \(T\) twice.

Worked Example: Recoloring a Two-Score HAC Matrix

Suppose a hypothetical fitted VAR(1) for two score components has

$$ \hat A= \begin{pmatrix} 0.5&0\\ 0&0.2 \end{pmatrix}, \qquad \hat\Omega_v= \begin{pmatrix} 4&1\\ 1&9 \end{pmatrix}. $$

The eigenvalues of \(\hat A\) are 0.5 and 0.2, both inside the unit circle, so the estimated filter is stable. The recoloring matrix and its transpose are

$$ (I-\hat A)^{-1} = \begin{pmatrix} 2&0\\ 0&1.25 \end{pmatrix}. $$

Applying the formula, first multiply on the left and then on the right:

$$ \hat\Omega_g = \begin{pmatrix} 2&0\\ 0&1.25 \end{pmatrix} \begin{pmatrix} 4&1\\ 1&9 \end{pmatrix} \begin{pmatrix} 2&0\\ 0&1.25 \end{pmatrix} = \begin{pmatrix} 16&2.5\\ 2.5&14.0625 \end{pmatrix}. $$

For instance, the upper-right entry is \(2(1)(1.25)=2.5\), and the lower-right entry is \(1.25(9)(1.25)=14.0625\). The covariance between the two score components is recolored as well as their variances; adjusting only the diagonal entries would not implement the matrix formula.

From Long-Run Covariance to Coefficient Uncertainty

Recoloring estimates uncertainty in the original score sequence, not directly in each regression coefficient. To obtain coefficient uncertainty, place the recolored estimate into the regression sandwich. Both the score covariance and the design matrix matter: a high-variance direction in the scores can have a different effect on coefficients depending on the scale and collinearity structure of the regressors.

Worked Example: A Prewhitened HAC Standard Error

Suppose a hypothetical regression has \(T=100\) observations and two coefficients. Assume the estimated design second-moment matrix is \(\hat Q=\operatorname{diag}(2,1)\). A stable fitted score filter has \(\hat A=0.5I\), and the residual HAC estimate is \(\hat\Omega_v=2I\). These are stipulated estimates for this example; the filter is stable because both its eigenvalues equal 0.5. Calculate the recolored coefficient covariance matrix and the standard error for the second coefficient.

The recoloring matrix is \((I-\hat A)^{-1}=2I\). Therefore,

$$ \hat\Omega_g=(2I)(2I)(2I)=8I. $$

Since \(\hat Q^{-1}=\operatorname{diag}(0.5,1)\), the sandwich calculation is

$$ \widehat{\operatorname{Var}}(\hat\beta) =\frac{1}{100} \begin{pmatrix}0.5&0\\0&1\end{pmatrix} \begin{pmatrix}8&0\\0&8\end{pmatrix} \begin{pmatrix}0.5&0\\0&1\end{pmatrix} = \begin{pmatrix}0.02&0\\0&0.08\end{pmatrix}. $$

The standard error for the second coefficient is the square root of its estimated variance: \(\sqrt{0.08}=0.2828\), in the units of that coefficient. This uncertainty estimate reflects the residual HAC estimate after recoloring and accounts for the design matrix; it is not obtained by taking the square root of an entry in \(\hat\Omega_v\) alone.

When Prewhitening Helps—and When It Can Mislead

Prewhitening can help when score dependence is persistent and a short stable autoregression captures an important part of that persistence. The remaining score dependence may then be easier for a finite-bandwidth HAC estimator to represent. Recoloring preserves the long-run scale targeted by the original score sequence rather than treating the filtered residuals as though they were the original scores.

The correction is not guaranteed to improve finite-sample inference. The estimated autoregressive coefficients are uncertain, and that uncertainty can matter when \(T\) is small or the fitted filter is close to unstable. In that case, \((I-\hat A)^{-1}\) can have large entries, magnifying small estimation errors in both \(\hat A\) and \(\hat\Omega_v\). A misspecified filter may also leave substantial residual dependence. The residual HAC step is important for this reason; prewhitening is not a license to assume that filtered scores are independent.

The underlying long-run covariance target still requires appropriate regularity conditions, such as a stable dependence process with finite second moments and a well-defined long-run covariance. Standard consistency of the HAC step also relies on appropriate time-series conditions and bandwidth behavior. In applications, inspect the fitted filter's stability and the filtered scores' remaining dependence, and consider whether the result is sensitive to reasonable filtering and bandwidth choices. These checks inform judgment but do not establish that a model or covariance estimate is correct.

Common pitfall: “The filtered residual HAC estimate is \(\hat\Omega_v\), so it is already the covariance estimate for the original regression scores.” This is wrong because filtering changes the scale and dependence structure. The original-score estimate is \((I-\hat A)^{-1}\hat\Omega_v(I-\hat A')^{-1}\), which must then enter the regression sandwich. Conversely, recoloring does not remove the need to estimate residual dependence with a suitable HAC procedure.

Prewhitening is also distinct from transforming the regression observations to estimate coefficients under a specified error covariance model. Here the fitted coefficients remain the OLS coefficients; only the estimated covariance matrix used for inference is adjusted. The practical question is therefore not whether the filter makes the regression “whiter,” but whether the complete filter–HAC–recolor procedure provides a credible estimate of the scores’ long-run covariance.

Check Your Understanding

Use the definitions and results above to answer the following questions.

  1. In a prewhitened HAC procedure, what sequence is filtered, and why is the filtered sequence still given a HAC covariance estimate?
  2. For a stable scalar AR(1) score process with coefficient \(\rho=0.4\) and innovation long-run variance 3, calculate the recolored long-run variance.
  3. Why must the right-hand recoloring factor be \((I-\hat A')^{-1}\), rather than simply repeating a left multiplication by \((I-\hat A)^{-1}\) without transposing?
  4. What can happen to the recolored estimate when an eigenvalue of \(\hat A\) is close to one?
  5. Does prewhitening change the OLS coefficient estimate? Explain what part of the analysis it changes.
Clinical Biostats