Skip to content
Prev 376331 / 398500 Next

Marginal effects with plm

Dear Milu,

I get the same error as you with this example -- I tried a different plm model -- which of course is why a reproducible example is a good idea.

Here's where the error is:

----------- snip -----------
Error in UseMethod("droplevels") : 
  no applicable method for 'droplevels' applied to an object of class "NULL"
10: droplevels(index)
9: model.frame.pFormula(formula = log(gsp) ~ log(pcap) + log(pc) + 
       log(emp) + unemp, data = Produc, drop.unused.levels = TRUE)
8: stats::model.frame(formula = log(gsp) ~ log(pcap) + log(pc) + 
       log(emp) + unemp, data = Produc, drop.unused.levels = TRUE)
7: eval(mf, parent.frame())
6: eval(mf, parent.frame())
5: glm(formula = log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, 
       data = Produc, control = list(epsilon = 1, maxit = 1, trace = FALSE))
4: eval(cl)
3: eval(cl)
2: Effect.default(c("pc", "emp", "unemp"), zz)
1: Effect(c("pc", "emp", "unemp"), zz)

----------- snip -----------

So the error is in model.frame.pFormula(), which is from the plm package. It would probably require substantial effort to get this to work.

Best,
 John