Specifying level 2 model


#1

Hi all,

I’m trying to shift from writing Stan code to using brms for more of my modeling. I’ve hit a snag trying to specify the functional form of the level 2 model. This feels like a very basic question.

Let’s take a very simple case:
y ~ N(b0 + b1 * x, sigma_y)
b0 ~ N(g00 + g01 * w, sigma_b0)
b1 ~ N(g10 + g11 * w, sigma_b1)

If the level 2 groups are defined by z, how would I pass these formulas to brms?

My understanding is that brm(y ~ x + (1 + x|z), …) corresponds to the formulas:
y ~ N(b0 + b1 * x, sigma_y)
b0 ~ N(b0_mean, sigma_b0)
b1 ~ N(b1_mean, sigma_b1)

  • Operating System: (Various, but primarily Linux)
  • brms Version: 2.4.0

#2

y ~ 1 + x * w + (1 + x | z)

This is the result for plugging in g00 + g01 * w for b0 and similar for b1.