Here comes my case:
I conducted an experiment with the following design:
- 30 participants, each with a unique id, were screened and classified according to a trait.
- Then, all participants were tested in two conditions (in random order), and each outcome was measured for each limb of each participant (in random order as well).
Data structure:
$id : Factor w/ 30 levels
$trait : Factor w/ 2 levels "Y", "N"
$condition : Factor w/ 2 levels "CTL", "EXP"
$limb : Factor w/ 2 levels "R", "L"
$outcome : num
If we were to calculate whether the outcome differs between conditions or traits and their interaction, the left side and fixed terms of the lmer
formula would be something like outcome ~ condition * trait
.
And here comes when I need your expertise. So far, I believe that the random terms of my model should take into account that:
- Participants (id) in each trait are completely different (Q1 Is id really nested within trait?)
- Each trait/id has 4 related outcomes: 2 conditions (CTL, EXP) x 2 limbs (R, L). (Q2 Are trait/id, condition and limb crossed?)
After doing some research (1, 2, 3, 4, 5) I explored some alternatives:
m1 <- lmer(outcome ~ condition * trait + (1|id) + (1|limb) + (1|condition), data)
m2 <- lmer(outcome ~ condition * trait + (1|outcome/id) + (trait|limb) + (trait|condition), data)
m3 <- lmer(outcome ~ condition * trait + (1|condition/limb/id), data)
Note: m3 returns the following Error message: number of levels of each grouping factor must be < number of observations
.
[EDITED:] No matter how many models I try, I am never sure about what terms would be reasonable to include as randoms. My main question then (Q3) is: should I specify, incorporating random effects, that there exist nested and crossed variables?
Furthermore, I have a last question (Q4): Would it make sense to initially include limb as a fixed term, to explore possible differences between hemispheres, and in case of not finding any limb differences continue the analisis modelling it as random?
I would really appreciate if some of you could point me in the right direction...
(1|id)
the proper way to indicate that certain degree of variability might come from the existence of crossed variables? I really appreciate your comment! $\endgroup$outcome ~ condition * trait + (condition | id)
. Most of the models that you "explored" don't make any sense and show that you don't really know what you are doing. It might make sense to study mixed models more systematically before you proceed. $\endgroup$outcome ~ condition * trait * limb + (condition | id) + (1 | id:limb)
. Regarding some of the models in your question:( ... | limb)
does not make sense because limb has only 2 levels.( ... | condition)
does not make sense for the same reason.( ... | outcome)
does not make sense because it's the dependent variable.(trait | ...)
does not makes sense because trait is between-subject variable. $\endgroup$