Treat the cluster mean of a predictor variable as a latent variable - hierarchical linear models

I trying to run a simple two-level MLM with a group-mean centered (cwc - centered within cluster) level-1 variable. As my clusters have relatively small size, the observed mean would not be reliable. It would be better to estimate the unobserved true group means and work with those.

I’m wondering if there is a reasonable way to do this in brms? I’ve seen some people (mostly working with lmer) do something like this:

Ultimately, one wants to fit

fit <- lmer(MATHACH ~ SEScwc, (1|ID), data=dat)

one first does

m <- lmer(SES ~ (1|ID), data=dat)

, uses the ranef() command to extract the random effect u0js, add that to the grand intercept (and call that the ‘empirical bayes estimate’ of the group-specific intercepts), and use that to make SEScwc, which can be fed into the first model.

I could do the same with brms using the Estimate.Intercept column returned by the same ranef() command, but my concern is that this procedure does not take into account our uncertainty in each of the estimated cluster means. Is there a way to work with latent group means in brms in a more integrated way? I’ve thought of using the me() option in brms, but can’t seem to figure out how I should do it. I would appreciate any form of advice, even brief ones.

Here is (a basic form) of one of the equations that I’m actually trying to estimate - I’m trying to estimate the latent cluster mean of a binary predictor X within the model.
CodeCogsEqn (2)
Priors omitted

If I’m reading this correctly I think you can just estimate these things directly instead of doing a two-stage inference.

Check out the non-linear models here: Estimating Non-Linear Models with brms (this allows you to have little sub-models for your parameters).

1 Like

Thanks a lot! It might take me some time to figure how to use it in my case, but that does appear to be the right way to go. I’ll post what I did if I succeed so that others can see it. With all the recent emphasis on latent mean centering, I think many people might be interested in how to do this in R.

BTW, there is a related post here Modeling latent means in brms for multilevel group mean centering

1 Like

Cool thanks! It is super useful to have answers make their way back!

1 Like

Hi @Tay, just wondering if you were able to make this work?

Hi Matti,

Unfortunately, no. I tried for a while but decided to just use a convenience software instead (not Bayesian tho). I used MPlus, which is a paid software and of which authors were one of the first to come up with this method. Sorry this was not a satisfactory answer - I also tried to do it with Stan but eventually just took the easier path.

Hi Tay, thanks for the reply! Yeah that makes sense.

I’ve been copying this approach: Bayesian MLM With Group Mean Centering | Mark Lai and almost have it working (I think :)) for my application. Once I have that going I’m going to try to see if I can hack it in brms.

Cheers.