Home › forums › Mixed Models › plotting models created by lmer_alt functions
Tagged: afex, emmip, mixed models, plotting
- This topic has 1 reply, 2 voices, and was last updated 6 years, 8 months ago by henrik.
-
AuthorPosts
-
-
January 16, 2018 at 12:18 GMT+0000 #180Jarkko HautalaParticipant
I’m trying to plot the results of my mixed model, e.g.:
emmip(model, a~b|c, CIs = TRUE)
where
a=dichotomous within-subject fixed factor
b=numeric, continuous between-subject fixed factor
c=dichotomous between-subject fixed factorThe 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 GMT+0000 #181henrikKeymaster
emmip()
is not part ofafex
, but part of theemmeans
package. 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.In general,
lmer_alt
returns the same object aslmer
orglmer
. In the default setting it returns objects of classmerModLmerTest
forlmer
objects. If you prefer the ‘true’merMod
objects returned fromlme4
in this case you can change this via:
afex_options(lmer_function = "lme4")
(but note that thenmethod = "KR"
and"S"
stop working).mixed
returns objects of classmixed
, for which the slotfull_model
contains the same model oject aslmer_alt
.Thus, objects returned from
lmer_alt
(or thefull_model
slot ofmixed
objects) should in principle work with all functions which work withmerMod
objects. For example foreffects
: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))
-
-
AuthorPosts
- You must be logged in to reply to this topic.