Hi,

Can anyone suggest an example including r-code that uses the family “multinomial” in brms?

I cannot find anywhere how to specify the model.

Thanks

- Operating System: windows 10
- brms Version: 2.8.0

Hi,

Can anyone suggest an example including r-code that uses the family “multinomial” in brms?

I cannot find anywhere how to specify the model.

Thanks

- Operating System: windows 10
- brms Version: 2.8.0

Here is an example with dummy data:

```
N <- 15
dat <- data.frame(
y1 = rbinom(N, 10, 0.3), y2 = rbinom(N, 10, 0.5),
y3 = rbinom(N, 10, 0.7), x = rnorm(N)
)
dat$size <- with(dat, y1 + y2 + y3)
dat$y <- with(dat, cbind(y1, y2, y3))
prior <- prior(normal(0, 10), "b", dpar = muy2) +
prior(cauchy(0, 1), "Intercept") +
prior(normal(0, 2), "Intercept", dpar = muy3)
fit <- brm(bf(y | trials(size) ~ 1, muy2 ~ x), data = dat,
family = multinomial(), prior = prior)
```

You may also bind `y1`

to `y3`

together within the formula as long as you avoid using `cbind`

which is (currently still) reseverd form multivariate models.

1 Like

Thank you very much for taking the time.

I cannot fully understand the model because I do not get what you did here:

I tried to look up

`> dpar`

in

set_prior {brms}

But I could not find how to define it and what, muy2/muy3 are.

I understood they are not arbitrary names because changing them I get the following error message:

`> xxx is not a valid distributional or non-linear parameter`

Could you tell me where to find these info?

Thank you again

The name of the distributional parameters in multinomial models are `mu<category name>`

(whereas the first category will serve as the reference by default). You only need to use those if you want to fit predictor terms of different structure to different categories. If you want to apply the same structure to all categories (except for the reference of course), you can simply write

```
bf(y | trials(size) ~ <predictor term>)
```

1 Like