# Crossed or nested random effects in a repeated measures and a between-subject design?

After reading a lot of material on nested and crossed effects, I am still unsure on whether the random effects in my design are nested or crossed. I would really appreciate advice from some more seasoned linear mixed model users!

Design: Two independent groups of Participants (before and after event) completed questions several times a day for several days. Within each of these two groups (before and after), there are two age groups.

For each question, I would like to run a linear mixed model with event (before and after) and Age group as fixed effects (and their interaction) to ask whether affect significantly changed before and after event and whether this is different for the two age groups.

As each participant contributed up to 35 data points, I would like to account for within-person variance as well as the day number (1-7) and signal number (1-5 each day).

I am trying to figure out whether these random effects should be specified as crossed or nested random effects. As far as I understand, here are some of the possibilities, where subject = IDNO, day number = DAY and signal number = SIG:

lmer1 <- lmer(question1 ~ event*AgeGroup + (1|IDNO) + (1|DAY) + (1|SIG), data = df1)

lmer1 <- lmer(question1 ~ event*AgeGroup + (1|IDNO/DAY/SIG), data = df1)


From the design specified above, which random effect structure makes more sense? Or does another specification make more sense?

Any help with this would be greatly appreciated after lots of independent research which has left me unsure!

From your description, these are crossed random effects.

For a factor, A, to be nested within another, B, this means that for any particular level of A, this occurs within one, and only one level of B.

So, in your study, for example, if signal 1 occurs only in day 1, and signal 2 occurs only in day1, while signal 2 occurs only in day 3 etc, then we would say that signal is nested in day. This does not appear to be the case, because each signal appears in each day, and on each day there were multiple signals - that is, they are crossed.

Also for example, if day 1 occurs only within subject 1, while day 2 occurs only in subject 3, day 4 in subject 3, etc, again we would say that day is nested in subject, and again this does not appear to be the case because each subject was measured on each day, and on each day, multiple subjects were measured; hence they are crossed.

So your 1st model would seem to be appropriate:

lmer1 <- lmer(Affect1 ~ COVID*AgeGroup + (1|IDNO) + (1|DAY) + (1|SIG), data = df1)


See this answer for further details:
Crossed vs nested random effects: how do they differ and how are they specified correctly in lme4?

• If I understand this correctly, one group of participants was used Before and another, independent group was used After. We don’t know how the two groups were selected, but it’s safe to assume that the two groups may differ with respect to variables that may affect the outcome variable, emotion. As an extreme example, if gender affects emotion and the Before group contains 90% females and the After group contains 90% males, then a difference in affect between the Before and After group (on average) could simply reflect the difference in gender make up among the two groups. Aug 24, 2020 at 15:08
• @IsabellaGhement I agree there could be confounding here, although that wasn't part of the question. Aug 24, 2020 at 15:12
• By considering different groups Before and After, the study design is defficient in the sense that it will make interpretation of the results quite difficult - these results could simply reflect differences in the make up of the two groups. If no active effort was made to make the groups as comparable as possible with respect to factors that could potentially affect emotion, then we will not be comparing like with like with respect to these factors. Aug 24, 2020 at 15:14
• Great, Robert! I thought I would flag out the potential confounding issues, as they are crucial to providing correct interpretation to modelling results. Aug 24, 2020 at 15:15
• @IsabellaGhement Thank you for your suggestions. I will take care to consider other confounding variables. Aug 26, 2020 at 10:40