13.1 Negative Binomial Distribution

For the negative binomial distribution Stan uses the parameterization described in Gelman et al. (2013). For alternative parameterizations, see section 13.3.

13.1.1 Probability Mass Function

If \(\alpha \in \mathbb{R}^+\) and \(\beta \in \mathbb{R}^+\), then for \(y \in \mathbb{N}\), \[ \text{NegBinomial}(y~|~\alpha,\beta) = \binom{y + \alpha - 1}{\alpha - 1} \, \left( \frac{\beta}{\beta+1} \right)^{\!\alpha} \, \left( \frac{1}{\beta + 1} \right)^{\!y} \!. \]

The mean and variance of a random variable \(y \sim \text{NegBinomial}(\alpha,\beta)\) are given by \[ \mathbb{E}[y] = \frac{\alpha}{\beta} \ \ \text{ and } \ \ \text{Var}[Y] = \frac{\alpha}{\beta^2} (\beta + 1). \]

13.1.2 Sampling Statement

n ~ neg_binomial(alpha, beta)

Increment target log probability density with neg_binomial_lpmf( n | alpha, beta) dropping constant additive terms.

13.1.3 Stan Functions

real neg_binomial_lpmf(ints n | reals alpha, reals beta)
The log negative binomial probability mass of n given shape alpha and inverse scale beta

real neg_binomial_cdf(ints n, reals alpha, reals beta)
The negative binomial cumulative distribution function of n given shape alpha and inverse scale beta

real neg_binomial_lcdf(ints n | reals alpha, reals beta)
The log of the negative binomial cumulative distribution function of n given shape alpha and inverse scale beta

real neg_binomial_lccdf(ints n | reals alpha, reals beta)
The log of the negative binomial complementary cumulative distribution function of n given shape alpha and inverse scale beta

R neg_binomial_rng(reals alpha, reals beta)
Generate a negative binomial variate with shape alpha and inverse scale beta; may only be used in generated quantities block. alpha \(/\) beta must be less than \(2 ^ {29}\). For a description of argument and return types, see section 10.8.1.

References

Gelman, Andrew, J. B. Carlin, Hal S. Stern, David B. Dunson, Aki Vehtari, and Donald B. Rubin. 2013. Bayesian Data Analysis. Third. London: Chapman &Hall/CRC Press.