Poisson Regression › Visualizing Poisson Regression

Michael BrenndoerferJune 21, 20258 min read
Machine Learning from ScratchAll chapters
Part 4 of 9Regression Models
Chapter 39Poisson Regression › Visualizing Poisson Regression
Reading section 3 of 8 · Visualizing Poisson Regression · 8 minSection 3 of 8 · 8 min

Book contents

Section 3 of 8 · 8 min read

Poisson Regression › Visualizing Poisson RegressionOne section · Sections in this chapter3 / 8 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

In the following visualizations, the model captures the general exponential trend in the data: as the predictor increases, the expected count rises rapidly, consistent with the log-link function shown in the third plot below. Most observed points cluster around the fitted curve, indicating that the model describes the main pattern in the data well.

However, there is some scatter around the curve, especially at higher predictor values, where the observed counts show more variability than the model predicts. This is typical for count data, as real-world data often exhibit overdispersion (variance greater than the mean), which the standard Poisson model does not account for. Despite this, the overall fit is reasonable.the model successfully captures the non-linear, non-negative relationship between the predictor and the expected count, and the exponential shape of the fitted curve matches the theoretical expectation for Poisson regression.

Overdispersion in Poisson Regression

The standard Poisson regression model assumes that the variance equals the mean (equidispersion). However, real-world count data often violates this assumption, showing overdispersion where the variance exceeds the mean. This can lead to underestimated standard errors and overly optimistic p-values. When overdispersion is detected through diagnostic tests, consider alternative models like negative binomial regression or zero-inflated Poisson models that can handle this common issue.

Out[4]:
Visualization
Bar plots showing Poisson distribution PMFs for different lambda values.
Poisson distribution probability mass functions for different rate parameters (λ). As λ increases, the distribution becomes more symmetric and shifts rightward. The Poisson distribution is characterized by its discrete, non-negative integer values and the property that variance equals the mean. This makes it well-suited for modeling count data where events occur independently at a constant rate.
Scatter plot showing variance vs mean relationship with equidispersion line.
The fundamental relationship between mean and variance in Poisson regression. The blue line shows the equidispersion assumption where variance equals the mean, which is characteristic of the Poisson distribution. The red dashed line represents overdispersed data where variance exceeds the mean, indicating potential violations of Poisson assumptions that may require alternative models like negative binomial regression.
Plot showing exponential link function curve.
The exponential log-link function that transforms the linear predictor to ensure positive expected counts. This transformation is important in Poisson regression because count data cannot be negative. The exponential function maps any real number to a positive value, allowing the model to handle both positive and negative coefficients while guaranteeing realistic predictions. The curve shows how small changes in the linear predictor can lead to large changes in expected counts.
Scatter plot with fitted exponential curve for Poisson regression.
A fitted Poisson regression model showing the relationship between a continuous predictor and count outcome. The blue points represent observed data, while the red curve shows the fitted exponential relationship. Notice how the curve is positive throughout and exhibits the characteristic exponential shape, with steeper increases for higher predictor values. The model captures the non-linear relationship between predictors and expected counts while ensuring all predictions remain non-negative.
Residual plot showing observed vs predicted values.
Residual analysis for the fitted Poisson regression model. The residuals (observed minus predicted values) are plotted against the fitted values to assess model adequacy. A well-fitting Poisson model should show residuals randomly scattered around zero without clear patterns. The red dashed line at y=0 represents the zero-residual line. Systematic patterns in the residuals might indicate model misspecification, overdispersion, or the need for additional predictors.
Bar chart showing coefficient interpretations as rate ratios.
Interpretation of Poisson regression coefficients as rate ratios. Each coefficient β is transformed using the exponential function to show the multiplicative effect on the expected count. A coefficient of 0.5 means the expected count increases by 65% (1.65x), while -0.5 means it decreases by 39% (0.61x). This multiplicative interpretation makes Poisson regression results intuitive for communicating the practical impact of predictor variables on count outcomes.

The final plot below demonstrates how to interpret Poisson regression coefficients in terms of rate ratios, which describe the multiplicative change in the expected count for a one-unit increase in a predictor. In Poisson regression, the model predicts the logarithm of the expected count as a linear function of the predictors:

log⁡(λ)=β0+β1x1+⋯\log(\lambda) = \beta_0 + \beta_1 x_1 + \cdots

where:

  • λ\lambda is the expected count (the mean parameter of the Poisson distribution)
  • β0\beta_0 is the intercept coefficient
  • β1,…\beta_1, \ldots are the coefficients for each predictor
  • x1,…x_1, \ldots are the predictor variables

To understand the effect of a predictor, we exponentiate its coefficient, eβe^{\beta}, which gives the rate ratio.

For example, if a coefficient β=0.5\beta = 0.5, then:

e0.5≈1.6487≈1.65e^{0.5} \approx 1.6487 \approx 1.65

This means that for each one-unit increase in the predictor, the expected count is multiplied by 1.65, or increases by 65%:

Percent increase=(1.65−1)×100%=0.65×100%=65%\text{Percent increase} = (1.65 - 1) \times 100\% = 0.65 \times 100\% = 65\%

This happens because the log link function in the model means that a one-unit increase in the predictor adds 0.5 to the log of the expected count, so the expected count itself is scaled by e0.5e^{0.5}.

Similarly, if β=−0.5\beta = -0.5, then:

e−0.5≈0.6065≈0.61e^{-0.5} \approx 0.6065 \approx 0.61

This means the expected count is multiplied by 0.61, or decreases by 39%:

Percent decrease=(1−0.61)×100%=0.39×100%=39%\text{Percent decrease} = (1 - 0.61) \times 100\% = 0.39 \times 100\% = 39\%

In other words, the expected count is 39% lower than it would be if the predictor had not increased.

This rate ratio interpretation is a key feature of Poisson regression: it allows us to express the effect of predictors as simple multiplicative changes in the expected count, making the results easy to communicate and understand in practical terms.