1
$\begingroup$

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 ?

$\endgroup$
3
  • 1
    $\begingroup$ What do you want to happen with respect to nuissance parameters (see the weights and nuissance options)? 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$ Commented May 5 at 9:40
  • $\begingroup$ I am just trying to understand why the contrast parameters differ between these two code chunks. I would assume since emmeans averages over the groups, they would be equal $\endgroup$ Commented May 5 at 9:57
  • $\begingroup$ Depending on the options you pick for weights and nuissance, you'd for a start get different averaging over levels of the other variable (e.g. assuming a equal proportion of each category vs. the proportions at which categories are seen in the data vs. anything else you might want). That has a huge effect on the estimates. $\endgroup$ Commented May 5 at 22:23

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.