How can I visualize a mixed model with random slopes for a variable but no fixed effect for that variable in a simple model such as y ~ 1 + (var | subject)
?
1 Answer
$\begingroup$
$\endgroup$
0
I guess in this case you would like to depict the heterogeneity in the estimated slopes per subject. Then, you could extract the subject-specific intercepts and slopes using function coef()
, and make the plot. The following code illustrates how this could be done with a linear mixed fitted in R using lmer()
from package lme4:
library("lme4")
fm <- lmer(Reaction ~ 1 + (Days | Subject), sleepstudy)
matplot(c(0, 1), t(data.matrix(coef(fm)$Subject)), type = "l", lty = 1,
xlab = "Days", ylab = "Reaction")