January 16, 2018 at 12:18 UTC #180
I’m trying to plot the results of my mixed model, e.g.:
emmip(model, a~b|c, CIs = TRUE)
a=dichotomous within-subject fixed factor
b=numeric, continuous between-subject fixed factor
c=dichotomous between-subject fixed factor
The problem is that resulting plot has only one value on x-axis, the mean of b.
Also I noticed that several handy plotting packages such as visreg or effects do not work on models constructed by afex.
WHat might be happening here?
January 16, 2018 at 13:27 UTC #181
emmip()is not part of
afex, but part of the
emmeanspackage. So I am not the one that can provide adequate support. I am also not sure what it is supposed to do in this case or if it even supports numerical covariates on the x-axis.
lmer_altreturns the same object as
glmer. In the default setting it returns objects of class
lmerobjects. If you prefer the ‘true’
merModobjects returned from
lme4in this case you can change this via:
afex_options(lmer_function = "lme4")(but note that then
method = "KR"and
mixedreturns objects of class
mixed, for which the slot
full_modelcontains the same model oject as
Thus, objects returned from
mixedobjects) should in principle work with all functions which work with
merModobjects. For example for
library("afex") library("effects") data("Machines", package = "MEMSS") # some example data m1 <- mixed(score ~ Machine + (Machine || Worker), data=Machines, expand_re = TRUE) # when using effects with mixed we need to set contr.sum globally: set_sum_contrasts() plot(Effect("Machine", m1$full_model)) # equal to: emmeans(m1, "Machine") ## compare again (now gives wrong results): set_treatment_contrasts() plot(Effect("Machine", m1$full_model))
In principle this should also work for objects returned from
lmer_alt. However it does not right now, because it does not set the data argument correctly (I will correct this in the next version and on github). For now the following works:
m2 <- lmer_alt(score ~ Machine + (Machine || Worker), data=Machines) m2@call[["data"]] <- as.name("Machines") plot(Effect("Machine", m2))
You must be logged in to reply to this topic.