4
$\begingroup$

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

$\endgroup$

1 Answer 1

5
$\begingroup$

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")
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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