I am confused about how random effects are structured in my model. I've read the discussion about it Crossed vs nested random effects: how do they differ and how are they specified correctly in lme4?. But I'm still having doubts.

I measured the response in plants as Duration [in seconds] at two Ages [young and old] using the same plants. So, I think it's a repeated measures design with crossed random effects, because the same individuals were measured two times, first at T1, then at T2. I assumed it is not nested, because subjects are not independently measured at Age. My experimental design

My data:

plantID Age Duration Nleaves.plant
1 Young 1.33 18
1 Old 2.64 75
2 Young 4.68 14
2 Old 4.99 56
3 Young 3.34 26
3 Old 3.75 94

I think that I have a crossed design, so a model like this would be appropriate:

m <- glmmTMB(Duration~ Age+ Nleaves.plant +(1|plantID) + (1|Age), data=df, family = Gamma("log"))

But I also was wondering if this model is correct as well:

m2 <- glmmTMB(Duration~ Age+ Nleaves.plant + (Age|plantID), data=df, family = Gamma("log"))

My questions are:

  1. Which model is correctly specified?

Sorry about this question, I know that it has been adressed many times in this forum, but I am still confused on this topic. Thank you for your time.


1 Answer 1


The first model:

Duration~ Age+ Nleaves.plant +(1|plantID) + (1|Age)

...does not make sense because Age has only 2 levels plus it appears to be of primary interest in your research question. So it should be a fixed effect.

The 2nd model makes sense, provided that random slopes ate supported by the data.

  • $\begingroup$ Thank you for your response and time. I think you are right, it makes more sense to fit a model with random slopes and intercepts. $\endgroup$ Sep 21, 2021 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.