Possible to model mixed families with set_rescor(TRUE)?

I’ve previously used a brms multivariate model with set_rescor(TRUE) to model 4 different methods to measure a clinical feature. These metrics all produced continuous data and were all modelled as gaussian. If these metrics are in anyway valid, they should be heavily correlated within individuals → so in this setting set_rescor makes a big difference to the model fit. And indeed this is what we see fitting the 4 outcome model with or without set_rescor

Now, we wish to also include a fifth outcome that is not gaussian - rather I’m using the zero_inflated_binomial family here (it’s a clinical scoring system). However, brms doesn’t allow currently allow set_rescor(TRUE) for such a model giving the error:

"Error: Currently, estimating 'rescor' is only possible in multivariate gaussian or student models."

This presents a problem because in order to add the extra outcome I have to lose the modelling of residual correlation, thus deviating from our preferred model of the 4 metrics.

Is there any way to use set_rescor(TRUE) for mixed families or for a subset of outcomes coming soon?

I do not believe so, but there is active development on copulas in brms (see the github page), which might facilitate what you’re after in a future release.

I found this which sounds exactly my problem: more flexible residual correlation structures in multivariate models · Issue #957 · paul-buerkner/brms · GitHub - but this is from 2 years ago now. Is brms 3.0 imminent by any chance?

brms 3.0 still needs at least a couple of months.

4 Likes

My current dev branch of brms with copula support can be installed using:

devtools::install_github("andrjohns/brms@gaussian-copula")

With example usage:

mn <- bf(y1 ~ 1, family = gaussian())
mp <- bf(c ~ 1, family = poisson())
mn2 <- bf(y2 ~ 1, family = gaussian())
mb <- bf(n | trials(d) ~ 1, family = binomial())
mod_n <- mn + mp + mn2 + mb + set_rescor(rescor = TRUE, copula = "gaussian")

t_n <- brm(mod_n, data = bdata, cores = 4)

However, this is only tested so far with Gaussian, bernoulli, binomial, and poisson outcomes in very simple models, so it’s likely to have issues with syntax generation for more complex models and/or other families.

Additionally, outcome families can only be supported if they have a CDF function defined in the Math library (I’m also planning to add the functionality for users to specify the CDFs themselves, but that’s still a ways off)

2 Likes

@andrjohns I’ll take a look at the dev branch, but seems like it won’t solve my issue for now since I’m using zero_inflated_binomial

I may have to look at the stancode for my models and see if I can figure out an case specific extension myself I guess.

Thanks all for the answers.

@andrjohns I’ll take a look at the dev branch, but seems like it won’t solve my issue for now since I’m using zero_inflated_binomial

Ah no, without a CDF function for the zero-inflated binomial, this copula code won’t be applicable for you at all unfortunately

1 Like

Thanks @andrjohns!

… and nope this is way to hard for me 😅

An alternative here could be to use a random-effects to model the dependence of outcomes within individuals.

I put together an example approach a while back for modelling correlated binary and count data with brms, I’ve just made a gist with the details here: CorrelatedDiscrete.md · GitHub

Hopefully something in there is helpful!

2 Likes

Ok thanks @andrjohns, I will take a look!

Hi there - sorry to reopen an old thread, but I wondered if this dev branch of brms should still have this functionality with copulas? Am trying to solve this exact problem, but couldn’t find the appropriate functions on GitHub…

1 Like