3

I wanto to run a two way fixed effects model and then correct standard errors.

mod3 = plm(Dir ~ Dist +Trade + GDP_sim +GDP +   
         GDP_capita_constant +Openess + GDP_g + Endowments + 
         US_PTA + Japan_PTA + FDI + Population+ Democracy+Rule_of_Law+Values+sim+ 
         WTO, data= dfPTA, index = c("Country", "Year"),
       model = "within",
       effect = "twoway")

this works very well.

However, when running this line

m.2wfe.scc <- coeftest(mod3, vcov = vcovSCC(mod3, type = "HC3", cluster = "group"))

I get the following error message

Error in 1 - diaghat : non-numeric argument to binary operator

All my variables are either numeric or integers (except Country).

Interestingly, I can run

mod4 = plm(Dir ~ Dist + Trade + GDP_sim +GDP +   
         GDP_capita_constant+Population+FDI, data= dfPTA, index = c("Country", "Year"),
       model = "within",
       effect = "twoway")
m.2wfe.scc <- coeftest(mod4, vcov = vcovSCC(mod4, type = "HC3", cluster = "group"))

and it works. Alltough I dont see a difference between the subset variables and the full model.

Any ideas?

Helix123
  • 3,502
  • 2
  • 16
  • 36
Julian
  • 31
  • 1
  • It's literally happening because calculation of `diaghat` has failed so it's a string with an error message. It's impossible to know which variable(s) are causing the error without seeing your data, but the issue is likely related to your `model.matrix` being unsolvable in some way. Maybe you have some collinearity in your data? The `plm` function may have silently dropped linearly dependent variables while `vcov` hasn't. – Esther Jun 19 '18 at 19:31
  • thanks for your reply! What is the best way to solve this problem? – Julian Jun 19 '18 at 21:51
  • I couldn't say without seeing your data. In general, you could drop the offending variable(s), try rescaling them, or you could try a different method of calculating the `vcov` matrix. The `plm` object contains a `vcov` matrix, so you can run `coeftest(mod3, vcov=mod3$vcov)` but the results will of course be different than using the `vcovSCC` method. – Esther Jun 19 '18 at 22:19
  • coeftest(mod3, vcov=mod3$vcov) worked, thanks! I will still try to find the offending variables – Julian Jun 19 '18 at 22:47

0 Answers0