I'm looking at a glmer for my masters thesis research (I cannot share the data until after thesis is completed so I will try to be very explicit in the descriptions).
But to summarize, my dependent variable is a binary (exhaustbinary), where 1, the participant did the thing, and 0 the participant did not. My independent factors are Age group, (child or adult), and trial type (control or critical), with two random intercepts of individual participant(SubjectID), and individual trial(Item). See code:
agebytrialopt <- glmer (ExhaustBinary ~ Agegroup * TrialType +
(1|SubjectID) + (1|Item), data=df, family="binomial",
control=glmerControl(optimizer="bobyqa",
optCtrl=list(maxfun=100000)))
That's all working marvelously. However on the summary and output I get something counterintuitive.
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 8.701 1.380 6.306 2.86e-10 ***
AgegroupChild -3.805 1.213 -3.137 0.0017 **
TrialTypeCritical -7.049 1.148 -6.140 8.23e-10 ***
AgegroupChild:TrialTypeCritical 6.493 1.201 5.409 6.35e-08 ***
Basically as we switch from the child to adult level children are more likely to have a 1 value in exhaust binary compared to the adult. But, based on the name that the glmer
chose, this should mean that children have a lower "score" compared to the adults. Which isn't accurate to the data, they have a higher score compared to adults.
Compared to the TrialTypeCritical, critical trials have more 0 values in exhaust binary compared to controls. So based on the name, critical trials should have lower "scores" compared to the controls. This is intuitively true/accurate, and the negative estimate makes sense here.
I did check the dummy code for the contrast in the factors, and the base factors look as follows.
> contrasts(df$Agegroup)
Child
Adult 0
Child 1
> contrasts(df$TrialType)
Critical
Control 0
Critical 1
To be fair I've been looking at this for the past 5 hours, and before I start manually setting the contrasts, I want to make sure that I'm interpreting these estimates correctly.
Additionally, since we do have that significant interaction, I have done that breakdown and looked at the emmeans already and all that, everything there makes sense and is interpretable and I don't have any issues with any negative/positive flipping there.
Any insight into where I'm going wrong (in either my understanding of the factors/levels and log estimates or how the contrasts work or just in general) would be helpful.
To make it clear though, the glmer is the best choice for the data we have, and I've done all the theoretical justification to use this approach, so I don't really want to have to field questions about why I chose to use a glmer or the like. I just need help with understanding what is going on with the polarity on AgegroupChild.
options(contrasts = c("contr.sum", "contr.poly"))
(and re-run the model) you will get main effects based on the average across levels of the other factor, which may be easier to interpret. More radically, you could rely on theemmeans
andmarginaleffects
packages to interpret your models and stop worrying about the coefficients entirely ... see x.com/stephenjwild/status/1838315652165378325 $\endgroup$Adult
andControl
), while theTrialTypeCritical
coefficient of -7.049 means an odds ratio of about 1/1000 forCritical
versusControl
forAdult
. They might be correct, but one worries with such large magnitudes. $\endgroup$