I’m currently modelling a multilevel mediation model. That is, I was wondering if it is possible to model a residual that differs by levels of a grouping variable?
How do you model a residual that differs by levels of a grouping variable that is not the clustering variable
To me it sounds like this might be what you are looking for:
y ~ 1 + (x1 | group) This gives you a varing slope per group.
(1 | group) would give you a varying intercept per group.
Yes, this is true. That is, it does not give me a varying residual variance per group. Also, the grouping variable does not necessarily have to be the clustering variable of my model.
You can do with within the distributional modeling framework. Here’s a quick example:
bf(y ~ 1 + (x1 |a| group), sigma ~ 1 + (x1 |a| group))
This is also what some have called the MELSM approach. See https://twitter.com/SolomonKurz/status/1337773792588918787