# Brms: multivariate response, different distributions

**URL:** <https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939>\
**Category:** brms\
**Created:** [July 22, 2018, 9:18pm UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939 "2018-07-22T21:18:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![idopen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/idopen/32/2821_2.png) [@idopen](https://discourse.mc-stan.org/u/idopen)\
**Post date:** [July 22, 2018, 9:18pm UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/1 "2018-07-22T21:18:47Z")

</div>

I am interested in modelling survival (0/1) and reproduction (# offspring 0…3) as a multivariate response, combining Bernoulli with (truncated) Poisson distributions. Is it possible to do this with brms?

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [July 23, 2018, 6:30am UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/2 "2018-07-23T06:30:18Z")

</div>

A model could look a follows:

```
bform <- bf(survival ~ ..., family = bernoulli()) +
  bf(offspring | trunc(<value>) ~ ..., family = poisson())

fit <- brm(bform, ...)

```

However, without correlated multilevel structure on the right-hand side of the model formulas, this model will just be equivalent to two univariate ones.

---

<div class="post-metadata">

**Author:** ![idopen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/idopen/32/2821_2.png) [@idopen](https://discourse.mc-stan.org/u/idopen)\
**Post date:** [July 23, 2018, 7:23am UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/3 "2018-07-23T07:23:33Z")

</div>

Thanks Paul. Is it possible to add a correlated multilevel structure on the rhs? Specifically, I want to model correlated year-effects to both survival and offspring. So, if I would add +(1|p|year) to both formulas, would a bivariate normal be estimated?

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [July 23, 2018, 8:39am UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/4 "2018-07-23T08:39:27Z")

</div>

Exactly.

---

<div class="post-metadata">

**Author:** ![idopen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/idopen/32/2821_2.png) [@idopen](https://discourse.mc-stan.org/u/idopen)\
**Post date:** [July 23, 2018, 9:05am UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/5 "2018-07-23T09:05:56Z")

</div>

Great, thanks! Is it also possible to model the correlated year-effects as multivariate t-distributed or multivariate skew-normal rather than “ordinary” multivariate normal?

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [July 23, 2018, 9:12am UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/6 "2018-07-23T09:12:19Z")

</div>

Student-t is possible albeit not documented and not yet officially supported until we better understand its implications. Go for `(1 |p| gr(year, dist = "student"))`.

---

<div class="post-metadata">

**Author:** ![idopen](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/idopen/32/2821_2.png) [@idopen](https://discourse.mc-stan.org/u/idopen)\
**Post date:** [July 23, 2018, 11:00am UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/7 "2018-07-23T11:00:40Z")

</div>

Thanks again. I will give the multivariate t a try because I have the impression that the year-effect empirical distribution has “fat tails”.

One more thing: when using the predict function, is it possible to marginalize/integrate over the “random” year effects, in order to obtain expected survival and offspring number?

BTW: thanks for creating bmrs. It looks like an enormously useful package that will save me a lot of Stan coding.

---

<div class="post-metadata">

**Author:** ![paul.buerkner](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/paul.buerkner/32/3303_2.png) [@paul.buerkner](https://discourse.mc-stan.org/u/paul.buerkner)\
**Post date:** [July 23, 2018, 11:10am UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/8 "2018-07-23T11:10:15Z")

</div>

You can ignore random effects via `re_formula = NA` but marginalizing is a much more difficult thing (read: not yet possible).

---

<div class="post-metadata">

**Author:** ![sss203](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@sss203](https://discourse.mc-stan.org/u/sss203)\
**Post date:** [July 29, 2020, 3:30pm UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/9 "2020-07-29T15:30:47Z")

</div>

I have used the make\_stancode call to generate two Stan files (below). One is with a Gaussian distribution for the random effects, and the second is using the gr() function to obtain Student-t distributed varying effects (as noted above by Paul). I have added the model specification at the top of the files for reference.

Could someone highlight where exactly in the Stan code the t-distribution is being specified on the random effects? I see a definition of a df variable and the priors for this variable, but it is not clear where exactly the change is specified.

Thank you!

[ND\_distrib.stan](https://discourse.mc-stan.org/uploads/short-url/2ef0jzedF4pH7FybFcx5ft6cXFs.stan) (3.1 KB) [t\_distrib.stan](https://discourse.mc-stan.org/uploads/short-url/16KqXFGjzYJcfn9oGheNf0lHOD1.stan) (3.2 KB)

---

<div class="post-metadata">

**Author:** ![lldb14](https://avatars.discourse-cdn.com/v4/letter/l/f19dbf/32.png) [@lldb14](https://discourse.mc-stan.org/u/lldb14)\
**Post date:** [July 23, 2025, 1:56pm UTC](https://discourse.mc-stan.org/t/brms-multivariate-response-different-distributions/4939/10 "2025-07-23T13:56:18Z")

</div>

Does anyone know of a good reference for consulting on these multivariate models with different distributions? Thank you very much
