I am quite new to mixed effects modelling but am starting to explore more complex designs for hypothesis testing using lmer
in R. The model specification is starting to get more complex and I am wondering if anyone could give an opinion on whether what I am doing is appropriate for the question at hand, or if they could point to a resource for understanding how to build up the statistical model.
I have a nested experimental design (cell biology) in which I measure approx. 1000 individuals (cells) in each group (well). Each well is either a treatment or control group. There are 3 wells for each treatment.
So far I have been testing for significant effects of treatment on the value measured for each cell using:
lmer(formula = value ~ treatment + (1 | well), data = .)
which I think treats well
as a random effect and allows me to test (using anova
) whether the fixed effect treatment
significantly affects value
in the context of this nested design (with multiple wells for each treatment). Based on some simulations this seems to give the expected results.
Now I want to extend this to compare measurements taken within different parts (compartments) of each cell and ask the question: "does the treatment have different effects on the different compartments in the cell?". My first attempt at this was:
lmer(formula = value ~ treatment + compartment +
treatment:compartment + (1 | well), data = .)
where the values
are now measured in two different compartments for each cell. I then used anova
to look at the significance of the interaction term treatment:compartment
This gives for example,
Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
treatment 0.5598 0.5598 1 6.1 24.94 0.002396 **
compartment 9.8343 9.8343 1 8860.0 438.15 < 2.2e-16 ***
treatment:compartment 18.0228 18.0228 1 8860.0 802.98 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
which I think means that treatment
and condition
(both two-level factors) have a significant effect on value
and that the effect is different for the two compartments (based on significance of treatment:compartment
).
Two questions:
- Do I need to also specify any additional random effects after including the additional fixed effects in the model?
- Does it matter that the two compartments come from the same cell (i.e. these are not strictly independent)? I have unique labels for each cell.
(1 | well) + (1 | well:treatment)
suggests thattreatment
is nested inwell
which doesn't seem to be the case here. Also, as a gneral rule you don't want to include a fixed effect as part of a grouping term for random effects, unless you have a very good reason. You say "each group (well), which is either a treatment or control group" which tells me thatwell
indicates the treatment group, but in that case what is thetreatment
variable for ? Please can you explain your study design and data clearly ? $\endgroup$well:treatment
terms, (they were only necessary when I had replicated well labels in the two treatment groups for my simulated data). $\endgroup$well
belongs to one and only one level oftreatment
then yes, although it's largely irrelevant since with only 2 treatments, and with treatment as your main exposure, it would not make sense to fit nested random effects. $\endgroup$