I have a mixed effects model specified as
complex1.model <- glmer(rt~ mental + alert + (1|subj_id), data = rt.df, family = Gamma(link = "inverse"))
I want to do contrast analysis for the main effects of mental and alert variables. I have been using the following code
emmeans(complex1.model, ~mental + alert)
emm <- emmeans(complex1.model, ~mental + alert)
custom <- list(
'Sleepy - Alert' = c(1,1,1,-1,-1,-1),
'MINDBLANK - ONTASK' = c(-1,0,1,-1,0,1),
'MINDBLANK - OFFTASK' = c(0,-1,1,0,-1,1),
'OFFTASK - ONTASK' = c(-1,1,0,-1,1,0)
)
emm.cont <- contrast(emm, custom, adjust = "fdr")
res <- summary(emm.cont, infer = c(TRUE, TRUE))
The order of the contrasts was extracted from
emmeans(complex1.model, ~ mental + alert)
Recently, it was proposed to me to extract the main effects with the following code
emmeans(complex1.model, pairwise ~ mental, adjust = "fdr")$contrasts |>
summary(infer = c(TRUE, TRUE)) |>
as.data.frame() -> main.mental
emmeans(complex1.model, pairwise ~ alert, adjust = "fdr")$contrasts |>
summary(infer = c(TRUE, TRUE)) |>
as.data.frame() -> main.alert
However, these two approaches give different contrast estimates. Which would be more accurate for my contrasts of interest ?
weightsandnuissanceoptions)? Also note running FDR over fewer terms (when you do mental / alert separately) vs. more (in the original code) will of course make a difference (but not on the point estimates). $\endgroup$