Negative binomial regression models a non-negative integer response using a negative binomial distribution whose conditional mean depends on explanatory variables. A quant might use it for daily operational-incident counts when a Poisson regression gives a plausible average but too little variation around that average. The regression describes how expected frequency changes; it does not model the monetary size of each incident.
Specify the mean and the variance
A common version is NB2 with a log link. Write for the count, for observed predictors and for a known exposure, such as operating hours:
The exposure term is an offset: its coefficient is fixed at one. Thus is an expected count, while is the expected event rate per exposure unit. Including this offset assumes counts scale proportionally with exposure at fixed predictors. Equal-exposure observations can use .
The extra term allows conditional variance above the Poisson value . This is overdispersion relative to Poisson, after accounting for the specified predictors and exposure. Comparing the raw sample variance with the raw sample mean mixes this question with differences in fitted means across observations.
The name alone is insufficient: NB1, under another common convention, uses . Its extra variation grows linearly rather than quadratically with the mean. With and a numerical dispersion value , NB1 gives variance , whereas NB2 gives . A dispersion estimate cannot be transferred between these models just because both call it “alpha.” statsmodels documents both conventions.
A forecast with mean four
Consider a specified synthetic NB2 model for one operating day, at fixed predictors and exposure:
To compute probabilities, convert to the size–probability parameterisation:
Here the probability mass is
This is the failures-before--successes convention when is an integer, as in R's negative-binomial documentation. It is not the total-trials convention, whose support starts at . In regression, may be any positive real number: “size” is a distributional parameter, not necessarily a literal success target, and operational incidents need no Bernoulli stopping interpretation.
At zero, the mass simplifies to
A Poisson distribution with the same mean has variance and zero probability . Matching the mean therefore does not match either the chance of a quiet day or the upper tail.
Original comparison of specified conditional count laws, not fitted data. Filled bars show NB2 and outlined bars show Poisson; the lower panel holds exposure and dispersion fixed while changing one covariate.
Read coefficients as ratios
With the log link, increasing by one unit multiplies the conditional mean by , holding all other predictors and exposure fixed. A coefficient changes a mean of to . It does not add two events. At fixed , the new NB2 variance is ; dispersion affects the predictive spread even though it does not appear in the mean equation.
This interpretation concerns the specified regression relationship. A coefficient is not automatically a causal effect. Interactions or nonlinear predictor terms also mean that the effect of changing an original input must be calculated from the full mean equation.
For ordinary independent observations, fitting commonly maximises the negative-binomial likelihood over regression coefficients and dispersion. Check what the chosen fitting routine actually estimates: MASS
glm.nb estimates its additional size parameter, while the statsmodels NB2 family documentation describes an ancillary alpha treated as given. Supplying a family with a dispersion value is not the same operation as estimating that dispersion.Extra variance is a modelling choice
One NB2 construction is a Poisson count conditional on an unobserved multiplier , with intensity , where is gamma distributed with shape and scale . Then and , producing the NB2 variance by the [law of total variance. This is a useful heterogeneity story, not evidence that a real dataset's hidden intensity follows a gamma law. The Loss Distribution Approach, §5, derives the mixture and connects frequency to aggregate losses. Its public preview is open; the full lesson requires membership.
A fitted dispersion parameter does not repair every count-data problem:
- A wrong conditional mean: omitted predictors, incorrect exposure or a wrong functional form can appear as overdispersion. Recheck the mean specification.
- Dependence: repeated counts from the same desk or serially clustered incident days require a dependence model or suitable inference. Merely replacing the one-observation distribution leaves cross-observation dependence unspecified.
- Excess zeros: NB2 already predicts more zeros than Poisson in this example. If zeros still exceed a credible fitted count model, a structural-zero or hurdle mechanism may be relevant; many zeros alone do not establish either mechanism.
Brooks et al. discuss separate model components for dispersion, correlated observations and structural zeros. Check fitted probabilities, residual patterns and predictive performance against the data-generating setting before interpreting a larger dispersion as a complete solution.
Sources
- statsmodels: NegativeBinomial count model, Parameters: NB1/NB2 variance conventions and exposure/offset treatment.
- statsmodels: NegativeBinomial exponential family, Parameters and Notes: log link, ancillary dispersion and NB2 mass function.
- R Core Team: The Negative Binomial Distribution, Details: count convention, size–mean mapping and gamma mixture.
- MASS: Fit a Negative Binomial Generalized Linear Model, Description, Details and Value: alternating estimation of regression and size parameters.
- Brooks et al. (2017), “glmmTMB Balances Speed and Flexibility Among Packages for Zero-inflated Generalized Linear Mixed Modeling”, Introduction and Implementation: distinctions between dispersion, random effects and structural-zero components.