2
$\begingroup$

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$?

$\endgroup$
  • 3
    $\begingroup$ Perhaps lmer(Y ~ X + M + (1+X|Subject) + (0+M|Subject), data=mydata) $\endgroup$ – Affine Jun 18 '13 at 16:42
  • $\begingroup$ Almost, but now the random M slope is uncorrelated with the random subject intercept. Only the two slopes should be uncorrelated. All other correlations are allowed. $\endgroup$ – Ben M. Jun 18 '13 at 22:05
  • $\begingroup$ The solution is given here: stackoverflow.com/a/35401176 $\endgroup$ – amoeba says Reinstate Monica Jan 11 '18 at 9:49
6
$\begingroup$

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)
$\endgroup$
-1
$\begingroup$

I realize this is an old question, but does || address your issue?

model <- lmer(Y ~ X + M + (1+X+M||Subject), data=mydata)
$\endgroup$
  • $\begingroup$ This does not achieve what OP was asking about. $\endgroup$ – amoeba says Reinstate Monica Dec 21 '17 at 22:38
  • $\begingroup$ Where does it fall short? $\endgroup$ – Adam_G Dec 22 '17 at 2:13
  • $\begingroup$ "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." If you think your syntax achieves this then please explain how. $\endgroup$ – amoeba says Reinstate Monica Dec 22 '17 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.