Ask Mallard
Analysis method

Negative binomial regression

4 min read

Negative binomial regression models counts whose spread exceeds the Poisson assumption, with an extra parameter for that spread.

Fit

When to use it, and when not to

Use it when

  • Your outcome is an event count with extra variation after predictors are included.
  • A quadratic mean-variance relation is a plausible working model.

Not when

Before you start

What you need

Decide these first
  1. Counts and observation windowsoutcomeTypeDefine repeat events and when counting starts and stops.
  2. Exposure time and target contrastsummaryMeasureUse a log-time offset for rates. Equal windows can support a count comparison.
  3. The variance model and planning assumptionsRecord expected counts, extra variation and predictor effects. Plan power or precision for the intended design.
It rests on these
  1. The log mean is correctly specified.How to check: Check fitted counts across predictor values and observation windows.
  2. The NB2 variance is the mean plus dispersion times the squared mean.How to check: Check whether extra spread grows with the mean. Software may label dispersion or its reciprocal differently.
  3. The dispersion term alone does not model repeated-observation correlation.How to check: Identify shared people and sites before choosing a clustered analysis.

Plain language

How it works

This article uses NB2, one negative binomial model. It keeps a log mean and adds a dispersion parameter. Its variance is mean plus dispersion times mean squared. A log-time offset converts a count model into a rate model. Exponentiated slopes compare rates at equal predictor values.

What the fit means

Gardner and colleagues describe extra between-person variation. Ver Hoef and Boveng show why the variance relation changes how counts contribute to a fitted model. Extra spread and within-person dependence are different problems. Negative binomial dispersion alone does not solve the second.

The method as a flow
A single-method workflow. Counts, predictors and exposure time. Fit a log mean plus extra dispersion. Check mean-dependent spread and rate ratios. The diagram describes the analysis steps, not results from any study.Negative binomial regressionCounts, predictors and exposure timeFit a log mean plus extra dispersionCheck mean-dependent spread and rate ratiosModel assumptions and the study design still determine what the estimate can support.
Conceptual diagram. It shows the structure of the idea, not data from any study.

Worked example

A worked example

Invented for illustration
Setting
A model of yearly exacerbation counts uses the NB2 variance and independent people.
Question
What does an assumed treatment coefficient imply?
Approach
Assume a fitted comparison mean of 4, a log rate ratio of log 0.75, and dispersion 0.5. Assume coefficient standard error 0.20.
Result
The fitted mean changes from 4 to 3 events per year, a change of -1. The comparison variance is 12.
What it means
The rate ratio is 0.75. Its exponentiated 95% Wald interval is 0.51 to 1.11. The interval allows a higher or lower rate.

In practice

Recent studies PubMed search · not vetted

Searching PubMed…

Watch out

Common mistakes

The one to remember

Extra dispersion does not account for dependence between repeated counts. Negative binomial regression needs its own mean and variance assumptions; many zeros alone do not establish a separate structural-zero process.

  • Choosing the model because the raw variance exceeds the raw mean.Instead: Assess extra spread after fitting the predictors and exposure time.
  • Calling every zero a structural zero.Instead: Examine the event process; an ordinary count distribution can produce many zeros.
  • Using a single-proportion interval for a rate ratio.Instead: Use profile-likelihood or Wald intervals for the regression coefficient and exponentiate the limits.

Inside Mallard

How Mallard uses this

Mallard links named negative binomial regression to this method. Its method list and code entry have no dedicated catalog sizing formula.

Code example in Mallard: Negative binomial regression for overdispersed counts (negative-binomial-rate-ratio).
Atlas node analysis.negative_binomial_regression, the id a plan cue records.
Code for this method
Loading…

Related Learn pages

Related designs and methods

Evidence

Sources & further reading

  1. Regression analyses of counts and rates: Poisson, overdispersed Poisson, and negative binomial models (opens in a new tab) · Psychol Bull · doi 10.1037/0033-2909.118.3.392
  2. Quasi-Poisson vs. negative binomial regression: how should we model overdispersed count data? (opens in a new tab) · Ecology · doi 10.1890/07-0043.1
Prepared with AI assistance. Source titles, authors, years and available DOIs were checked against PubMed on 2026-11-06. No independent professional approval is claimed. Gardner supports the count model; Ver Hoef and Boveng support the NB2 mean-variance relation and weighting. Their application concerns animal counts, not a clinical treatment effect.
Last source review: 2026-11-06
AI-generated educational content
Mallard uses reputable methodological and reporting sources, but this material may contain errors or omit important context. Verify important methodological decisions with the cited sources and, when appropriate, a qualified research methodologist or statistician.