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 -----------
Ef.hd <- Effect(c("pc", "emp", "unemp"), zz)
Error in UseMethod("droplevels") :
no applicable method for 'droplevels' applied to an object of class "NULL"
traceback()
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
-----Original Message-----
From: Miluji Sb [mailto:milujisb at gmail.com]
Sent: Thursday, September 6, 2018 8:52 AM
To: Fox, John <jfox at mcmaster.ca>
Cc: r-help mailing list <r-help at r-project.org>
Subject: Re: [R] Marginal effects with plm
Dear John,
Apologies for not providing reproducible example. I just tried with a
plm example but ran into the same issue;
library(plm)
data("Produc", package = "plm")
zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data =
Produc, index = c("state","year"))
Ef.hd <- Effect(c("pc", "emp", "unemp"), zz)
Error in UseMethod("droplevels") :
no applicable method for 'droplevels' applied to an object of class
"NULL"
What am I doing wrong? Thanks again.
Sincerely,
Milu