Book contents

REGRESSION MODELLING FOR HEALTH PRACTITIONERS · CHAPTER 6

Poisson and Negative Binomial Regression

Count outcomes in health research

In health studies it is common to measure outcomes as counts of events: number of doctor visits, hospital readmissions, episodes of asthma, or adverse drug reactions. These data are non‐negative integers and often represent rates over a specified exposure time (e.g., person–years of follow‐up). Using linear regression to model counts is inappropriate because it can predict negative values and ignores the discrete nature of the data. As noted by UCLA’s count regression tutorial, count data are common across disciplines and count models are preferable to ordinary least squares; they can also incorporate exposure to model rates. The canonical count model is the Poisson regression; however, when the variance of the counts exceeds the mean (overdispersion), a negative binomial model may provide a better fit.

Poisson regression model

Let YiY_i denote the count of events for subject ii observed over exposure tit_i. Under the Poisson model, Yi∼Poisson(λiti)Y_i \sim \text{Poisson}(\lambda_i t_i) with mean equal to variance. The log of the mean count is modelled as a linear predictor: log(𝔼[Yi∣𝐱i])=log(ti)+β0+β1xi1+⋯+βpxip,\log(\mathbb{E}[Y_i \mid \mathbf{x}_i]) = \log(t_i) + \beta_0 + \beta_1 x_{i1} + \cdots + \beta_p x_{ip}, where log(ti)\log(t_i) is an offset ensuring that counts are adjusted for differing exposure times. Exponentiating a coefficient yields a rate ratio. For example, exp(βj)\exp(\beta_j) represents the multiplicative change in the rate of events for a one–unit increase in xjx_j.

Negative binomial regression

Poisson models assume the variance equals the mean. In practice, health count data often exhibit overdispersion due to unobserved heterogeneity or clustering. The negative binomial distribution introduces a dispersion parameter α\alpha such that Var(Yi)=𝔼[Yi]+α𝔼[Yi]2\operatorname{Var}(Y_i) = \mathbb{E}[Y_i] + \alpha\mathbb{E}[Y_i]^2. When α=0\alpha=0, the negative binomial reduces to the Poisson. Negative binomial regression uses the same log–linear predictor as the Poisson model but estimates α\alpha from the data.

Worked example

Suppose we study the number of emergency department visits for asthma over one year for 500 children. Predictors include exposure to tobacco smoke (Smoke), age (Age), and an exposure offset equal to follow‐up months. We model the rate of visits using Poisson and negative binomial regression and compare the fit.

Worked example

R

library(MASS)  # for glm.nb
# Assume df has: Visits (count), Smoke (0/1), Age, months (exposure time)
fit_pois <- glm(Visits ~ Smoke + Age + offset(log(months)),
               family = poisson, data = df)
summary(fit_pois)
exp(coef(fit_pois))  # rate ratios

fit_nb <- glm.nb(Visits ~ Smoke + Age + offset(log(months)), data = df)
summary(fit_nb)
exp(coef(fit_nb))  # rate ratios under NB model

Python (statsmodels)

import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf

# df: DataFrame with columns Visits, Smoke, Age, months
# Poisson model
model_p = smf.glm('Visits ~ Smoke + Age', data=df,
                  family=sm.families.Poisson(),
                  offset=np.log(df['months']))
result_p = model_p.fit()
print(result_p.summary())
print(np.exp(result_p.params))

# Negative binomial (NB2) model
model_nb = smf.glm('Visits ~ Smoke + Age', data=df,
                   family=sm.families.NegativeBinomial(),
                   offset=np.log(df['months']))
result_nb = model_nb.fit()
print(result_nb.summary())
print(np.exp(result_nb.params))

Julia

using DataFrames, GLM, Distributions, StatsBase

# df: DataFrame with Visits, Smoke, Age, months
fm = @formula(Visits ~ Smoke + Age + offset(log(months)))

# Poisson model
fit_pois = glm(fm, df, Poisson(), LogLink())
coeftable(fit_pois)
exp.(coef(fit_pois))

# Negative binomial model (NB2)
fit_nb = glm(fm, df, NegativeBinomial(), LogLink())
coeftable(fit_nb)
exp.(coef(fit_nb))

Interpretation

Exercises

Exercises

  1. Using the simulated asthma dataset described above, fit Poisson and negative binomial models. Report the estimated rate ratios and compare AIC values. Which model fits better? Examine residuals to assess model fit.

  2. Construct a dataset with 100 individuals where counts follow a Poisson distribution with mean λ=2\lambda=2, and simulate a predictor XX that increases λ\lambda by a factor of 1.5 when X=1X=1. Fit a Poisson regression and verify that the estimated rate ratio is close to 1.5.

  3. Explain why ordinary least squares regression is inappropriate for count data. Illustrate with a simple example in which OLS predicts negative counts.

  4. Investigate the impact of overdispersion by generating data with variance twice the mean. Fit both Poisson and negative binomial models and compare the estimated dispersion.

Code examples use illustrative datasets. Supply data with the named columns to run them.