# Stan\_mvmer for seemingly unrelated regressions?

**URL:** <https://discourse.mc-stan.org/t/stan-mvmer-for-seemingly-unrelated-regressions/3927>\
**Category:** rstanarm\
**Created:** [April 19, 2018, 6:17pm UTC](https://discourse.mc-stan.org/t/stan-mvmer-for-seemingly-unrelated-regressions/3927 "2018-04-19T18:17:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremy.koster](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jeremy.koster/32/5756_2.png) [@jeremy.koster](https://discourse.mc-stan.org/u/jeremy.koster)\
**Post date:** [April 19, 2018, 6:17pm UTC](https://discourse.mc-stan.org/t/stan-mvmer-for-seemingly-unrelated-regressions/3927/1 "2018-04-19T18:17:49Z")

</div>

I am creating a gentle introduction to seemingly unrelated regression (SUR) models for a class of novices. I was looking into rstanarm’s function for multivariate outcomes, **stan\_mvmer**. However, it seems that that this function does not model the correlation between the residuals. Is that right? (Although I think it would be a useful exercise for students to calculate residuals and correlations themselves, that’s probably too much for a first class session.)

If not rstanarm, are there other recent scripts for multivariate outcomes? My inclination is to start with convenience packages like rstanarm, if possible. But the class will have some familiarity with stand-alone Stan models by this point, so working with Stan models directly is also an option, if necessary.

- Operating System: Mac OS
- rstanarm Version: 2.17.2

---

<div class="post-metadata">

**Author:** ![tjmahr](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/tjmahr/32/357_2.png) [@tjmahr](https://discourse.mc-stan.org/u/tjmahr)\
**Post date:** [April 19, 2018, 6:55pm UTC](https://discourse.mc-stan.org/t/stan-mvmer-for-seemingly-unrelated-regressions/3927/2 "2018-04-19T18:55:11Z")

</div>

I have used brms to do multivariate models. There is a vignette on it. [https://cran.r-project.org/web/packages/brms/vignettes/brms\_multivariate.html](https://cran.r-project.org/web/packages/brms/vignettes/brms_multivariate.html)

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [April 19, 2018, 8:12pm UTC](https://discourse.mc-stan.org/t/stan-mvmer-for-seemingly-unrelated-regressions/3927/3 "2018-04-19T20:12:32Z")

</div>

Here’s a related thread about what’s not currently implemented in `stan_mvmer`:

> [@Stan\_mvmer with shared parameters for sub-models?](http://discourse.mc-stan.org/t/stan-mvmer-with-shared-parameters-for-sub-models/3873/3):
>
> No, unfortunately not. At the moment stan\_mvmer only allows for group-level parameters that are correlated across submodels, but not that are common or shared across submodels. In any case, only the group-level parameters are correlated in stan\_mvmer, and not the population-level parameters or residual errors. Hence, I chose to call it stan\_mvmer, and not stan\_mvglm. I think there is probably a demand for some type of stan\_mvglm function that works with correlated errors or multivariate outcome…

Like @tjmahr said, brms has a bunch of stuff you can do with multivariate outcomes. It doesn’t do everything that @sambrilleman did with stan\_jm and stan\_mvmer in rstanarm, but it also does some things that can’t be done with those rstanarm functions.

---

<div class="post-metadata">

**Author:** ![ermeel](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ermeel/32/4180_2.png) [@ermeel](https://discourse.mc-stan.org/u/ermeel)\
**Post date:** [April 19, 2018, 8:57pm UTC](https://discourse.mc-stan.org/t/stan-mvmer-for-seemingly-unrelated-regressions/3927/4 "2018-04-19T20:57:18Z")

</div>

Actually I find the example Stan code listed in section 9.15. of the current manual version also not that complicated and well suited for educative purposes. So why not use it (you might skip the LKJ part for the sake of clarity)?

In addition to that you might also want to look at @ericnovik’s great blog post [Correlation or no correlation, that is the question](https://www.generable.com/blog/2018/02/correlation-or-no-correlation-that-is-the-question/) which actually also uses SUR. I learned LKJ and SUR from this.
