Brms and heterogeneous residual covariance - equivalent of "at.level" function

  • Operating System: Mac-OS
  • brms Version: 2.6

Hi there,

I was wondering if there is any equivalent of the at.level function in brms, or in Stan? This function is handy for multivariate hierarchical models, in which the residual covariance should be estimated for some (but not all) combinations of variables. Basically I want to do a model like in which I estimate the residual covariance between a pair of male traits, and a pair of female traits, but not between male and female traits (since individual in my dataset never have a mixture of male and female traits, so I’d like to fix the residual covariance to zero and “tell” brms not to estimate it).

I wrote a full post, with some reproducible code, when I asked the same question on SO in reference to another R package called sommer that is used for (frequentist) mixed modelling:

Hope that makes sense, please let me know if now.

Many thanks,


1 Like

Currently, the residual correlation matrix in brms needs to be either fully estimated, set_rescor(TRUE), or completely set to zero, set_rescor(FALSE). This will be made more flexible in brms 3.0 which definitely won’t be ready within the next few months.

@paul.buerkner, is this still the case for the current version of brms (2.13.5)? I have a single level model with two predictors, x1 and x2. One predictor has some missing data, which I’d like to handle with a residual covariance between it and the other predictor. But I do not want the response variable y to share a residual covariance with either of the predictors. I was hoping to get away with something like the code below, but the outermost rescor statement seems to override the inner one.

bf_x1 <- bf(x1 ~ 1)
bf_x2 <- bf(x2 | mi() ~ 1)

bf_y <- bf(y ~ 1 + x1 + mi(x2))

mvbf(bf_y, mvbf(bf_x1, bf_x2, rescor = TRUE), rescor = FALSE)