Optimal Lag for Newey West

I am currently working on my PhD thesis and was wondering how I can identify the optimal number of lags for the Newey West covariance matrix. So far, my code is

library(sandwich)
library(lmtest)
library(dynlm)

Regression <- dynlm(y ~ x)
coeftest(Regression, vcov = NeweyWest(Regression, lag = NULL))

Since I have to compare coefficients of multiple regressions (for the same time series), I should use the same lag as well. However is there a rule of thumb or a simple method to get the lag?

Thank you and best regards

• When you specify null to lag, the function automatically estimates the number of lags to use – Repmat Jan 11 '17 at 17:45
• Thank you very much Repmat. But shouldn't I use just one fixed lag for all regressions? – user144267 Jan 12 '17 at 21:40
• Well that depends on the residuals, which are likely different across model's – Repmat Jan 13 '17 at 8:32
• Exactly, but when I compare regression models, they should use the same lag, right? – user144267 Jan 14 '17 at 8:15

I don't think that you necessarily need to fix the lag length across regressions. Due to the different model specifications there may be slightly different amounts of autocorrelation in the residuals that you have to adjust for.

However, you can easily display the lag length employed by NeweyWest() and also extract it using bwNeweyWest(). For simple replication, let's consider the following (non-sensical because non-time-series) linear model:

m <- lm(dist ~ speed, data = cars)
NeweyWest(m, lag = NULL, verbose = TRUE)
## Lag truncation parameter chosen: 3
##             (Intercept)      speed
## (Intercept)   49.250542 -3.7390757
## speed         -3.739076  0.3035406

The bandwidth estimation is done by bwNeweyWest():

bwNeweyWest(m)
##  3.032204

The lag length is just floor() of that.