How to assess the fixed effect of age in a repeated-measures design with a linear mixed model

In my experiment I want to assess the effect of age on various response variables (all continuously distributed). The experiment is a repeated-measures design with 7 conditions (1 predictor variable with 7 levels). I also have some demographic variables for each subject, and tested whether they correlate with age. There are three demographic variables that correlate with age: d1, d2, and d3, and I want to include these variables in my model. Since we were unable to systematically manipulate age, I think it is important to try to control for any potentially confounding variables.

In a linear mixed-effect model, how do I account for the fact that:

• There are repeated measures for each subject. Doing (1 | subject) seems obvious here.
• The demographic information correlates with age (how do I regress this variable out of the model to look at just the effect of age?)

What I am thinking is to have two random effects terms, but I am not sure if this is the correct approach.

m1 <- lmer(response ~ age * condition +(d1, d2, d3 | age) + (1 | subject), data=data)


how do I account for the fact that:

There are repeated measures for each subject. Doing (1 | subject) seems obvious here.

Yes, that is correct.

the demographic information correlates with age (how do I regress this variable out of the model to look at just the effect of age?)

You would include these variables, along with age, as fixed effects. It does not make sense to include these as random slopes over age and it doesn't make sense to include age as a grouping variable for random intercepts, since age is your main exposure. The main thing to be aware of is to avoid including any mediators. For example if one of the variables is blood pressure and this also has a causal effect on the response, then it is a mediator and should excluded.

A more appropriat model would be:

response ~ age * condition + d1 + d2 + d3 + (1 | subject)

• Thank you! This is the second time you've helped me and I appreciate it so much. I will mark this as accepted as soon as I verify that it worked. Feb 10, 2021 at 18:55
• You're very welcome :) Feb 10, 2021 at 19:33