# How to specify slope by several fixed effects to a random effect in mixed effects regression in R's lme4?

In the past I have seen regression models with random effect slopes by one fixed effect, for example:

mod = lmer(y ~ x1 + x2 + x3 + (x1|rand1) + (x1|rand2), data = dat, REML=FALSE)


Is it possible to add a slope by several fixed effects (e.g. x1, x2, and x3) to a random effect in mixed effects regression in R's lme4? If, so how? What would the syntax look like?

EDIT

To make the question more specific, let me include a specific example from a data set I am using. Doing some exploratory plotting and analysis, I plotted the Kendall correlations between the three fixed variables.

As you can see in the plots, the correlations are very high, which would seem to justify including interactions between then in my mixed effects model. Specifically, there is a linear relationship between x1 and x3, and a quadratic relationship between x1 and x2, and x2 and x3. The correlations seem to suggest that I should acknowledge the dependence of the variables when I specify the slope for the two random effects. What is the most appropriate way to specify this in lme4?

• Are you asking about (x1|rand1)+(x2|rand1)? Yes, this is possible. Nov 22, 2017 at 21:19
• Sure, but are the variables dependent or independent in this syntax? Why not (1 + x1| rand1) or (x1 - 1|rand1)? There are different theoretical motivations for these choices, but I just don't know what they mean and I'd was hoping someone would address that in their answer. Nov 22, 2017 at 21:58