1

I understand that this question was asked multiple times, but none received a satisfying answer. I am quite new to using R (transitioning from Stata) and I would like to know whether marginal effect calculation is possible for plm model?

If not, how do you go about this issue to calculate marginal effect? One thought I had is to use lm model and include factor("group_id") and factor("year"). However, it really isn't a feasible solution given the large sample size (cannot allocate vector of enough size) to run the code.

I am hesitant to use Stata just for the margins and margins plot command. Any help would be appreciated.

Thanks.

  • Put some reproducible example of your dataset(dput format preferred) and the main part of your code to make the issue easier to solve. Also in the question area, just write the main question and codes. Not necessary to put something like "I'm hessitant", "I understand" or "thanks". – Behnam Hedayat May 25 '21 at 04:27

1 Answers1

1

The marginaleffects package can compute marginal effects for many, but not all, the models produced by plm. (Disclaimer: I am the maintainer.)

library(plm)
library(marginaleffects)
data(Grunfeld)

mod <- plm(inv ~ value * capital, data = Grunfeld, model = "random", effect = "individual")

mfx <- marginaleffects(mod, type = "probs")

summary(mfx)
## Average marginal effects 
##    type    Term  Effect Std. Error z value   Pr(>|z|)   2.5 % 97.5 %
## 1 probs capital 0.13812   0.022647   6.099 1.0688e-09 0.09373 0.1825
## 2 probs   value 0.08996   0.009234   9.743 < 2.22e-16 0.07187 0.1081
## 
## Model type:  plm 
## Prediction type:  probs
Vincent
  • 15,809
  • 7
  • 37
  • 39