Mixed Model – How to Specify Uncorrelated Random Slopes in lmer() Syntax

lme4-nlmemixed modelrandom-effects-model

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 and M, this should decrease the number of parameters overall. As in the following example:

require(lme4)

# use data with two within variables:
data(obk.long, package = "afex")

# the full model
m1 <- lmer(value ~ phase + hour + (phase + hour|id), data = obk.long)
print(m1, corr = FALSE)
# has correlations between the slopes.

# the alternative model with two intercepts:
m2 <- lmer(value ~ phase + hour + (hour|id) + (phase|id), data = obk.long)
print(m2, corr = FALSE)
# has no correlations between the slopes but two intercepts:

# m2 has overall less parameters (29 vs 36):
anova(m1, m2)
Related Question