13.2 Binomial Distribution, Logit Parameterization
Stan also provides a version of the binomial probability mass function distribution with the chance of success parameterized on the unconstrained logistic scale.
13.2.1 Probability Mass Function
Suppose \(N \in \mathbb{N}\), \(\alpha \in \mathbb{R}\), and \(n \in \{0,\ldots,N\}\). Then \[\begin{eqnarray*} \text{BinomialLogit}(n~|~N,\alpha) & = & \text{Binomial}(n~|~N,\text{logit}^{-1}(\alpha)) \\[6pt] & = & \binom{N}{n} \left( \text{logit}^{-1}(\alpha) \right)^{n} \left( 1 - \text{logit}^{-1}(\alpha) \right)^{N - n}. \end{eqnarray*}\]
13.2.2 Log Probability Mass Function
\[\begin{eqnarray*} \log \text{BinomialLogit}(n~|~N,\alpha) & = & \log \Gamma(N+1) - \log \Gamma(n + 1) - \log \Gamma(N- n + 1) \\[4pt] & & { } + n \log \text{logit}^{-1}(\alpha) + (N - n) \log \left( 1 - \text{logit}^{-1}(\alpha) \right), \end{eqnarray*}\]
13.2.3 Gradient of Log Probability Mass Function
\[ \frac{\partial}{\partial \alpha} \log \text{BinomialLogit}(n~|~N,\alpha) = \frac{n}{\text{logit}^{-1}(-\alpha)} - \frac{N - n}{\text{logit}^{-1}(\alpha)} \]
13.2.4 Sampling Statement
n ~
binomial_logit
(N, alpha)
Increment target log probability density with binomial_logit_lupmf(n | N, alpha)
.
13.2.5 Stan Functions
real
binomial_logit_lpmf
(ints n | ints N, reals alpha)
The log binomial probability mass of n successes in N trials given
logit-scaled chance of success alpha
real
binomial_logit_lupmf
(ints n | ints N, reals alpha)
The log binomial probability mass of n successes in N trials given
logit-scaled chance of success alpha dropping constant additive terms