Multivariate multilevel model with duplicated DV

For a research question, I would like to look at correlations between random slopes of various IVs in the prediction of various DVs. For different DVs, this works well using a multivariate multilevel model in brms. For instance, the correlation between the random slopes for IV1 -> DV1 and IV1 -> DV2 can easily be estimated:

brm(
bf(DV1~IV1+(1+IV1|cor|id)) +
bf(DV2~IV1+(1+IV1|cor|id)))

For identical DVs however, the problem is that I would like bivariate associations and not partial effect sizes. Thus, I would like to obtain the correlation between random slopes for IV1 -> DV1 and IV2 -> DV1, but without controlling for the respective other IV in each model.
I.e., I do not want: brm(DV1 ~ IV1+IV2+(1+IV1+IV2|id))

I tried to implement this by simply copying the DV and including it twice in the multivariate model. However, this results in warnings, divergences, and residual covariances estimated as 1.

brm(
bf(DV1~IV1+(1+IV1|cor|id)) +
bf(DV1~IV2+(1+IV2|cor|id)))

Is there a way to specify this model such that it works?

Morning! Can you post the model code, priors (if you set them), errors, and a subset of the data? All those things will be helpful in figuring out what’s going on.

1 Like

Morning! I’m not sure the model is actually supposed to run, so it’s also a conceptual question. For instance, if I just use the same DV twice (instead of an exact copy), a warning is issued that that is not possible.

I’m attaching simulated data, which I analyzed with this code:

brm(
bf(y~x1+(1+x1|cor|id)) +
bf(y2~x2+(1+x2|cor|id)),
data=dat,chains=4,cores=4,iter=1000)

I got rhats in the thousands and these warnings:

Warnmeldungen:
1: There were 420 divergent transitions after warmup. Increasing adapt_delta above 0.8 may help. See
http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
2: There were 1580 transitions after warmup that exceeded the maximum treedepth. Increase max_treedepth above 10. See
http://mc-stan.org/misc/warnings.html#maximum-treedepth-exceeded
3: There were 3 chains where the estimated Bayesian Fraction of Missing Information was low. See
http://mc-stan.org/misc/warnings.html#bfmi-low
4: Examine the pairs() plot to diagnose sampling problems

5: The model has not converged (some Rhats are > 1.1). Do not analyse the results!
We recommend running more iterations and/or setting stronger priors.
6: There were 420 divergent transitions after warmup. Increasing adapt_delta above 0.8 may help.
See http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup

multivariate.txt (39.2 KB)

1 Like

I believe brms estimates residual correlations in multivariate gaussian models by default. Since you are using the same outcome variable in the two formulas, that will cause problems. Try wrapping your model formulas in mvbf(..., rescor = FALSE).

To make it easier to help you further, could you please attach the code that generates the simulated data, instead of a data file? Also, you should wrap your code in three backticks to make it easier to look at your code examples:

```
x <- 1
```

Hope that helps!

3 Likes