I am currently fitting a mixed effects model to some experimental data as follows:
model <- lmer(Y ~ X + M + (1+X+M|Subject), data=mydata)
The meaning of the variables is not so important here, but $X$ is the predictor of interest while $M$ is a (suspected) mediating variable. All variables are continuous and measured within-subjects. Now the question concerns the random slopes in this model. The above syntax specifies fully correlated random effects. However, I would like to remove the correlation between the two random slopes ($X$ and $M$) without removing the correlation between the random slopes and the random intercept.
Initially, I attempted the following code:
model <- lmer(Y ~ X + M + (1+X|Subject) + (1+M|Subject), data=mydata)
This does produce uncorrelated random slopes but lmer() now estimates a random subject intercept both for $X$ and $M$. I am not sure this is correct (or what I require), because I am now forced to introduce an extra variance parameter (simply for removing another one). Is there any way to specify a single subject intercept and uncorrelated random slopes for $X$ and $M$?
Best Answer
I think what you want is not directly achievable. The best seems to be your second option (i.e., two random intercepts but no slopes).
Depending on the number of levels in
X
andM
, this should decrease the number of parameters overall. As in the following example: