1
$\begingroup$

I am running a lmer mixed effects model with three fixed effects parameters, each having multiple levels:

predic1: HH LR RR LD (4 levels) predic3: L1 L2 L3 L4 (4 levels) predic2: A B C D E F (5 levels)

I know that R, by default, uses the treatment coding for contrasts, where each level is compared to a reference level. I would instead like to have access to all the possible pairwise comparisons between different levels of each predictor. For example, in the case of predic1, I would like to see the following comparisons in the results of the model:

(HH-LR) 1-2 (HH-RR) 1-3 (HH-LD) 1-4 (LR-RR) 2-3 (LR-LD) 2-4 (RR-LD) 3-4

More like a combination of successive and treatment contrast codings.

Is there any built-in function in R for this type of comparison? If not what is the correct contrast matrix for these comparisons?

$\endgroup$
1
$\begingroup$

You can indeed do all multiple comparisons between the levels of these predictors, and appropriately correct for multiple testing. This can be done, with, for instance, the multcomp and emmeans packages. Below a generic example with multcomp:

library(multcomp)

fm <- lmer(...) 

fm_mc <- glht(fm, linfct = mcp(predic1 = "Tukey"))
summary(fm_mc)
$\endgroup$
  • $\begingroup$ Thanks for your reply. I tired multicomp based on your suggestion. I’m afraid the results are not consistent with those of lmerTest. The reason is that lmerTest uses a different method (Satterthwaite’s method of approximation) to calculate p-values. $\endgroup$ – Tom Oct 6 '18 at 12:13
  • $\begingroup$ You can set the degrees of freedom for the $t$ distribution (e.g., what you get from the lmerTest) in glht() using the df argument. $\endgroup$ – Dimitris Rizopoulos Oct 6 '18 at 18:00

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.