# Help with lmer formula for a repeated measures ANOVA

This is my first repeated measures analysis.

Subjects in two groups exercise until "peak" level. Blood is taken at baseline (prior to exercise), peak, 2hrs post, 24 hrs post, and 72hrs post. Levels of various proteins are measured in the blood samples.

Groups: 2 (mutation for disease, control)
Subjects: N
Time Points (exercise): 5 (baseline, peak, 2hr, 24hr, 72hr)
Outcome: continuous variable (protein expression)

Is this description right?

If there is a group effect, then there would be an interaction between group and time. The lack of independence comes from the repeated measurements on the same subjects, so there should be a random effect with time. Because the two groups likely have different baseline measurements, I need to include both random intercepts and random slopes.

Does this seem like the right formula?

outcome ~ subject + group*time + (1 + subject|time)

## Edit

Based on the comment below, is this right?

outcome ~ group*time + (1 + time | subject)

• If subjects have your repeated measurements within them, then subjects form the basis for your random effects. In that case you shouldn't list it as a fixed effect (as you do right after the "~") and it should be after the "|" symbol in the random term. Please edit the question to fix that, so that you can get better advice on the statistical issue of how/whether to use random slopes.
– EdM
Nov 15, 2022 at 21:51
• Re: your edit, yes, with the edited code you get fixed effects of group and time and their interaction, random intercept of subject and random slope of time for each subject, which seems like a reasonable model. Nov 16, 2022 at 9:14
• One thing to think about: Is subject labeled so that there aren't the same "subjects" in both groups ? That is, do you do not have "Subject 1" in Group 1 and Group 2 ? Nov 16, 2022 at 16:40
• @SalMangiafico -- yes. I'm very detailed about setting up tables. A column "subject" has the unique subject IDs. A column "group" has the group IDs. Nov 16, 2022 at 21:51