# vcovHC, vcovHAC, NeweyWest – which function to use?

I am trying to update my lm() based model to get correct standard errors and tests. I am really confused which VC matrix to use. The sandwich package offers vcovHC , vcovHAC and NeweyWest. While the former only accounts for heteroskedasticity the latter two account for both serial correlation and heteroskedasticity. Yet, the documentation does not tell much about the difference between the latter two (at least I don't get it). Looking to the function itself I realized that NeweyWest actually calls vcovHAC.

Empirically the results of coeftest(mymodel, vcov. = vcovHAC) and coeftest(mymodel, vcov. = NeweyWest)are mad different. While vcovHACis somewhat close to the naive lm results, using NeweyWest all coefficients turn insignificant (tests even close to 1).

• Usually the R help pages give link to the articles. The precise details usually reside there. Zeileis article for example is freely available and contains wealth of information. – mpiktas Sep 16 '11 at 7:15
• Zeileis article specifically states how vcovHAC is different from NeweyWest. To summarise, different HAC methods differ only on choice of weights. NeweyWest has its specified weights, vcovHAC is a general function, which lets you supply your own weights, and by default uses Andrews weights. – mpiktas Sep 16 '11 at 7:23
• @mpiktas: thx for the summary. Since I haven't specified any weights, the respective default weights should be used. Now that I know, I should maybe restate my question to: Why do different default weights of vcovHAC and NeweyWest make such a huge difference and how to determine weights? I mean do you know which weights STATA or other packages use? – hans0l0 Sep 16 '11 at 9:30
• all these calculations depends on the fact that $x_tu_t$ are stationary variables, where $x_t$ are the regressors and $u_t$ are the disturbances. Stationarity is a bit restrictive property, so check whether it holds. – mpiktas Sep 16 '11 at 11:22

The "sandwich" in question is two pieces of bread defined by the expected information enclosing a meat defined by the observed information. See my comments here and here. For a linear regression, the estimating equation is:

$$U(\beta) = \mathbf{X}^T\left(Y - \mathbf{X}^T\beta\right)$$

$$A = \frac{\partial U(\beta)}{\partial \beta} = -(\mathbf{X}^T\mathbf{X})$$

The observed information (meat) is:

$$B = E(U(\beta)U(\beta)^T) = \mathbf{X}^T(Y-\mathbf{X}^T\beta)(Y-\mathbf{X}^T\beta)^T\mathbf{X}$$

Note the inner term is a diagonal of constant residuals when the homoscedasticity, independent data assumption is met, then the sandwich covariance estimator which is given by $A^{-1}BA^{-1}$ is the usual linear regression covariance matrix $\sigma^2 \left(\mathbf{X}^T\mathbf{X}\right)^{-1}$ where $\sigma^2$ is the variance of the residuals. However, that's rather strict. You get a considerably broader class of estimators by relaxing the assumptions involved around the $n \times n$ residual matrix: $$R = (Y-\mathbf{X}^T\beta)(Y-\mathbf{X}^T\beta)$$.

The "HC0" vcovHC estimator is consistent even when the data are not independent. So I will not say that we "assume" the residuals are independent, but I will say that we use "a working independent covariance structure". Then the matrix $R$ is replaced by a diagonal of the residuals

$$R_{ii} = (Y_i - \beta \mathbf{X}_{I.})^2, \quad 0\text{ elsewhere}$$

This estimator works really well except under small samples (<40 is often purported). The HC1-3 are various finite sample corrections. HC3 is generally the best performing.

However if there are autoregressive effects, the off-diagonal entries of $T$ are non-zero, so a scaled covariance matrix is produced based on commonly used autoregressive structures. This is the rationale for the "vcovHAC". Here, very flexible and general methods are produced to estimate the autoregressive effect: the details may be beyond the scope of your question. The "meatHAC" function is the general workhorse: the default method is Andrews'. Newey-West is a special case of the general autoregressive error estimator. These methods solve one of two problems: 1. at what rate does correlation decay between "adjacent" observations and 2. what is a reasonable distance between two observations? These If you have balanced panel data, this covariance estimator is overkill. You should use gee from the gee package instead specifying the covariance structure to AR-1 or similar.

As for which to use, it depends on the nature of the data analysis and the scientific question. I would not advise fitting all the types and picking the one that looks best, as it is a multiple testing issue. As I alluded to earlier, the vcovHC estimator is consistent even in the presence of an autoregressive effect, so you can use and justify a "working independence correlation model" in a variety of circumstances.

• Just feel a need to respond to AdamO's comment, in the last paragraph of his post -- the vcovHC estimator is absolutely not consistent in the presence of an autoregressive effect! Maybe he meant to say "vcovHAC estimator is consistent even in the presence of an autoregressive effect"? – user24465 Feb 17 at 22:33
• @user24465 Do you have a reference for the claim that vcovHC isn't consistent in the presence of serially correlated errors? (thanks) – Thomas Winckelman Apr 9 at 18:31
• Furthermore, if we use method="arellano" and "cluster=group" in vcovHV (both of which appear to be the default settings) then, according to Arellano himself, "no restrictions are placed on the form of the autocovariances for a given individual ... thus allowing for heteroskedasticity and serial correlation of arbitrary form" (on the first page of the paper "Computing Robust Standard Errors for Within-Groups Estimators") – Thomas Winckelman Apr 9 at 18:38