I am using the
proc autoreg procedure in SAS and the
sandwich library in R to calculate Newey West covariance for a linear model. The two methods give the same coefficient estimates (expected because they are OLS estimators), but different t-statistics hence p-values. Below is my code for model summary in R:
library(sandwich) model = lm(response ~ var1 + var2 + var3 + var4 + var5 + var6,data=SAS_Q) coeftest(model, vocv=NeweyWest(model,lag=2, prewhite=FALSE))
Below is my code to generate model summary in SAS:
proc autoreg data= SAS_Q plots=all; model response = var1 var2 var3 var4 var5 var6/covest=neweywest;; ods output ParameterEstimates = _auto_full_params_; output out=Autoreg_Out p=FORECAST_t rm=r pm=pm lcl=lcl lclm=lclm ucl=ucl uclm=uclm; run; quit;
No matter how I assign the lag, I can not get the R result to match that of the SAS. More specifically, the p-value for var5 is 0.11 in R but 0.03 in SAS. It also seems that my R-output is quite immune to the change of lag.
Am I doing anything wrong in R? If so, what is it?