Negative Binomial Calculator
Model overdispersed count data.
Enter parameters to calculate negative binomial probabilities
Use the negative binomial distribution when you're counting how many attempts it takes to achieve a certain number of successes, or when you have count data that's more variable than the Poisson distribution allows. It's commonly used in biology for modeling species abundance, in insurance for claim counts, and in quality control for defect analysis—anywhere counts show more variability than expected.
What Is the Negative Binomial Distribution?
The negative binomial distribution models the number of trials needed to achieve a specified number of successes, or equivalently, the number of failures before achieving r successes.
Also used for: Count data with overdispersion (variance > mean), which the Poisson cannot handle.
Two Parameterizations
Type 1: Trials Until r Successes
Question: "How many trials until I get r successes?"
Where:
- X = number of trials (minimum r)
- k = total trials
- r = required successes
- p = probability of success per trial
Type 2: Failures Before r Successes
Question: "How many failures before r successes?"
Where:
- X = number of failures (minimum 0)
- k = number of failures
- r = required successes
- p = probability of success per trial
Type 3: Mean-Dispersion Form (Overdispersed Counts)
Where:
- μ = mean
- r = dispersion parameter (smaller r = more overdispersion)
Example: Trials Until Success
Scenario: A basketball player has 70% free-throw success rate. What's the probability of needing exactly 5 shots to make 3 baskets?
Parameters:
- r = 3 (need 3 successes)
- p = 0.70
- k = 5 (total shots)
Interpretation: 18.5% chance of needing exactly 5 shots.
Example: Overdispersed Counts
Scenario: Daily emergency room visits. Mean = 20, but variance = 45 (much greater than mean).
Poisson assumes variance = mean, so it's inappropriate.
Negative binomial with μ = 20 and r = 16 (estimated from data): ✓
Mean and Variance
For "Failures Before r Successes" Version
For "Overdispersed Counts" Version
Key insight: Variance always exceeds mean (overdispersion).
Relationship to Other Distributions
Special Case: Geometric Distribution
Negative binomial with r = 1 is the geometric distribution (trials until first success).
Limiting Case: Poisson Distribution
As r → ∞, negative binomial approaches Poisson with parameter μ.
Mixture Interpretation
Negative binomial can be viewed as a Poisson distribution where the rate parameter itself follows a gamma distribution (Poisson-gamma mixture).
Detecting Overdispersion
Visual Check
Compare histogram of counts to Poisson with same mean.
Variance-to-Mean Ratio
- Ratio = 1: Poisson appropriate
- Ratio > 1: Overdispersion → consider negative binomial
- Ratio >> 1: Strong overdispersion
Statistical Test
In Poisson regression, test if dispersion parameter = 1.
When to Use Negative Binomial
Counting Processes
- Number of failures before success
- Trials until quota reached
- Waiting for rare events
Overdispersed Count Data
- Disease counts with clustering
- Accident data
- Insurance claims
- Ecological counts (species abundance)
- Website hits with viral effects
Whenever Poisson Doesn't Fit
If Poisson model shows overdispersion, try negative binomial.
Negative Binomial Regression
Model count data with covariates:
With negative binomial variance:
Use when: Poisson regression shows overdispersion (deviance >> df).
Cumulative Probabilities
For practical calculations, use software or statistical tables.
Applications
Quality Control
Number of inspections until finding r defective items.
Clinical Trials
Number of patients screened until finding r eligible subjects.
Epidemiology
Disease counts when clustering or heterogeneity exists.
Ecology
Species abundance data (often highly overdispersed).
Insurance
Claim counts per policyholder.
Software Engineering
Bug counts in code modules.
Example: Hospital Readmissions
Data: 30-day readmission counts for 500 patients
| Readmissions | Observed | Poisson Expected | NegBin Expected |
|---|---|---|---|
| 0 | 350 | 303 | 348 |
| 1 | 100 | 152 | 102 |
| 2 | 30 | 38 | 31 |
| 3+ | 20 | 7 | 19 |
Negative binomial fits much better due to overdispersion from unobserved patient heterogeneity.
Estimating Parameters
Method of Moments
Maximum Likelihood
More accurate; requires iterative computation.
Confidence Intervals
For estimated probabilities, use exact methods for small samples or normal approximation for large samples.
Reporting Results
For regression:
"Negative binomial regression was used due to significant overdispersion in the Poisson model (dispersion = 2.8). Hospital readmission counts were significantly associated with age (IRR = 1.03 per year, 95% CI: 1.01-1.05, p = .003) and prior admissions (IRR = 1.45, 95% CI: 1.22-1.72, p < .001)."
For probability calculation:
"Under a negative binomial model with r = 3 successes and p = 0.70, the probability of needing exactly 5 trials is 18.5%."
Common Mistakes
Using Poisson When Overdispersed
Check variance-to-mean ratio. If > 1.5, consider negative binomial.
Confusing Parameterizations
Be clear whether counting trials, failures, or using mean-dispersion form.
Ignoring Zero-Inflation
If there are excess zeros beyond what negative binomial predicts, consider zero-inflated models.
Wrong Variance Formula
Variance formula differs by parameterization—use the one matching your formulation.
Comparison with Poisson
| Aspect | Poisson | Negative Binomial |
|---|---|---|
| Variance | = Mean | > Mean |
| Parameters | 1 (λ) | 2 (μ, r) |
| Flexibility | Less | More |
| Use case | Homogeneous counts | Overdispersed counts |
| Interpretation | Random events | Clustering/heterogeneity |
Historical Context
The negative binomial distribution was studied by Pascal in the 17th century in the context of waiting for successes in repeated trials.
Its application to overdispersed count data developed in the 20th century, particularly through the work of Greenwood and Yule (1920) in epidemiology and Fisher in genetics.
Related Calculations
- Binomial Probability Calculator — Fixed number of trials
- Poisson Probability Calculator — When variance ≈ mean
- Geometric Distribution — Special case r = 1
- Chi-Square Goodness of Fit — Test fit
Summary
The negative binomial distribution models either the number of trials until r successes or overdispersed count data where variance exceeds mean. It's more flexible than Poisson, accommodating clustering and heterogeneity in count data. Key applications include quality control (waiting for r defects), epidemiology (disease clustering), and any count data failing the Poisson variance assumption. The dispersion parameter r controls the degree of overdispersion—smaller r means more overdispersion. Use negative binomial regression when Poisson regression shows overdispersion.