# Contrast for Mixed-Effects Model for the pre-treatment-post test design

I am learning how to use Linear Mixed-Effects model instead of ANOVA. My data is investigating the effects of four different types of treatments on learning gain, which is measured at before and after the treatments. Some of the participants engaged in several types of treatments and took several types of measurements.

TYPE_OF_TREATMENT <- FACTOR(TYPE_OF_TREATMENT)
TEST_TIMING <- FACTOR(TEST_TIMING)
contrasts (TYPE_OF_TREATMENT) <- contr.sum(4)
contrasts (TEST_TIMING) <- contr.treatment(2, base = 1)
model <- lmer (learning_gain ~TYPE_OF_TREATMENT + TEST_TIMING +(1|participant)+(1|TEST_TIMING:participant)+(1|TYPE_OF_TREATMENT:participant))
require(multcomp)


My questions are:

1. Am I setting the contrasts appropriately? I have never cared about contrast when conducting ANOVA. What I would like to do is to compare differences of the learning gains among treatments (one by one; which should have been taken care of by glht() function.. hopefully). I am assuming, by using this sum contrast for treatment, I can get the estimated value for each treatment when doing summary(model). And by using treatment contrast, I am seeing the comparison between post-test (as a factor) and pre-test (as intercept). The significance for each treatment means that the estimated value for each treatment is not 0 ... Am I understanding right?

2. Is intercept in the results of summary (model) showing the estimated value for pre-test? Or does intercept include other values from TYPE_OF_TREATMENT as well?

3. Sometimes, I can see lmer() function report the warning saying that

fixed-effect model matrix is rank deficient so dropping 28 columns / coefficients

This happens when I put interactions. Is this something I can ignore? Or, do I have to simplify the model until I eliminate this warning?

• I don't see anything wrong with how you are using glht, though I am not sure about the effect of using contr.sum and contr.treatment. My recommendation, tho, is to transition to using emmeans. I think it's a little easier to use, and can also handle contrasts on interactions. I wrote an answer with a simple example here: stats.stackexchange.com/questions/102857/post-hoc-after-glm . Dec 19, 2017 at 16:52