# Setting priors on sd for multinomial multilevel model

**URL:** <https://discourse.mc-stan.org/t/setting-priors-on-sd-for-multinomial-multilevel-model/11193>\
**Category:** brms\
**Created:** [September 30, 2019, 9:33pm UTC](https://discourse.mc-stan.org/t/setting-priors-on-sd-for-multinomial-multilevel-model/11193 "2019-09-30T21:33:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon75146577](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@anon75146577](https://discourse.mc-stan.org/u/anon75146577)\
**Post date:** [September 30, 2019, 9:33pm UTC](https://discourse.mc-stan.org/t/setting-priors-on-sd-for-multinomial-multilevel-model/11193/1 "2019-09-30T21:33:16Z")

</div>

I’ve hit a problem setting the standard deviations for a multilevel multinomial model.

My problem is something like

```
formula <- y | trials(total) ~ (1 + year || region\country) + (-1 + covariate | region)
priors <- c( set_prior("normal(0,1)", class = "b"),
                          set_prior("normal(0,1)", class = "sd"))
code <- make_stancode( formula , data = analysis_data, prior=priorsl)

```

throws the error

```
rror: The following priors do not correspond to any model parameter: 
sd ~ normal(0,1)
Function 'get_prior' might be helpful to you.

```

The function `get_prior` does not help :p

If I try

```
priors <- c( set_prior("normal(0,1)", class = "b"),
                          set_prior("normal(0,1)", class = "sd", group = "region"))

```

I get the same error except it says that `sd_region` does not exist.

Any ideas?

(Edit: this is brms version 2.10.0)

---

<div class="post-metadata">

**Author:** ![anon75146577](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@anon75146577](https://discourse.mc-stan.org/u/anon75146577)\
**Post date:** [September 30, 2019, 10:25pm UTC](https://discourse.mc-stan.org/t/setting-priors-on-sd-for-multinomial-multilevel-model/11193/2 "2019-09-30T22:25:39Z")

</div>

A hacky but working solution is the following:

```
ind_sd <- which(priors_complex_model$group == "" & priors_complex_model$class == "sd")
priors_complex_model$prior[ind_sd] <- "normal(0,1)"

```

---

<div class="post-metadata">

**Author:** ![anon75146577](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@anon75146577](https://discourse.mc-stan.org/u/anon75146577)\
**Post date:** [September 30, 2019, 10:29pm UTC](https://discourse.mc-stan.org/t/setting-priors-on-sd-for-multinomial-multilevel-model/11193/3 "2019-09-30T22:29:47Z")

</div>

Ok. I understnand it now. I needed to do something like

```
set_prior("normal(0,1)", class = "sd", dpar = "mu<category>")

```

---

<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:** [October 1, 2019, 6:59am UTC](https://discourse.mc-stan.org/t/setting-priors-on-sd-for-multinomial-multilevel-model/11193/4 "2019-10-01T06:59:48Z")

</div>

Yeah, sorry for that. The fact that the same works with `class = "b"` is merely a convenience feature that is not trivial to implement for SDs as the hierechical structure of the prior specification makes handling of default priors more complicated. I brms 3.0 I plan a little restructering of the brms prior system and then we hopefully have a good solution.

P.S. `get_prior` would have helped :-p
