This is an old version, view current version.

16.2 Multinomial distribution, logit parameterization

Stan also provides a version of the multinomial probability mass function distribution with the \(\text{$K$-simplex}\) for the event count probabilities per category given on the unconstrained logistic scale.

16.2.1 Probability mass function

If \(K \in \mathbb{N}\), \(N \in \mathbb{N}\), and \(\text{softmax}^{-1}(\theta) \in \text{$K$-simplex}\), then for \(y \in \mathbb{N}^K\) such that \(\sum_{k=1}^K y_k = N\), \[ \text{MultinomialLogit}(y|\theta) = \text{Multinomial}(y|\text{softmax}^{-1}(\theta)) = \binom{N}{y_1,\ldots,y_K} \prod_{k=1}^K [\text{softmax}^{-1}(\theta)_k]^{y_k}, \] where the multinomial coefficient is defined by \[ \binom{N}{y_1,\ldots,y_k} = \frac{N!}{\prod_{k=1}^K y_k!}. \]

16.2.2 Sampling statement

y ~ multinomial_logit(theta)

Increment target log probability density with multinomial_logit_lupmf(y | theta).
Available since 2.24

16.2.3 Stan functions

real multinomial_logit_lpmf(array[] int y | vector theta)
The log multinomial probability mass function with outcome array y of size \(K\) given the \(K\)-simplex distribution parameter \(\text{softmax}^{-1}(\theta)\) and (implicit) total count N = sum(y)
Available since 2.24

real multinomial_logit_lupmf(array[] int y | vector theta)
The log multinomial probability mass function with outcome array y of size \(K\) given the \(K\)-simplex distribution parameter \(\text{softmax}^{-1}(\theta)\) and (implicit) total count N = sum(y) dropping constant additive terms
Available since 2.25

array[] int multinomial_logit_rng(vector theta, int N)
Generate a multinomial variate with simplex distribution parameter \(\text{softmax}^{-1}(\theta)\) and total count \(N\); may only be used in transformed data and generated quantities blocks
Available since 2.24