3

I estimated a VAR-model in R using the vars package and want to estimate Newey West Standard Errors using the sandwich package

  VARmodel_quotedspread <- VAR(data_for_VAR_model_quotedSpread, lag.max = 2, ic = "HQ", type = c("const"))
NeweyWest(VARmodel_quotedspread$varresult$quoted_spread)

Since the parameter for the function is an lm-object I thought I could use the function for the standard errors directly on the corresponding lm-objects stored in a list in the estimated VAR-model. However, I get the following error

NeweyWest(VARmodel_quotedspread$varresult$quoted_spread)
Error in AA %*% t(X) : requires numeric/complex matrix/vector arguments
In addition: Warning message:
In ar.ols(x, aic = aic, order.max = order.max, na.action = na.action,  :
  model order:  1 singularities in the computation of the projection matrix results are only valid up to model order 0

while using it on a manually estimated lm-model using the same variables

lm(VARmodel_quotedspread$varresult$quoted_spread$model$y ~ 
VARmodel_quotedspread$varresult$quoted_spread$model$quoted_spread.l1 + 
VARmodel_quotedspread$varresult$quoted_spread$model$ILLIQ.l1 + 
VARmodel_quotedspread$varresult$quoted_spread$model$absolute_r_S_P500.l1
 + VARmodel_quotedspread$varresult$quoted_spread$model$r_S_P500.l1 + 
VARmodel_quotedspread$varresult$quoted_spread$model$r.l1 + 
VARmodel_quotedspread$varresult$quoted_spread$model$monthly_trading_vol_dollar_corrected.l1 + 
VARmodel_quotedspread$varresult$quoted_spread$model$quoted_spread.l2 + 
VARmodel_quotedspread$varresult$quoted_spread$model$ILLIQ.l2 + 
VARmodel_quotedspread$varresult$quoted_spread$model$absolute_r_S_P500.l2 
+ VARmodel_quotedspread$varresult$quoted_spread$model$r_S_P500.l2 +
 VARmodel_quotedspread$varresult$quoted_spread$model$r.l2 + 
VARmodel_quotedspread$varresult$quoted_spread$model$monthly_trading_vol_dollar_corrected.l2)
NeweyWest(linear_model)

works completely fine. While I could use this workaround, I would still prefer not to manually compute an additional lm-model for every equation of the VAR-model.

I would be grateful for any advise.

1 Answers1

0

I had the same problem. The error seemed to be coming from the prewhitening step

var.fit <- ar(umat, order.max = prewhite, demean = FALSE, 
    aic = FALSE, method = ar.method)

inside bwNeweyWest, which is called inside NeweyWest.

The error disappeared after removing the prewhitening. In other words, I did

NeweyWest(x, prewhite = FALSE)
JS1204
  • 11
  • 1