Skip to content

HAC prewhitening

HAC prewhitening filters dependence from regression scores, estimates the filtered long-run covariance and recolours it before calculating coefficient uncertainty.

HAC prewhitening is a covariance-estimation procedure that filters serial dependence from a model’s estimating functions, estimates the filtered process’s long-run covariance, and then transforms that covariance back to the original scale. In a persistent factor regression, it can change the uncertainty attached to alpha without changing the estimated alpha itself.
The final transformation is called recolouring. Omitting it can produce a precise-looking answer for the wrong process.

Filter the score that drives the estimate

For an ordinary least squares regression yt=xt′β+εty_t=\mathbf{x}_t'\boldsymbol\beta+\varepsilon_t, the relevant empirical score is
g^t=xtε^t.\hat{\mathbf g}_t=\mathbf{x}_t\hat\varepsilon_t.
It contains one component per coefficient, including the intercept when present. The autocorrelation of these regressor–residual products determines the time-dependent part of coefficient uncertainty. Filtering an arbitrary return series, or filtering regression residuals alone when regressors vary, is not generally the same operation. The software documentation’s estimating-function example makes this product explicit.

An intercept-only mean is the special case xt=1x_t=1. Its score is just the demeaned observation, which makes the mechanism easy to see.

A population example: removing memory does not remove uncertainty

Suppose the true mean-zero score, in arbitrary score units, follows a stationary AR(1) process:
gt=0.5gt−1+et,E[et]=0,Var(et)=1,g_t=0.5g_{t-1}+e_t, \qquad \mathbb{E}[e_t]=0, \qquad \text{Var}(e_t)=1,

with independent, identically distributed innovations. This is an oracle example: the filter coefficient and innovation variance are known population quantities.

The score’s one-period variance and lag-kk autocovariance are

γ0=11−0.52=43,γk=43(0.5)k.\gamma_0=\frac{1}{1-0.5^2}=\frac43, \qquad \gamma_k=\frac43(0.5)^k.
Its long-run variance, the covariance sum governing the large-sample variance of its average, is larger:
Sg=γ0+2∑k=1∞γk=43(1+20.51−0.5)=4.S_g=\gamma_0+2\sum_{k=1}^{\infty}\gamma_k =\frac43\left(1+2\frac{0.5}{1-0.5}\right)=4.

Prewhitening subtracts the predictable component: et=gt−0.5gt−1e_t=g_t-0.5g_{t-1}. Since these innovations are independent, Se=1S_e=1. But we still want uncertainty for the original mean. Recolouring reverses the filter’s effect at frequency zero:

Sg=Se(1−0.5)2=4.S_g=\frac{S_e}{(1-0.5)^2}=4.

For n=100n=100, the asymptotic approximation to the original sample mean’s variance is Sg/n=0.04S_g/n=0.04, corresponding to a standard error of 0.20.2. Using Se/n=0.01S_e/n=0.01 would instead report 0.10.1. That calculation has forgotten recolouring. Neither number is a fitted HAC estimate from an observed sample; 0.040.04 is also an asymptotic approximation, not the exact finite-sample variance.

Population AR(1) score with coefficient 0.5: autocorrelation halves at each lag while filtered innovations have zero positive-lag autocorrelation. Filtering takes long-run variance from 4 to 1; recolouring restores 4. For n=100, asymptotic mean variance is 0.04, versus the incorrect unrecoloured 0.01.
Population AR(1) score with coefficient 0.5: autocorrelation halves at each lag while filtered innovations have zero positive-lag autocorrelation. Filtering takes long-run variance from 4 to 1; recolouring restores 4. For n=100, asymptotic mean variance is 0.04, versus the incorrect unrecoloured 0.01.
Population oracle illustration. Filtering removes dependence; recolouring restores the original score’s long-run scale. The n=100 calculations are asymptotic mean variances, not estimated sample standard errors.

The fitted procedure and its normalisation

In a regression, the scores and filter must be estimated. A common implementation fits a low-order vector autoregression to the column-vector scores:

e^t=g^t−∑j=1pB^jg^t−j,A^(1)=I−∑j=1pB^j.\hat{\mathbf e}_t =\hat{\mathbf g}_t-\sum_{j=1}^{p}\hat B_j\hat{\mathbf g}_{t-j}, \qquad \hat A(1)=I-\sum_{j=1}^{p}\hat B_j.

Apply a kernel HAC estimator to the filtered residuals to obtain S^e\hat S_e, then recolour:

S^g=A^(1)−1S^eA^(1)−′.\hat S_g=\hat A(1)^{-1}\hat S_e\hat A(1)^{-\prime}.
The right factor is the transpose of the left inverse. Reversing that matrix order generally changes the answer. This is the filter-and-recolour construction in den Haan and Levin, §2.3.4.

Here S^e\hat S_e and S^g\hat S_g estimate long-run covariance matrices of per-observation processes, rather than covariances of their sample averages. With

Q^=1n∑t=1nxtxt′,\hat Q=\frac1n\sum_{t=1}^{n}\mathbf{x}_t\mathbf{x}_t',

the OLS sandwich covariance estimate is

Var^(β^)=1nQ^−1S^gQ^−1.\widehat{\text{Var}}(\hat{\boldsymbol\beta}) =\frac1n\hat Q^{-1}\hat S_g\hat Q^{-1}.

The 1/n1/n is essential under this convention. Software may organise sums, usable observations after filtering, and finite-sample adjustments differently; reconcile those conventions before comparing outputs.

What prewhitening leaves to decide

The purpose is to make the residual dependence easier for a kernel estimator to capture. It does not guarantee truly white residuals. The original Andrews–Monahan research finds improvements in particular inference criteria alongside costs in estimator variance; it does not establish universal finite-sample improvement.
  • Kernel and bandwidth remain choices. A filter can leave higher-order or seasonal dependence. Bandwidth selection still matters for the filtered series, and its rule must be compatible with prewhitening. Filter order and kernel bandwidth are different parameters.
  • Recolouring can amplify filter error. In the scalar case, (1−ϕ^)−2(1-\hat\phi)^{-2} becomes extremely sensitive as ϕ^\hat\phi approaches one. In a VAR, inspect filter stability and whether A^(1)\hat A(1) is nearly singular. A unit root lies outside this stationary illustration; prewhitening does not make nonstationarity disappear.
  • A fitted filter adds sampling uncertainty. Small samples and an unsuitable lag order can make the resulting covariance unstable. The oracle calculation above excludes that estimation error. Compare defensible specifications and report the filter, kernel, bandwidth and adjustments used.

Prewhitening changes covariance estimation. It does not repair an endogenous regressor, an omitted conditional-mean dynamic or a biased alpha estimate. Newey–West standard errors describe a related HAC construction; enabling prewhitening adds a filtering and recolouring step, rather than defining a new coefficient estimator.

For the regression foundation, Serial Correlation: Durbin–Watson, Breusch–Godfrey, and Newey–West derives the AR(1) pattern and the HAC sandwich and contrasts them with GLS. The preview is public; the full lesson requires membership.

Sources

Last updated
  • hac
  • prewhitening
  • long run covariance
  • regression inference
← Back to the glossaryBack to top ↑