Modeling latent means in brms for multilevel group mean centering

Oh, I see. Then maybe using the non-linear model syntax (https://cran.r-project.org/web/packages/brms/vignettes/brms_nonlinear.html) should let you have something like (not tested):

bf(
y ~ 1 + b1 * (x - mean_x) + b2 * mean_x + (1 | cluster),
mean_x ~ cluster,
b1 + b2  ~ 1,
nl = TRUE
)

(note that the model coefficients become explicit in non-linear syntax)
I am short on time, so I hope I didn’t mess up, but I think it should work (please consult the linked vignette to make sure you follow this and can double check that I am correct - I do make quite a lot of mistakes.

Best of luck!

EDIT: The above does not tie mean_x to actual x in any way, so you might want to add a line like

x ~ mean_x
2 Likes