This is an old version, view current version.

12.2 Bernoulli distribution, logit parameterization

Stan also supplies a direct parameterization in terms of a logit-transformed chance-of-success parameter. This parameterization is more numerically stable if the chance-of-success parameter is on the logit scale, as with the linear predictor in a logistic regression.

12.2.1 Probability mass function

If \(\alpha \in \mathbb{R}\), then for \(y \in \{0,1\}\), \[ \text{BernoulliLogit}(y~|~\alpha) = \text{Bernoulli}(y | \text{logit}^{-1}(\alpha)) = \left\{ \begin{array}{ll} \text{logit}^{-1}(\alpha) & \text{if } y = 1, \text{ and} \\ 1 - \text{logit}^{-1}(\alpha) & \text{if } y = 0. \end{array} \right. \]

12.2.2 Sampling statement

y ~ bernoulli_logit(alpha)

Increment target log probability density with bernoulli_logit_lupmf(y | alpha).

12.2.3 Stan Functions

real bernoulli_logit_lpmf(ints y | reals alpha)
The log Bernoulli probability mass of y given chance of success inv_logit(alpha)

real bernoulli_logit_lupmf(ints y | reals alpha)
The log Bernoulli probability mass of y given chance of success inv_logit(alpha) dropping constant additive terms

R bernoulli_logit_rng(reals alpha)
Generate a Bernoulli variate with chance of success \(\text{logit}^{-1}(\alpha)\); may only be used in transformed data and generated quantities blocks. For a description of argument and return types, see section vectorized PRNG functions.