[R] Marginal effects with plm
Fox, John
j|ox @end|ng |rom mcm@@ter@c@
Thu Sep 6 16:03:07 CEST 2018
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 using gmail.com]
> Sent: Thursday, September 6, 2018 8:52 AM
> To: Fox, John <jfox using mcmaster.ca>
> Cc: r-help mailing list <r-help using 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
More information about the R-help
mailing list