[R-sig-ME] Plotting post-fitting inference effects in a glmmTMB model
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Tue Aug 27 15:31:33 CEST 2019
Yes, quite weird as effects:::plot.eff (the relevant method) appears
to check that variables are factors every time it tries to applies
droplevels(). A reproducible example would be great (although
technically maybe not this list's problem, as it's not clear it's
directly mixed-model-related?)
On 2019-08-27 8:06 a.m., Daniel Lüdecke wrote:
> Dear Julian,
>
> without a reproducible example, it's a bit difficult to guess how to solve
> your issue. Is one of your predictors of class "character" and should
> probably be coerced to factor before you fit your model?
>
> Else, you could also try the "ggeffects" package
> (https://strengejacke.github.io/ggeffects/), where you have three functions:
> ggpredict(), ggeffect() and ggemmeans(), each calling the related functions
> "predict()", "effects::effect()" or "emmeans::emmeans()" internally to
> compute marginal effects. There is a plot() method as well, based on ggplot2
> (see examples here
> https://strengejacke.github.io/ggeffects/articles/introduction_plotcustomize
> .html or here
> https://strengejacke.github.io/ggeffects/articles/introduction_plotmethod.ht
> ml).
>
> Best
> Daniel
>
> -----Ursprüngliche Nachricht-----
> Von: R-sig-mixed-models [mailto:r-sig-mixed-models-bounces using r-project.org] Im
> Auftrag von Julian Gaviria Lopez
> Gesendet: Dienstag, 27. August 2019 12:01
> An: r-sig-mixed-models using r-project.org
> Betreff: [R-sig-ME] Plotting post-fitting inference effects in a glmmTMB
> model
>
> Hello,
>
>
> I have the next model:
>
>> zipoisson2 <- glmmTMB(Observations ~ CAP * Condition + (1|ID),
>> contrasts=list(CAP="contr.sum",Condition="contr.sum"), data=mDATA,
>> ziformula=~ 1 , family=poisson)
>
>
> Plotting the effects ("effects" package), I obtain:
>
> (ae <- allEffects(zipoisson2))
>
> model: Observations ~ CAP * Condition
> CAP*Condition effect
> Condition
> CAP aapaff aff neu pneu
> apreC3 3.222636 2.731724 2.777021 2.573694
> insC5 1.406698 3.173030 2.104875 1.420336
> preC1 2.883115 3.641252 2.541221 2.635991
> preC5 2.184075 2.310564 3.137734 1.995430
>
> plot(ae)
> Error in UseMethod("droplevels") :
> no applicable method for 'droplevels' applied to an object of class
> "character"
>
> Question 1: Has anyone encountered the same issue? Any hint to solve it?
>
> Question 2: Maybe is there any other package works better with glmmTMB model
>
> Thanks in advance for any hint about it.
>
> Julian,
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> 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), Prof. Dr. Dr. Uwe Koch-Gromus, Joachim Prölß, Marya Verdel
> _____________________________________________________________________
>
> SAVE PAPER - THINK BEFORE PRINTING
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
More information about the R-sig-mixed-models
mailing list