Negative Binomial — overdispersed counts (Var = μ + α μ²)

Verified

Advanced & specialized

Independently verified. Every statistic this test reports has been re-derived against an independent reference — never the library the pipeline itself calls — the rendered output was read back in a browser, and the result is locked with a committed regression suite.

Run this test straight away on a free built-in teaching dataset — no data of your own needed — or bring your own. Either opens the guided workspace: variable setup, assumption diagnostics, results with effect sizes and confidence intervals, figures, and APA-ready reporting.

Loading teaching datasets…

Or use your own dataset

Loading your datasets…

Models an OVERDISPERSED count outcome (variance >> mean) via the NB2 parameterisation Var(y|x) = μ + α μ².

Reports per-predictor incidence rate ratios (IRR = exp(β)) with 95% CI, MLE-estimated overdispersion parameter α with CI, model fit (deviance, log-likelihood, AIC, BIC, deviance pseudo-R²), an LRT vs nested Poisson testing whether overdispersion is real (H₀: α = 0), and a residual-dispersion check on the NB fit. The robust default for count outcomes in epidemiology, ecology, and any field where Poisson dispersion is rarely 1.

Worked example

How does clinic type affect (overdispersed) monthly visit counts?

Monthly visit counts were overdispersed (variance far exceeding the mean), so a negative-binomial regression replaces Poisson.

Result

Specialist clinics saw about 50% more visits than general clinics (IRR = 1.50, 95% CI [1.18, 1.90], p = .001); the data were overdispersed, so Poisson would have understated the standard errors.

How you'd report it (APA)

A negative-binomial regression (chosen for overdispersion) showed specialist clinics had significantly more visits, IRR = 1.50, 95% CI [1.18, 1.90], p = .001.

Try it yourself: Load this ready-made sample and follow the run above.

When to use it

  • Overdispersed event counts per case
    Hospital readmissions per patient (n = 3000) ~ age + comorbidity + length-of-index-stay + offset(log(follow-up-days)).
  • Disease counts in epidemiological surveillance
    TB cases per district (n = 200 districts) ~ HIV prevalence + poverty + altitude + offset(log(population)).

When NOT to — use instead

Hypotheses

H₀: β_j = 0 for all predictors (equivalently IRR_j = 1). Joint H₀_α: α = 0 (model collapses to Poisson).
Hₐ: at least one β_j ≠ 0; OR α > 0 (overdispersion).

Parameter tested: vector of population log-rate coefficients β plus overdispersion parameter α

Assumptions (and what to do if they fail)

α (overdispersion parameter) significantly > 0 — confirmed by an LRT comparing NB to nested Poisson. If α → 0, NB collapses to Poisson and the simpler model should be preferred.high

Check: α point estimate + LRT p-value vs Poisson.

If violated: α ≈ 0 with LRT p ≥ .05 → no evidence of overdispersion → switch to poisson_regression for parsimony.

After NB fit, Pearson dispersion ≈ 1. Substantial deviation suggests further misspecification (zero-inflation, missing predictors, or wrong link).medium

Check: Pearson dispersion ratio.

If violated: Residual dispersion still > 1.5 → consider zero-inflated NB, hurdle model, or richer predictor set.

Observed zero count rate matches NB expectation. Excess zeros suggest a zero-inflated NB (ZINB) is appropriate.medium

Check: Observed vs expected zero proportion under NB.

If violated: Excess zeros beyond NB expectation → zero-inflated NB or hurdle model.

No single case dominates the fit (Cook's D for NB GLM).high

Check: Max Cook's D.

If violated: Influential cases can flip IRR signs.

VIF for each predictor moderate (< 5 preferred; < 10 tolerable).medium

Check: Max VIF.

If violated: High VIF inflates IRR standard errors.

Ready to run a Negative Binomial — overdispersed counts (Var = μ + α μ²) on your own data?

Guided setup, automatic assumption checks, effect sizes, figures and an APA write-up.

Run this test →