I am analyzing a dataset with multilevel modelling in R using the lme4 package. I conducted a study where The influence of participants and learning materials were counterbalanced. Participants went through either the two conditions: (a) learning A condition or (b) learning B condition. The half of the participants learned material A with learning A and material B with learning B, the other half of the particpants learned material B with learning A condition and material A with learning B condition.
How should I specify this counterbalance as random effect for the lm4 package?
Participants went through either the two conditions: (a) learning A condition or (b) learning B condition. The half of the participants learned material A with learning A and material B with learning B, the other half of the participants learned material B with learning A condition and material A with learning B condition.
I think the most sensible model for your experimental design corresponds to the mixed-model formula
~ material*learning + (1 | subject)
That is, you can estimate the interaction between material and learning condition at the population level, but you can only estimate the variation among subjects in overall difference in learning effectiveness (or whatever it is that you're measuring). I initially thought you could estimate the among-subject variation in the additive effects of learning and material, but it's tricky because each individual only sees two conditions (A/A, B/B or B/A, A/B) (estimating variation in the additive effect of both material and learning would require three treatment conditions per individual). You can estimate among-individual variation in the difference between the two conditions they experience, but it's tricky because there are two different types of condition. If you want to go to the effort of coding the maximal model (Barr et al 2013), supposing you have a type
variable that identifies subjects as seeing either a 'parallel' (AA, BB) or 'crossed' (AB, BA) set of conditions, and a which
variable that identifies whether a trial is on the first (AA/AB) or second (BB/BA) condition for that individual.
your_data <- transform(your_data,
tp = dummy(type, 'parallel'),
tc = dummy(type, 'crossed'))
~ material*learning +
(0 + tp + tp:which | subject ) +
(0 + tc + tc:which | subject)
The dummy variable makes sure that each random effect term is zeroed out for half the individuals. This estimates different among-individual terms for each type; this isn't perfect, but it avoids other challenges. If we used (1 + tp:which + tc:which | subject)
we would be trying to estimate a correlation between the second and third terms to the left of the bar, which is impossible: if we used (1|subject) + (0 + tp:which | subject) + (0 + tc:which | subject)
we would be eliminating the correlation between intercept and which
effect, which is a reasonable but slightly restrictive assumption.