[R-sig-ME] Marginal effect plot for an interaction effect from GLMM following a beta-distribution (glmmTMB)
Daniel Lüdecke
d@|uedecke @end|ng |rom uke@de
Tue Oct 20 08:54:21 CEST 2020
I share this confusion. I believe, the "margins" package computes *average* marginal effects, and the "emmeans" and "effects" packages average over factor levels for non-focal terms, so some people call this "marginal" effects / means.
You could also try the ggeffects package, which actually is a convenient wrapper for stats::predict() (via ggpredict()), effects::effect() (via ggeffect()) and emmeans::emmeans() (via ggemmeans()). ggeffects provides a consistent API / function design, so you can switch between the three underlying packages (predict, effects and emmeans) as needed, without changing the code.
There is a comprehensive online documentation: http://strengejacke.github.io/ggeffects
In your case, the simplest function call would be:
ggeffect(model1, c("unemployment", "experience_with_ref")) # uses effects package
ggemmeans(model1, c("unemployment", "experience_with_ref")) # uses emmeans package
ggpredict(model1, c("unemployment", "experience_with_ref")) # uses stats::predict
or:
plot(ggeffect(model1, c("unemployment", "experience_with_ref")))
plot(ggemmeans(model1, c("unemployment", "experience_with_ref")))
plot(ggpredict(model1, c("unemployment", "experience_with_ref")))
I think the function calls in "effects" and "emmeans" are quite similar, however, plotting capabilities may differ between packages.
Best
Daniel
-----Ursprüngliche Nachricht-----
Von: R-sig-mixed-models <r-sig-mixed-models-bounces using r-project.org> Im Auftrag von Ben Bolker
Gesendet: Montag, 19. Oktober 2020 22:54
An: r-sig-mixed-models using r-project.org
Betreff: Re: [R-sig-ME] Marginal effect plot for an interaction effect from GLMM following a beta-distribution (glmmTMB)
I always get confused about the different meanings of the term
'marginal', but it's possible that the emmeans package will do what you
want ...
On 10/19/20 4:21 PM, Jan anye Velimsky via R-sig-mixed-models wrote:
>
> Dear R project mixedmodels users,
>
> I am struggling to estimateand visualize the marginal effects (interaction effect) from a GLMM Model.
>
> We have been estimatinga GLMM model following a beta-distribution with the glmmTMB-package. The model consistsof factors influencing referendum turnout (range between 0-1) in german municipalities.The primary units of investigation are city districts nested in referendumsnested in cities.
>
> Here an example model:
>
> model1 <- glmmTMB (ref_turnout ~ unemployment + contestation+ experience_with_ref + (experience_with_ref *unemployment)+ (1| town/ referendum), family=list(family="beta", link ='logit'), data = ml)
>
>
>
> Results example model:
>
> Estimate Std. Error zvalue Pr(>|z|)
>
> (Intercept) -0.583 0.131 -4.455 8.4e-06***
>
> unemployment -0.067 0.002 -30.397 < 2e-16 ***
>
> contestation 0.008 0.003 2.398 0.0165 *
>
> experience_with_ref 0.012 0.052 0.228 0.8200
>
> unemployment: experience_with_ref -0.001 0.001 -1.725 0.0845 .
>
>
>
> The model contains an interaction effect with unemploymentper district and experience with referendums in the respective city.
>
> The aim is to visualize the interaction effects plotting the marginal effects.
>
> With the "marginal_effects" command from the (margins-package) it was possible to estimate marginal effects,but no further summaries which are needed for plotting the model. The "margins" command does not work for the glmmTMBmodel. The idea is to have a simplemarginal effects plot for the interaction effect like this:
>
>
> Thanks a lot for your help!
> Jan Velimsky
>
> -- Jan Velimsky, MAResearch associate
> Ludwig-Maximilians-Universität Munich
> Geschwister-Scholl-Institut of Political Science (GSI)
> Oettingenstrasse 67
> D-80538 Munich
>
>
>
>
>
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
_______________________________________________
R-sig-mixed-models using r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
--
_____________________________________________________________________
Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard Göke (Vorsitzender), Joachim Prölß, Prof. Dr. Blanche Schwappach-Pignataro, Marya Verdel
_____________________________________________________________________
SAVE PAPER - THINK BEFORE PRINTING
More information about the R-sig-mixed-models
mailing list