[R] error in vcovNW

Achim Zeileis Achim.Zeileis at uibk.ac.at
Sat Dec 19 03:06:44 CET 2015


On Sat, 19 Dec 2015, Saba Sehrish via R-help wrote:

> Hi I am using NeweyWest standard errors to correct lm( ) output. For example:
> lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)
> vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5))
>
> I am using package(sandwich) for NeweyWest. Now when I run this command, it gives following error:
> Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) :system is computationally singular: reciprocal condition number = 7.49468e-18
>
> Attached herewith is data for A&B, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are 
> simply lag variables. Can you help me removing this error please?

Without trying to replicate the error, there are at least two issues:

(1) You should scale your data to use more reasonable orders of magnitude, 
e.g., in millions. This will help avoiding numerical problems.

(2) More importantly, you should not employ HAC/Newey-West standard errors 
in autoregressive models. If you use an autoregressive specification, you 
should capture all relevant autocorrelations - and then no HAC estimator 
is necessary. Alternatively, one may treat autocorrelation as a nuisance 
parameter and not model it - but instead capture it in HAC standard 
errors. Naturally, the former strategy will typically perform better if 
the autocorrelations are more substantial.

> Saba


More information about the R-help mailing list