How to Find the MLEs of a Negative Binomial Distribution
At a glance
- 1. Choose a convention
Here, X counts failures before r successes, and p is the probability of success on each trial.
- 2. Fix the size
If r is known, estimate p using the sample mean: p-hat equals r divided by r plus the sample mean.
- 3. Estimate both parameters
If r is unknown, substitute the estimate of p into the likelihood and solve the size score equation numerically.
- 4. Check the limit
A very large estimated size approaches a Poisson model; check the profile likelihood if the data are not overdispersed.
The maximum-likelihood estimates depend on which negative-binomial convention you use and whether the size parameter is known. This article uses the convention that each observation counts failures before the th success. It gives the closed-form estimate when is fixed and the equation to solve when both parameters are unknown.
Model and likelihood
Let be independent observations, where each is the number of failures before successes. Write for the success probability. The probability mass function is
For positive integer , the binomial coefficient has its usual meaning. In estimation, it is also common to allow a positive real-valued size parameter , using the gamma-function extension. Under this parameterization,
For observations , let and let . The likelihood is
The combinatorial factors do not depend on , which makes its estimate straightforward when is fixed.
MLE of when is known
The part of the log-likelihood involving is
Differentiate and set the result to zero:
Solving gives
Thus, for known , the MLE of the success probability is the size divided by the size plus the sample mean. The fitted mean is . If , this formula gives the boundary estimate . If the parameter space is restricted to , the likelihood instead has a supremum as approaches 1, but no interior MLE.
MLE when both and are unknown
If , all observations are zero. The likelihood is maximized at the boundary if that value is allowed, and every positive gives the same likelihood, so is not identified. If is required, the likelihood supremum is approached as tends to 1.
For , for each proposed value of , the maximizing value of is still . Substitute this into the log-likelihood, then solve the score equation for :
where is the digamma function, the derivative of . This equation generally has no closed-form solution, so use a numerical root finder or maximize the profile log-likelihood directly. A finite root need not exist: compare the profile likelihood with its limit as tends to infinity, which corresponds to a Poisson model with mean . If that limit is favored, there is no finite- MLE under the negative-binomial model alone. After finding a finite , calculate
When the observations are nonnegative integers, the digamma differences can be written as finite sums:
For an observation equal to zero, this sum is empty and contributes zero. This form can make numerical evaluation easier.
Worked example
Suppose the observed failure counts are , and both parameters are to be estimated. There are observations and . The score equation becomes
Numerically, its solution is approximately . Substituting this into the formula for gives
The fitted mean is approximately , matching the sample mean, as expected. In practice, a software optimizer should also be checked for convergence and for whether it found a maximum rather than another stationary point.
If your convention is different
Some sources define a negative-binomial variable as the number of successes before a fixed number of failures, or write the model in terms of its mean and size . Under the mean-size form,
For fixed , the MLE of is . This is the same result expressed in different parameters: . Always check what the variable counts and which probability is called before applying a formula.
Common mistakes
- Swapping and . In the convention used here, is the probability of success, while the observed count is failures.
- Treating the size estimate as closed form. The estimate of is explicit for fixed , but estimating both parameters usually requires numerical optimization.
- Using the wrong mean. The sample mean estimates , not itself.
- Ignoring the Poisson limit. As grows without bound while the mean stays fixed, the negative binomial approaches a Poisson distribution. If the profile likelihood is maximized at this limit, there is no finite-size MLE under the negative-binomial model alone. Inspect the profile likelihood instead of forcing a finite estimate.
References
- Discrete Distributions, 3rd edition — Norman L. Johnson, Adrienne W. Kemp, and Samuel Kotz
- Statistical Inference, 2nd edition — George Casella and Roger L. Berger
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.