0

I need to solve the issue of serial correlation in a within-model. I calculated the regression with country- and year-fixed effects and then calculated robust standard errors HC1. How can I calculate HAC Standard Errors instead? I've read about function vcovHAC() but I couldn't figure out how to implement it properly.

IVpan <- plm(log(Y) ~ log(X),
             model = "within",
             data = df,
             index = c("countryIdentifier","year"),
             effect = "twoways")
covIVpan         <- vcovHC(IVpan, type = "HC1")
robust_seIVpan    <- sqrt(diag(covIVpan))

Thanks for your support!

TFT
  • 129
  • 10
  • It is unclear from which package function `vcovHAC` stems and if it is compatible with plm model objects. Otherwise here is the general approach as an answer to a similiar question of yours (please accept if it answer your question there): https://stackoverflow.com/a/71787457/4640346 – Helix123 Apr 16 '22 at 20:40

1 Answers1

0

coeftest(IVpan, vcov = vcovHAC(IVpan))

Julian
  • 6,586
  • 2
  • 9
  • 33
  • Thanks for your feedback! Somehow, I got an error running the proposed code. The error is **Error with `estfun`**. Do you happen to know why? – TFT Apr 16 '22 at 11:51