Multivariate mixtures in brms

Hi folks,

I’m having a lot of trouble setting up a multivariate mixture model in brms. Here’s a simple example:

dat <- data.frame(
  x = c(rnorm(200), rnorm(100, -6)), 
  y = c(rnorm(200), rnorm(100, 6))

fit1 <- brm(mvbind(x,y) ~ 1, dat, 
family = mixture(gaussian,gaussian),
chains = 2,rescor=T,
    prior(normal(0, 7),class = "Intercept",resp = "x",dpar = "mu1"),
    prior(normal(-5, 7),class = "Intercept",resp = "x",dpar = "mu2"),
    prior(normal(0, 7),class = "Intercept",resp = "y",dpar = "mu1"),
    prior(normal(5, 7),class = "Intercept",resp = "y",dpar = "mu2"))) 

This throws the following error message:

Error in get(paste0(".family_", x)) : object '.family_mixture' not found

I’m using brms version 2.13.5 in R version 4.0.2 on OS X 10.13.6 High Sierra.


Nice reproducible example. I confim that I can reproduce the issue on my side. I think you should report this as a bug at , also tagging @paul.buerkner.

Unfortunately, I couldn’t find a quick workaround.

Thanks for checking, Martin!

I think brms may not yet support multivariate mixtures and this is simply the lack of an appropriate error message.

I hope it does soon, though - despite issues with identifiability in these models, brms is a fantastic package for mixtures in STAN, thanks to the helper functions like pp_mixture().

I investigated the issue and it turns out brms did not check correctly whether residual correlations are allowed for this model. In fact, due to the mixture, residual correlations cannot be modeled but this was not captured correctly by the checks. In the latest github version of brms, rescor will now automatically be set to FALSE for this model and an attempt to set it to TRUE will fail with an informative error message.

1 Like