Hi,
I am setting up a multivariate model in brms. There are two response variables, y1
and y2
, and three groups g1, g2, g3
in the data (fake data code at the bottom of the topic). I would like to model the rescor(y1, y2)
and also model the correlation between every combination of response variables between groups, such as same response different groups: cor(y1_groupg1, y1_groupg2)
, and different response, same group: cor(y1_groupg1, y2_groupg1)
etc. I can’t figure out a direct way to do this, but I found a work-around that produces the outputs that I want. I created a dummy variable dum_v
with only one level Q
and set up the model like this:
m1 <- brm(data = toy_dat,
family = student,
formula = bf( y1 ~ 0 + (0 + group | i | dum_v)) +
bf( y2 ~ 0 + (0 + group | i | dum_v)) +
set_rescor(TRUE))
This method appears to be working, but I may be making some big mistake that I am not aware of. Before I spend more time on this I definitely want to check with the experts to see if this is ok, or if there is a more direct way of producing the same outputs.
Thank you in advance!
- Operating System: OSX
- brms Version: 2.14
Toy data
set.seed(6)
n = 50
toy_dat =
tibble(
group = rep(c("g1", "g2", "g3"), times = c(30, 15, 5)),
y1 = rnorm(50,
c(0.3, 0.3, 2, 2, 1, 1),
c(0.1, 0.3, 0.6, 0.2, 0.3, 0.3)),
y2 = rnorm(50, 0.5 * exp(y1), 1),
dum_v = rep("Q", 50))