I ran the following mixed model:
fit_mixed_POST <- mixed(correct~probability_simple*letter_position+
(1|PP),data=all_data_cleaned_POST_only, method = c("LRT"),
family=(binomial(link = "logit")))
Now, I would like to perform all pairwise comparisons for probability_simple and letter_position using emmeans. However, when trying to run (after introducing the library(emmeans):
emmeans(fit_mixed_POST, "probability_simple")
I get following error:
Error in ref_grid(object, ...) : Can't handle an object of class “mixed”
However, emmeans should support the performed mixed model, according to the documentation. The mixed model is part of the afex package, and they mention that mixed objects should be supported.
Any suggestions?
I cannot reproduce your issue.
According to the list of models supported by emmeans
mixed
models from the afex
package are supported directly through the afex
package.
We can verify the calculation of marginal means from the mixed
model fit, using one of the sample datasets included in afex
library(afex)
library(emmeans)
data(md_15.1)
model <- mixed(iq ~ timecat + (1 + time|id), data = md_15.1)
emmeans(model, "timecat")
# timecat emmean SE df lower.CL upper.CL
# 30 103 4.14 12.3 94.0 112
# 36 107 3.88 14.8 98.7 115
# 42 110 3.91 14.8 101.6 118
# 48 112 4.23 12.2 102.8 121
#
#Degrees-of-freedom method: kenward-roger
#Confidence level used: 0.95