Reputation: 11
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.
Upvotes: 1
Views: 840
Reputation: 17823
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
Upvotes: 1