Negative binomial count/rate regression

Regression · Method and input reference

Rows: nonnegative integer count, positive exposure (use 1 for equal exposure), then numeric predictors. Log-link with log(exposure) offset. Independent observations required. NB2 estimates dispersion alpha with variance mu + alpha × mu². No zero-inflated or clustered model. Synthetic example: 240 simulated counts with unequal observation exposure and two predictors.

Open calculator · Compare methods in the decision matrix

When to consider it

  • Model independent overdispersed counts/rates using an NB2 log-link and exposure offset.

Assumptions and scope

  • Observations must be independent between subjects; repeated rows from one subject are not independent samples.
  • Enter Count, positive Exposure, then predictors. Use exposure 1 for equal observation periods. Review dispersion, zero inflation and fit diagnostics.

Required inputs

  • Count, exposure, predictors — Numeric observations; preserve the row and column structure described above.

Review missing values and data coding before running. Sample inputs are synthetic teaching examples.

Implementation

Rows: nonnegative integer count, positive exposure (use 1 for equal exposure), then numeric predictors. Log-link with log(exposure) offset. Independent observations required. NB2 estimates dispersion alpha with variance mu + alpha × mu². No zero-inflated or clustered model. Synthetic example: 240 simulated counts with unequal observation exposure and two predictors.

  • statsmodels 0.14.4: statsmodels.api.NegativeBinomial

These are pinned library versions; saved results record the versions actually used at runtime.

Library references