I have conducted an ordinal mixed model with four predictors; all of which are either ordinal or multilevel categorical. In my model comparison, I've found significant main effects and interaction, however now I'd like to decompose the interaction.

Some example data


# Mock data

mock_dat <- data.frame(subj = rep(1:10, each = 8),
                       sex = rep(c("M", "F"), each = 40),
                       score = sample(1:5, 80, replace = T),
                       category = rep(c("A", "A", "B", "B", "C", "C", "D", "D"), 10),
                       item = rep(1:8, 10))

# Deviation coding

mock_dat$dev.sex <- scale(ifelse(mock_dat$sex=="F",1,0), center=TRUE, scale=FALSE)
mock_dat$AB <- scale(ifelse(mock_dat$category=="B",1,0), center=TRUE, scale=FALSE)
mock_dat$AC <- scale(ifelse(mock_dat$category=="C",1,0), center=TRUE, scale=FALSE)
mock_dat$AD <- scale(ifelse(mock_dat$category=="D",1,0), center=TRUE, scale=FALSE)

# Response as factor

mock_dat$score <- as.factor(mock_dat$score)

# Model

mod <- clmm(score ~ dev.sex + AB + AC + AD +
              dev.sex:AB + dev.sex:AC + dev.sex:AD +
              (1 + AB + AC + AD | subj) +
              (1 | item), data = mock_dat)

# Model comparison

no_sex <- update(mod, . ~ . - dev.sex)

no_cat <- update(mod, . ~ . - AB - AC - AD)

no_sex.cat <- update(mod, . ~ . - dev.sex:AB - dev.sex:AC - dev.sex:AD)

Now, let's say there's a significant effect of category and a significant interaction between sex and category.

How would I proceed to do post hoc comparisons, i.e. see how each level of category influence score and how that influence changes based on sex (the interaction)?

So far I've managed to deduce that I can use emmeans but the output is an absolute mess and I am not sure if I need to recode the predictors of if it's enough to just look at them when they're deviation coded? If anyone could show me how they'd do post hoc comparison using emmeans with this data that would be very helpful!

  • $\begingroup$ Have you looked into the effects package, developed by John Fox, Sanford Weisberg (and others)? It is designed to do precisely this type of post-model effect calculation with graphical outputs. stats.stackexchange.com/questions/233007/… $\endgroup$ – Erik Ruzek Jul 24 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.