experimental design - repeated measures within factor combinations? Sorry for what might be an obvious question, but I have a question about an experimental design for which I can create a "mouse" analogue:
I have 270 mice. I have 2 treatments (factors)-- L and S (2 types of vitamin, each with 3 levels). I apply the treatments such that there are 9 groups of 30 mice, each group of 30 gets 1 factor level combination, i.e., L1S1, L1S2, ... L3S3. So one replicate of my experiment requires 9 experimental units, 30 replicates --> 270 experimental units. Fine.  Next, on each of these mice, we apply each level combination of 3 additional treatments (drugs) (d (3 levels), m (4 levels) and a (2 levels). So dXmXa 3X4X2=24 treatment level combinations. One day we apply d=1,m=1,a=1 levels of the 3 drugs to each of the 270 mice, and measure their heart rate. Next day we apply d=1,m=1,a=2, we measure their heart rates, etc. until we've done our 24 days, and have 270 * 24 or 6480 total measurements of heart rate. The goal of my experiment was to understand the effects of the treatments independently, and 2-way interactions. For instance are the effects of d, m, or a mediated by level of L, or LXS interactions. Also, does d have a bigger impact on heart rate than m under different LS combinations,  etc. etc.
It sounds like a factorial design, it sounds like repeated measurements (each mouse gets all of the dma treatment combinations applied to it). I'd like to analyze it with a mixed effects model; it sounds like random effects are from the replicate, as there are repeated measurements on the same experimental unit.
It has been some 30 years since I have had an experimental design class, and I am stumbling around on the Internet trying to figure this out. Can anyone point me in the right direction? Any suggestions for the form of the lme model in R? Thanks for any advice!
Andrew
 A: Yes, it seems that you have a repeated measures factorial design.
So there are repeated measures within mice so we would want to fit random intercepts for mice since measurements within mice are likely to be correlated
The mice are grouped into 30 replicates of 9 and so we would also want to fit random interecepts for replicate, since measures within the same replicate may be correlated. If the variance component for replicate is close to zero or the model converges with a singular fit warning then you can remove replicate from the random effects
We can also say that any individual mouse belongs to one and only one replicate. Hence mice are nested in replicates.
Such a model can be fitted with lme from the nmle package using:
lme(Y ~ L + S + d + m + a, random = ~  1|replicate/mouseID, data = mydata)

or with the newer packages such as lme4 and other, the standard syntax would be
Y ~ L + S + d + m + a + (1|replicate/mouseID), mydata

You can then add the interactions that you are interested in.
