Quantitative Analysis/ Regression
Counts with extra variation

What is negative binomial regression? Theory, calculation and application

Negative binomial regression handles count outcomes whose variation exceeds their average, which is common in health, safety, and service-use data. This guide explains overdispersion and rate ratios and shows how to run a model in AnalyZ Solutions.

9 min read Regression Advanced

01What is negative binomial regression?

Negative binomial regression is a method for studying outcomes that are counts, such as the number of clinic visits in a year, when the counts vary more than a simple count model allows. It shows which factors are linked to the count, by how much, and how many events to expect for a particular person.

Counts are whole numbers that cannot be negative, and in real data many people have zero or one event while a few have very many. The thing you want to explain is the outcome, and the factors you use to explain it are the predictors.

An example

Suppose you record the number of clinic visits in a year for 600 people, together with whether each person has a long-term condition and their age. You want to know three things. Do people with a long-term condition make more visits? Does age make a difference? And how many visits would you expect from a 40-year-old with a long-term condition? Negative binomial regression answers all three.

Why not use a different method?

Linear regression can predict a negative number of visits and assumes the spread of the data is the same everywhere, which counts do not follow. The standard model for counts, Poisson regression, assumes the variation in counts equals their average. In real data it often does not, because a few people with very many events stretch the spread far beyond the average. Negative binomial regression adds one parameter that lets the variation exceed the average, so the standard errors and significance levels stay honest.

What you get out of it

  1. Direction
    Whether each predictor goes with more or fewer events.
  2. Size
    How many times more or fewer events, as a ratio called the incidence rate ratio.
  3. Confidence
    Whether the pattern could easily be chance, shown by a significance level and a confidence interval.
  4. Prediction
    The expected number of events for any combination of predictor values.
Results are adjusted for the other predictors. The effect of each predictor is the effect among people who are the same on the others, so differences in those do not distort it.

02When to use it

Use it for count outcomes when the variance clearly exceeds the mean, or when Poisson regression in AnalyZ Solutions displays an overdispersion warning. It fits counts of health facility visits, incidents, hospitalisations, days absent, or services used, wherever a few units dominate the totals.

If the counts are equidispersed, Poisson is simpler and gives the same answers. If there are far more zeros than either model expects, for instance because many people never use a service, neither is ideal. If the data are clustered, use multilevel regression with a count outcome.

03The building blocks: the Poisson starting point, overdispersion and a dispersion parameter

Negative binomial regression builds on the Poisson model, so it helps to see where that model falls short. This section covers the Poisson starting point, the problem called overdispersion, and the extra parameter that fixes it.

The Poisson starting point

The standard model for counts is Poisson regression. It writes the logarithm of the average count as a straight-line combination of the predictors, which keeps every prediction above zero, and it reports effects as ratios called incidence rate ratios. A ratio of 1.3 means 30% more events.

Overdispersion: when Poisson is not enough

Poisson regression assumes that the spread of counts matches their average. Real data rarely behave so neatly. In health and service data, a large share of people may have zero or one event while a few have very many: some people make dozens of clinic visits, some sites report many incidents, and some pupils miss a lot of school days. The variation is then far greater than the average would suggest, which is called overdispersion.

The consequence is not a slight loss of accuracy. A Poisson model on overdispersed data reports standard errors that are too small, so it makes confidence intervals too narrow and calls too many predictors significant. Negative binomial regression fixes this by adding a parameter that lets the variation exceed the average.

The figure below uses the 600 counts from the example in this guide. With no predictors in either model, a Poisson model with the same average expects far too few people with no visits and too few with many. A negative binomial model follows the data.

Figure 1. Observed visit counts against what each model expects (no predictors, same average)Bar chart of observed counts with a Poisson curve that underestimates zeros and large counts and a negative binomial curve that follows the bars.0%10%20%30%40%50%012345678910+Observed share of peoplePoisson model expectsNegative binomial model expectsZeros: observed 41%, Poisson 22%, negative binomial 41%Number of clinic visits in a yearShare of people
Figure 1. Observed visit counts against what each model expects (no predictors, same average)

The dispersion parameter

Negative binomial regression has the same structure as Poisson regression. It models the expected count through a log link and reports incidence rate ratios. The addition is a dispersion parameter, usually called alpha, which measures how much extra variation there is beyond Poisson. AnalyZ Solutions uses the common NB2 form, in which the variance grows with the square of the average. The figure plots the variance against the average. The Poisson variance rises in a straight line, while the negative binomial variance curves upward, and the larger alpha is, the more steeply.

Figure 2. How the variance grows with the mean, with and without the dispersion parameterLine chart. The Poisson variance rises in a straight line equal to the mean. Negative binomial variance curves upward, more steeply for a larger dispersion parameter.0102030012345Marked points: at a mean of 1.8, the variance is1.8 under Poisson and 5.4 under negative binomial.Negative binomial, alpha = 1.11 (this guide)Negative binomial, alpha = 0.30Poisson: variance equals the meanAverage count (mean)Variance of the count
Figure 2. How the variance grows with the mean, with and without the dispersion parameter

An alpha close to zero means the data are close to Poisson, and the extra parameter is doing little. A larger alpha means stronger overdispersion. The value itself is rarely reported as a finding. What matters is that the model handles it, and that the resulting standard errors can be trusted.

04The model in numbers

What changes from Poisson

The mean is modelled in exactly the same way as in Poisson regression, with the log of the mean as a straight-line combination of the predictors. The change is in the variance:

ln( μ ) = b0 + b1 × x1 + b2 × x2 + ...
variance of Y = μ + α × μ²
P( Y = 0 ) = ( 1 / (1 + α × μ) )^(1/α)

The dispersion parameter α is estimated together with the coefficients by maximum likelihood. When α is zero the variance collapses to μ and the model is Poisson. The larger α is, the more the counts spread out, and the more the variance exceeds the mean, especially when the mean itself is large.

Making a prediction

Take a person with a long-term condition, aged 40, with age in decades, and the results below, where α = 1.111.

  1. Expected count
    e^(0.309 + 0.266 × 1 + 0.003 × 4) = 1.80 visits a year. For someone without the condition the mean is 1.38, and the ratio is e^0.266 = 1.305, the incidence rate ratio.
  2. Variance under negative binomial
    1.80 + 1.111 × 1.80² = 5.39.
  3. Variance under Poisson
    just 1.80. The negative binomial model expects counts about three times as spread out around the same average.
  4. Chance of no visits
    Under negative binomial, ( 1 ÷ (1 + 1.111 × 1.80) )^(1/1.111) = 0.372, or 37%. Under Poisson, e^-1.80 = 0.166, or 17%.

The figure shows the two distributions side by side at this mean.

Figure 3. The same average, two very different distributionsPaired bars comparing Poisson and negative binomial probabilities for zero to ten visits at the same mean.0%10%20%30%40%01234567891017%37%PoissonNegative binomialSame mean (1.80 visits).6 or more visits: 1% under Poisson,7% under negative binomial.Number of visits in a yearChance
Figure 3. The same average, two very different distributions

Many people with no visits, together with a few with very many, is the pattern that real overdispersed counts show, and only the negative binomial model reproduces it. That is why Poisson standard errors come out too small in such data.

05Reading the output

Incidence rate ratios

Each predictor has an IRR with a 95% confidence interval and a significance level. A ratio of 1 means no difference, above 1 means higher expected counts, and below 1 means lower. An IRR of 1.5 for people with a long-term condition means they are expected to record 50% more events than people without one. A toggle switches to raw coefficients on the log scale.

Model fit and dispersion

The summary reports the number of cases, log-likelihood, a likelihood-ratio test, a pseudo R-squared, AIC, and the dispersion parameter alpha. Comparing AIC with a Poisson model on the same variables is a useful check. A clearly lower AIC for the negative binomial model confirms that the extra flexibility was needed.

06How to run it in AnalyZ Solutions

Open Inferential Analysis, choose Regression, then Negative Binomial Regression.

  1. Select the dependent variable
    Choose a count variable with non-negative whole numbers.
  2. Select the predictor variables
    Choose numeric or categorical predictors.
  3. Set reference categories
    Categorical predictors are converted to comparisons against a reference category automatically. Pick the reference category you want each group compared with, usually the largest or the most natural comparison group.
  4. Apply a subsample filter if needed.
  5. Click Run regression
    The output includes the IRR table, the model summary with alpha, a coefficient plot, and a plain-language interpretation.
Compare it with Poisson. Run both models on the same variables. If the significant predictors are the same and the intervals are similar, the overdispersion did not change your conclusions. If predictors that were significant under Poisson lose significance under negative binomial, the Poisson result was overstated, and the negative binomial result is the one to report.

07Interpreting the result

The figures below are invented to show the steps, and they follow the results tables in AnalyZ Solutions, with a few columns left out to save space. Suppose the number of clinic visits in a year is modelled for 600 people using a long-term condition (reference: None) and age in decades. A Poisson model was run first, and it showed a dispersion ratio of 2.882, above the warning level of 1.5, so a negative binomial model was used.

Model summary
NLog-likelihoodLR chi2Prob > chi2Pseudo R²AICalpha
600-1012.68625.540.06270.0032033.371.111
Incidence rate ratios (negative binomial)
VariableIRR95% CI lower95% CI upperp-valueSig
Long-term condition (ref: None)1.3051.0451.6290.0189*
Age (per 10 years)1.0030.9201.0940.9473ns

Reading it step by step

  1. Confirm why this model was needed
    The average number of visits is 1.52, but the variance is 4.56, three times larger. The Poisson dispersion ratio of 2.88 flagged the problem. The dispersion parameter alpha of 1.111 confirms that the spread is well beyond Poisson.
  2. Compare the fit
    The AIC is 2033.37 for the negative binomial model and 2381.34 for the Poisson model on the same data. Lower is better, so the extra flexibility was clearly needed.
  3. Read the rate ratio
    People with a long-term condition have a rate ratio of 1.305, so they make about 30% more visits. The interval, 1.045 to 1.629, is above 1, and the p-value of 0.0189 makes the result significant at the 5% level. Under the Poisson model, the same ratio looked much stronger (p below 0.001, interval 1.143 to 1.489), which shows how overdispersion overstates significance.
  4. Read the non-significant predictor
    Age has a rate ratio of 1.003 and a p-value of 0.9473, so there is no sign of any link with visits. Do not describe alpha as a finding. It describes the spread of the counts, not the effect of any predictor.

In plain words

People with a long-term condition made about 30% more clinic visits, a result significant at the 5% level. Because the counts were far more spread out than a Poisson model allows, a negative binomial model was used, and its wider interval is the more honest one. Age showed no clear association with visits.

08Common mistakes

Choosing it automatically without checking. When counts are not overdispersed, Poisson is simpler.

Ignoring zero inflation. If many units never take part in the activity at all, the model may fit poorly.

Treating alpha as a result. It describes the spread of the counts and is not an effect of any predictor.

Ignoring clustering. Counts from the same person, clinic, or school are usually correlated, and a multilevel count model is more appropriate.

Frequently Asked Questions
How do I know if my data are overdispersed?
Compare the variance of the count with its mean. If the variance is much larger, the data are overdispersed. AnalyZ Solutions also checks this automatically when you run Poisson regression and warns you if the ratio is high.
What is the dispersion parameter alpha?
It measures the extra variation beyond what Poisson allows. A value near zero means Poisson is adequate. Larger values indicate more overdispersion. It is a property of the counts and not a finding about any predictor.
Are the incidence rate ratios interpreted differently from Poisson?
No. They mean the same thing. The difference is that their confidence intervals and significance levels are more accurate when the data are overdispersed.
What if I have many more zeros than expected?
Zero-inflated and hurdle models are designed for that situation and are not included in AnalyZ Solutions. As a partial approach, you can model whether any events occurred with logistic regression, and then model the counts among those with at least one event.
Can I compare AIC across Poisson and negative binomial models?
Yes, when both are fitted to the same cases and variables. A lower AIC indicates a better balance of fit and simplicity.

Model overdispersed counts

Open Regression in AnalyZ Solutions. Free to sign up, free to analyze.

Get started
Related Guides