I have four variables that are all level 1 variables in a multilevel model. I am trying to execute moderated multilevel mediation in R, using the brms package. The moderator (Mod) is a categorical two-level variable at level 1. All three of the other variables (Pred, Med, and Resp) are continuous.
I have been trying to write it but I don’t think I am doing it correctly. Can someone help explain how to effectively write a two-group moderated multilevel mediation in brms?
Among the things I am confused about:
- When to use bf() versus brm() and why sometimes people have bf() inside of brms()
- Why some versions I have seen of doing mediation in brms use set_rescor(FALSE)
I have found this page and this page that seem to have accurate descriptions for how to do mediation and multilevel mediation in brms but I wasn’t sure about two group moderated multilevel mediation in brms.
Right now I have:
brm_M_0 <- brm(Resp ~ Pred + (Pred | subID), medDf, family = gaussian())
brm_M_M <- brm(Med ~ Resp + (Resp | subID), medDf, family = gaussian())
brm_M_Y <- brm(Resp ~ Pred + Med + (Pred + Med | subID), medDf, family = gaussian())
But how do I incorporate a categorical two-level moderator into this? And how do I make it into a moderated multilevel mediation? I’m pretty stumped. Thank you so much for any help!