Solved – Repeated measures with nested data mixed effects model

lme4-nlmenested datarrepeated measures

Hi everyone: I'm hoping for help analyzing nested data in R.
I measured the mass of chicks at 3 time points; chicks were in one of two treatments (P and W) and in one of two environmental conditions (Wet or Dry). I have measurements from multiple chicks per (literal) nest.

Here's what the data look like:
chick nest visit treatment condition mass
1 a 1 1 P dry 4.5
2 a 1 2 P dry 17.2
3 a 1 3 P dry 32.4
4 b 1 1 P dry 4.2
5 b 1 2 P dry 18.0
6 b 1 3 P dry 30.2
7 c 2 1 P dry 5.2
8 c 2 2 P dry 18.3
9 c 2 3 P dry 31.0

And here's what the data look like plotted
plot of mass over visit

I'm trying to use a linear mixed effects model in lme4 to test the hypothesis that the treatments differ in the dry conditions but not otherwise but I am not sure how to code the random effects/ leverage repeated measures of each individual chick. What do you think of these approaches?
Option 1)

lmer(mass~ treatment * condition + (1|visit/nest/chick)

Option 2)

lmer (mass~treatment * condition + visit +(1|nest/chick)

Thanks for any help.

Best Answer

The important question here is whether visit indicate a pre-during-post design, where you measure the chickens' mass before, during and after the treatment. In this case, if you want to assess the effectiveness of the treatment option 2 would be the correct choice.

However, additionally you might want to look at the interaction effect of treatment* condition* visit. If this interaction was significant it would tell you that the change in mass over time (between the different visits) would differ between the treatments, i.e. whether the effectiveness of the treatment differs between conditions (dry vs. wet). Moreover, you might want to estimate a random slope for each chick, to see whether the effectiveness of the treatment varies across chicks and nests.

In that case your model would be:

lmer(mass~ treatment * condition * visit + (1 + visit | nest/chick)

If the treatment was already administered and finished before the first visit, you should go with option 1.

Related Question