[R-sig-ME] nested random effects in lmer

Phillip Alday me @end|ng |rom ph||||p@|d@y@com
Mon Apr 11 05:18:18 CEST 2022


I'm not familiar with JMP, but I suspect that both treatment and sex
should be fixed effects. If each mouse receives only a single treatment,
then you would have:

1 + treatment * sex + (1|mouse)

if there is treatment by sex interaction

or

1 + treatment + sex + (1|mouse)

if there is no treatment by sex interaction.

If each mouse received multiple treatments, then you may want to
consider (1 + treatment|mouse) instead of (1|mouse) in order to allow
for the treatment effect size to vary between mice.


The GLMM FAQ has a small section on this:

https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#should-i-treat-factor-xxx-as-fixed-or-random

Hope that helps a bit,
Phillip

On 8/4/22 7:40 am, Amanda Barabas wrote:
> Hello R members,
> 
> I have a situation involving nested data for which I couldn’t find a clear
> answer and am hoping someone can help.
> 
> 
> 
> I do work using laboratory mice. A common study design involves repeated
> measures of single animals receiving the same treatment over time. For
> these designs, it’s recommended to use a nested design since each animal
> typically only experiences one treatment level. It looks like I could code
> this by adding these terms to a lmer model:
> 
> 
> 
> (1|Mouse) + (1|Treatment:Mouse)
> 
> 
> 
> However, we also like to account for sex in the models. A single mouse can
> only have one sex, so I would similarly code this nested effect with:
> 
> 
> 
> (1|Mouse) + (1|Sex:Mouse)
> 
> 
> 
> If I have a single model where Mouse is nested in both Treatment and Sex,
> do I need an additional term to reflect this? Would this code be correct?:
> 
> 
> 
> (1|Mouse) + (1|Treatment:Mouse) + (1|Sex:Mouse)
> 
> 
> 
> For comparison, I’ve previously used JMP for nested models. In JMP, Mouse
> nested in both Treatment and Sex would look like this: Mouse(Treatment,
> Sex). I’m not sure if the above line of code would be the R equivalent or
> if I need to add a term that includes both Treatment and Sex in the same
> set of parentheses. My searches weren’t very helpful for this situation.
> I’d greatly appreciate any resources anyone may have about this type of
> design.
> 
> Thanks,
>



More information about the R-sig-mixed-models mailing list