Under the hood, marginaleffects
’s predictions
and marginalmeans
functions use the insight
package to retrieve adjusted predictions from a wide variety of models. Currently, insight
supports very many model types, and most should work out-of-the-box with the predictions
function. If you run into problems, do not hesitate to report them on Github or via email.
This table shows the list of model types for which the marginaleffects
function can compute slopes and contrasts. There are three main alternative software packages to compute such slopes (1) Stata
’s margins
command, (2) R
’s margins::margins
function, and (3) R
’s emmeans::emtrends
function. The test suite hosted on Github compares the numerical equivalence of results produced by marginaleffects
to those produced by all 3 alternative software packages:
marginaleffects
.I am very eager to add support for new models. Feel free to file a request or submit code on Github.
Package | Function | dY/dX | SE | dY/dX | SE | dY/dX | SE |
---|---|---|---|---|---|---|---|
stats | lm | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
glm | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
AER | ivreg | ✓ | ✓ | ✓ | ✓ | U | U |
tobit | ✓ | ✓ | U | U | ✓ | ✓ | |
aod | betabin | U | U | U | U | ||
betareg | betareg | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
bife | bife | U | U | U | U | ||
brglm2 | bracl | U | U | U | U | ||
brglmFit | ✓ | ✓ | ✓ | ✓ | |||
brnb | ✓ | ✓ | U | U | |||
brmultinom | U | U | U | U | |||
brms | brm | U | U | ✓ | ✓ | ||
crch | crch | U | U | U | U | ||
hxlr | U | U | U | U | |||
estimatr | lm_robust | ✓ | ✓ | ✓ | U | ✓ | ✓ |
iv_robust | ✓ | ✓ | U | U | U | U | |
fixest | feols | ✓ | ✓ | U | U | U | U |
feglm | U | U | U | U | |||
fepois | ✓ | ✓ | U | U | U | U | |
gam | gam | U | U | ✓ | ✓ | ||
geepack | geeglm | U | U | ✓ | ✓ | ||
glmx | glmx | ✓ | U | U | U | ||
ivreg | ivreg | ✓ | ✓ | ✓ | ✓ | U | U |
lme4 | lmer | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
glmer | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
glmer.nb | ✓ | ✓ | ✓ | ✓ | |||
lmerTest | lmer | ✓ | ✓ | ✓ | ✓ | ||
MASS | glmmPQL | U | U | ✓ | ✓ | ||
glm.nb | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
polr | ✓ | ✓ | ✖ | ✖ | ✓ | ✓ | |
rlm | ✓ | ✓ | ✓ | ✓ | |||
mclogit | mblogit | U | U | U | U | ||
mclogit | U | U | U | U | |||
mgcv | gam | U | U | ✓ | ✓ | ||
nlme | gls | U | U | ✓ | ✓ | ||
nnet | multinom | ✓ | ✖ | U | U | U | U |
ordinal | clm | ✓ | ✓ | U | U | U | U |
plm | plm | ✓ | ✓ | ✓ | ✓ | U | U |
pscl | hurdle | ✓ | U | ✓ | ✖ | ||
zeroinfl | ✓ | ✓ | ✓ | U | ✓ | ✓ | |
quantreg | rq | ✓ | ✓ | U | U | ✓ | ✓ |
rms | lrm | U | U | ✓ | ✓ | ||
robust | lmRob | U | U | U | U | ||
robustbase | glmrob | ✓ | ✓ | U | U | ||
lmrob | ✓ | ✓ | U | U | |||
robustlmm | rlmer | U | U | ||||
rstanarm | stan_glm | ✖ | U | ✓ | ✓ | ||
scam | scam | U | U | U | U | ||
speedglm | speedglm | ✓ | ✓ | ✓ | ✓ | U | U |
speedlm | ✓ | ✓ | ✓ | ✓ | U | U | |
survey | svyglm | ✓ | ✓ | ✓ | ✓ | ||
survival | coxph | ✓ | ✓ | U | U | ✓ | ✓ |
truncreg | truncreg | ✓ | ✓ | ✓ | ✓ | U | U |