1

apologies if I write anything wrong - this is my first post. I am doing some time series regressions on the different determinants of house prices for different countries, and would like to use modelplot() to showcase the different coefficients for one variable across all the countries. This is the easy part, and I have it done. However, when I try to run this code to try and include Newey-West std. errors:

modelplot(mods_TS_graph,
      coef_map= varnames,
      vcov = c(vcovAUS, vcovBEL, vcovEST, vcovFIN, vcovFRA, vcovGER, vcovGRE, vcovIRE, vcovITA, vcovLAT, vcovLIT, vcovLUX, vcovNET, vcovPOR, vcovSLK, vcovSLE, vcovSPA),
      coef_omit="[^ECB]",
      draw=T, size=1)

Where the vcovAUS arguments etc are just sandwich::NeweyWest(OLS_AUS) etc I get the following error:

Error in get_vcov.default(model, vcov = vcov, conf_level = conf_level, : Unable to extract a variance-covariance matrix from model of class lm. The variance-covariance matrix is required to adjust the standard errors. The vcov argument accepts a variance-covariance matrix, a vector of standard errors, or a function that returns one of these, such as stats::vcov.

I used pretty much the same method for an earlier modelsummary(), which computed Newey-West standard errors no problem. Is there something I am doing wrong? I have also tried to just use "NeweyWest" in the vcov() argument for modelplot(), just like I did in modelsummary(). Very confused. Thanks for reading, hope somebody can help.

Vincent
  • 15,809
  • 7
  • 37
  • 39
  • Here's a short list of corrections (and use [edit] facility rather than comments to respond): need data example. Add `library` call to load needed packages. – IRTFM Mar 20 '22 at 22:29

1 Answers1

0

The modelplot documentation notes that the vcov argument can be either a list of functions, or a list of matrices, or a vector of strings. This means that both of these commands should work:

library(modelsummary)
library(sandwich)

mod <- lm(mpg ~ hp, mtcars)

modelplot(mod, vcov = c("HC3", "NeweyWest"))

Alternatively,

modelplot(mod, vcov = list(vcovHC, NeweyWest))
modelplot(mod, vcov = list(vcovHC(mod), NeweyWest(mod)))

The error message you get suggests that the specific model you are trying to summarize is unsupported by the sandwich package. You can check if it is supported by calling:

sandwich::NeweyWest(mod)
#>             (Intercept)           hp
#> (Intercept)  5.93124548 -0.032929737
#> hp          -0.03292974  0.000221307

In my example, mod was a lm model, but you did not supply a MINIMAL REPRODUCIBLE EXAMPLE, so your problem is impossible to diagnose conclusively.

Vincent
  • 15,809
  • 7
  • 37
  • 39