I have a mixed model containing the response variable (resp), two fixed effects (fix1 and fix2) and a random factor (ran1). In particular:
- fix1 has 2 levels (control and treatment);
- fix2 has 7 levels (from 1 to 7, indicating time in a categorical sense);
- ran1 has 6 levels (plots were paired, and pair is used as random variable).
An example of the type of data I am using is
library("tidyr")
library("dplyr")
set.seed(123)
DF <- data.frame(resp = rnorm(84, -2, 1),
fix1 = c(rep("C",42),rep("Trt",42)),
fix2 = c(rep("1",6),rep("2",6),rep("3",6),rep("4",6),rep("5",6),rep("6",6),rep("7",6),
rep("1",6),rep("2",6),rep("3",6),rep("4",6),rep("5",6),rep("6",6),rep("7",6)),
ran1 = c(rep(1:6,14)))
DF
From the example above it's evident that:
- the experimental design is fully factorial (fix1 * fix2);
- All plots have been sampled at each occasion (7 levels of fix2).
In a mixed model containing the interaction between fix1 and fix2,
LME <- lmer(resp ~ fix1 * fix2 + (1 | ran1), DF)
I would like to compare (for fix2):
- the average of levels 1 and 2 against the average of levels 3, 4, and 5;
- the average of levels 3, 4, and 5 against the average of levels 6 and 7;
- the average of levels 1 and 2 against the average of levels 6 and 7.
My questions are:
- How do I set the contrasts (in lmer) in such a way that I can compare the three "new" levels made up by the averages specified above?
- how to interpret the interaction between fix1 and the new specified levels?