[R-sig-ME] lmer code for multiple random slopes
Peter R Law
pr|db @end|ng |rom protonm@||@com
Tue Feb 16 04:02:07 CET 2021
I am trying to fit a model with two covariates, x and z say, for response y, with a random factor g and want each of x and y to have a random slope. I expected
lmer(y ~ x + z + (x+z|g),...)
to fit a model with 6 random variance components, the intercept, two slopes and three correlations. But I got an error message saying there were 74 random variance components and my data was insufficient to fit the model. Yet
lmer(y ~ x + z + (x+z||g),...)
returned what I expected, a model with the random intercept and two slopes but no correlations. How is lmer interpreting the first line of code above and how I would code for what I want. I have not been able to find any examples in the literature or online that help me but I may have easily missed something so if anyone knows of a useful link that'd be great. The only examples of multiple random slopes I've seen take the form
lmer(y~x + z +(x|g) + (z|g),...)
specifically excluding correlations between the random slopes and intercept of the two predictors. Even if the latter is a more sensible approach I'd like to understand the coding issue.
Sent with [ProtonMail](https://protonmail.com) Secure Email.
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models