Model formula for Multilevel Model where different sets of predictors are used for random intercept and random slope

Hi, my question will be a more general question regarding the model formula. I have been searching for many web sources just to try to get any information on this issue. I am working on a two-level multilevel model.

Problem Background

In level one, I have one response variable with one predictor variable. Therefore, I have one intercept and one slope coefficient at this level.
In level two, I have one model that predicts the level-one intercept and another model that predicts the level-one slope. In my study, I will be using different predictors in both level-two models. Nearly all tutorials in the internet and the books I have read assume the same level-two predictors are being used to predict the level-one intercept and level-one slope.

Level One Model

y_{ij} = \beta_{0j} + \beta_{1j}\cdot x_{ij} + \varepsilon_{ij}

Level Two Model

\beta_{0j} = \gamma_{00} + \gamma_{01}\cdot z_j + u_{0j}
\beta_{1j} = \gamma_{10} + \gamma_{11} \cdot k_j + u_{1j}

Question

How should I specify my model in r? (Packages in use: lmerTest, blmer, and brms. They all use the same model formulation)

What I Know

Null Model: This is simple. I think I have done it correctly.

y ~ (1 | j)

Random Intercept Model: I am pretty sure this is correct too. x will be a fixed effect predictor and this only allows the incept to be varying across the different groups.

y ~ x + (1 | j)

What I Don’t Know

How do I make a formula for random intercept and random slope and beyond? I know that when you have the same level-two predictors for both the intercept and the slope, it is

y ~ x + (z | j)

But to my understanding, this assumes z to be the level-two predictor of both Level-one intercept and slope. How do I formulate my model when the level-two predictors for level-one intercept and slope are different? I hope my question makes sense to everybody.

Note:

Please let me know what I should do to make the question clearer to you. I have recently been experimenting with brms package for a thorny model estimation issue. Thank you.

For the full model, I believe you want this: y ~ 1 + x + z + x:k + (1 + x | j)

1 Like

Dear Solomon, I was super busy lately… I will try asap and will let you know. Do you know if any thoroughly written reference in this topic? I haven’t used x:k , but I assume it is the same with x * k ? Thank yo so much!

The : and * are similar, yet distinct. Try them both out with a simplified version of your model with just the lm() function. You’ll see.