# Setting priors for multinomial regression in brms

**URL:** <https://discourse.mc-stan.org/t/setting-priors-for-multinomial-regression-in-brms/15911>\
**Category:** Modeling\
**Tags:** multinomial-response, prior-choice\
**Created:** [June 13, 2020, 10:52am UTC](https://discourse.mc-stan.org/t/setting-priors-for-multinomial-regression-in-brms/15911 "2020-06-13T10:52:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![filippogambarota](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/filippogambarota/32/8163_2.png) [@filippogambarota](https://discourse.mc-stan.org/u/filippogambarota)\
**Post date:** [June 13, 2020, 10:52am UTC](https://discourse.mc-stan.org/t/setting-priors-for-multinomial-regression-in-brms/15911/1 "2020-06-13T10:52:22Z")

</div>

Hi, I’m new to bayesian modelling and `brms` so maybe my question is trivial. However, I’m fitting a multinomial regression using `brms`. The response variable `response` is modeled as a function of a binary factor `GROUP` and then a random intercept for subjects `1|ID`. This is my model:

```
fit <- brm(response ~ GROUP + (1|ID),
                  cores = n_cores,
                  family = categorical(link = "logit"),
                  data = data_exp1,
                  chains = 6,
                  iter = 4000,
                  warmup = 2000,
                  control = list(adapt_delta = 0.999,
                                 max_treedepth = 15))

```

The `control` parameters were set according to some warnings about the model (following this [https://mc-stan.org/misc/warnings](https://mc-stan.org/misc/warnings)).  
This model works fine but the compilation time is very long (30 minutes) so I’ve read about putting slightly informative priors according to my parameters.

This is the prior summary (with default priors):

```
prior_summary(fit)
                 prior class coef group resp dpar nlpar bound
1 b mudisgust            
2 b GROUPIMS mudisgust            
3 b mufear            
4 b GROUPIMS mufear            
5 b musadness            
6 b GROUPIMS musadness            
7 b musurprise            
8 b GROUPIMS musurprise            
9 student_t(3, 0, 10) Intercept mudisgust            
10 student_t(3, 0, 10) Intercept mufear            
11 student_t(3, 0, 10) Intercept musadness            
12 student_t(3, 0, 10) Intercept musurprise            
13 student_t(3, 0, 10) sd mudisgust            
14 student_t(3, 0, 10) sd mufear            
15 student_t(3, 0, 10) sd musadness            
16 student_t(3, 0, 10) sd musurprise            
17 sd ID mudisgust            
18 sd Intercept ID mudisgust            
19 sd ID mufear            
20 sd Intercept ID mufear            
21 sd ID musadness            
22 sd Intercept ID musadness            
23 sd ID musurprise            
24 sd Intercept ID musurprise            

```

Given that my fixed effects are all **odds ratio** in log scale a reasonable prior might be a normal distribution with `mean = 0` and a broad `SD`.

```
fixef(fit)
                       Estimate Est.Error Q2.5 Q97.5
mudisgust_Intercept 1.3054715 0.4063684 0.5105506 2.1279143
mufear_Intercept 2.7147141 0.3380190 2.0931628 3.4193736
musadness_Intercept 0.6062926 0.4717226 -0.3891898 1.5063598
musurprise_Intercept 1.0915517 0.4007677 0.2983177 1.8751994
mudisgust_GROUPIMS 0.2545814 0.6390059 -0.9781262 1.5333117
mufear_GROUPIMS -0.6974617 0.5408466 -1.7542061 0.3734919
musadness_GROUPIMS -1.2186215 0.8067931 -2.8796989 0.3203030
musurprise_GROUPIMS -0.4853391 0.6435296 -1.7527883 0.7877122

```

I’ve set my priors but a warning message appears during the fitting about the deprecated usage of a global priors on all beta parameters and this could bring to unexpected results.

```
mod_prior = c(prior_string("normal(0, 10)", class = "b"),
              prior_string("normal(0, 10)", class = "Intercept"))

```

Given that I would like to simply speed my fitting time what could I do?

---

<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:** [June 14, 2020, 9:36am UTC](https://discourse.mc-stan.org/t/setting-priors-for-multinomial-regression-in-brms/15911/2 "2020-06-14T09:36:31Z")

</div>

You could set the SD of the normal distribution smaller (to 3 or 2.5 say) but I doubt this will speed up the computation much.

---

<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:** [June 14, 2020, 9:37am UTC](https://discourse.mc-stan.org/t/setting-priors-for-multinomial-regression-in-brms/15911/3 "2020-06-14T09:37:25Z")

</div>

What could also help, is that you also set more narrower priors on the `sd` parameters.

---

<div class="post-metadata">

**Author:** ![filippogambarota](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/filippogambarota/32/8163_2.png) [@filippogambarota](https://discourse.mc-stan.org/u/filippogambarota)\
**Post date:** [June 14, 2020, 10:01am UTC](https://discourse.mc-stan.org/t/setting-priors-for-multinomial-regression-in-brms/15911/4 "2020-06-14T10:01:22Z")

</div>

Thanks @paul.buerkner! So can I ignore the warning message about setting a global prior? in this case I think that all my population-level fixed parameters are the same in terms of prior distribution.

---

<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:** [June 14, 2020, 10:05am UTC](https://discourse.mc-stan.org/t/setting-priors-for-multinomial-regression-in-brms/15911/5 "2020-06-14T10:05:53Z")

</div>

The warning just means that this way of specification is deprecated and may not continue to work in future versions of brms.

---

<div class="post-metadata">

**Author:** ![filippogambarota](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/filippogambarota/32/8163_2.png) [@filippogambarota](https://discourse.mc-stan.org/u/filippogambarota)\
**Post date:** [June 14, 2020, 10:21am UTC](https://discourse.mc-stan.org/t/setting-priors-for-multinomial-regression-in-brms/15911/6 "2020-06-14T10:21:41Z")

</div>

Perfect! I’ve also found that another (maybe better) solution could be to remove the intercept `response ~ 0 + GROUP` and then setting a global prior on `b` class.
