Model comparison for mediation in brms

I would like to compare models for:

  1. The direct effect of X on Y.
  2. The effect of X on Y, mediated by M.
  3. The effect of X on Y, mediated by M, where this mediation is fully moderated by another variable Z.

I would fit these three models using the following syntax:

  1. brm(Y ~ X)
  2. brm(bf(Y ~ X + M) + bf(M ~ X) + set_rescor(FALSE))
  3. brm(bf(Y ~ X*Z + M*Z) + bf(M ~ X*Z) + set_rescor(FALSE)).

However, when comparing these models with compare_ic(), brms complains (rightly) that:

Warning message: Model comparisons are likely invalid as the response values of at least two models do not match.

This is because Model 1 does not include M.

To remedy this problem, should I simply refit Model 1 as brm(bf(Y ~ X) + bf(M ~ 1) + set_rescor(FALSE)? These two model parts will be estimated separately from one another.

Thanks in advance for your help (and for the amazing package)!

Please use the Interfaces - brms tag for brms related questions otherwise they will likely remain overlooked.

(I have changed in manually this time).

With regard to your problem you can select the responses used in the post-processing via the resp argument.

Apologies for the tagging oversight (first time poster here). I’ll try this resp solution out Paul, thanks very much!