15.1 Negative binomial distribution

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

15.1.1 Probability mass function

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

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

15.1.2 Sampling statement

n ~ neg_binomial(alpha, beta)

Increment target log probability density with neg_binomial_lupmf(n | alpha, beta).
Available since 2.0

15.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
Available since 2.12

real neg_binomial_lupmf(ints n | reals alpha, reals beta)
The log negative binomial probability mass of n given shape alpha and inverse scale beta dropping constant additive terms
Available since 2.25

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
Available since 2.0

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
Available since 2.12

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
Available since 2.12

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 transformed data and generated quantities blocks. alpha \(/\) beta must be less than \(2 ^ {29}\). For a description of argument and return types, see section vectorized function signatures.
Available since 2.18

References

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