Tutorials › Exam PA - Predictive Analytics › Poisson GLMs For Event Counts

Exam PA · GLM Families and Model Construction · Tutorial 303 of 966

Poisson GLMs For Event Counts

Specify a Poisson count model, fit it in R, interpret fitted means, and diagnose design mismatches that can distort count predictions.

Intermediate 11 min read

What You'll Learn

  • Define a Poisson response and its conditional mean and variance assumptions.
  • Specify a log-link model and interpret its coefficients as multiplicative effects.
  • Fit a Poisson GLM in R and obtain predictions on the count scale.
  • Distinguish event counts from grouped binary outcomes and event-level records.
  • Check that zeros, observation units, and exposure periods match the prediction target.

Why the Count and Observation Unit Matter

A Poisson generalized linear model (GLM) is a standard choice when the outcome is a nonnegative integer count, such as the number of service incidents at a site during a month. Its usefulness depends on getting the data design right: each response must be the count for a clearly defined observation unit and observation period. If records with zero events are dropped, or if a row represents an event rather than an exposed unit, the model may describe a different population from the one intended.

This tutorial specifies a Poisson response with a log link, shows how to fit it in R, and explains what the fitted quantities mean. The model is aligned with the SOA Exam PA (Predictive Analytics) syllabus.

Definition: A response \(Y_i\) is a count when it records the number of occurrences in observation unit \(i\) during a defined period. A Poisson GLM assumes that, conditional on the predictors for unit \(i\), \(Y_i\) has a Poisson distribution with mean \(\mu_i>0\). Thus \(Y_i\) can be \(0,1,2,\ldots\), and its conditional variance equals its conditional mean.

The Poisson probability function is \(P(Y_i=y_i)=e^{-\mu_i}\mu_i^{y_i}/y_i!\) for nonnegative integer \(y_i\). Consequently, \(E[Y_i\mid x_i]=\mu_i\) and \(\operatorname{Var}(Y_i\mid x_i)=\mu_i\). The usual model also treats observations as conditionally independent given their predictors. These are assumptions about the response after conditioning on the model predictors, not claims that all observations have the same mean.

The Log-Link Poisson Model

Let \(x_{i1},\ldots,x_{ip}\) denote the predictors for observation \(i\). The Poisson log-link model sets the logarithm of the conditional mean equal to a linear predictor:

$$ Y_i\mid x_i\sim\operatorname{Poisson}(\mu_i), \qquad \log(\mu_i)=\eta_i=\beta_0+\beta_1x_{i1}+\cdots+\beta_px_{ip}. $$

Equivalently, \(\mu_i=\exp(\eta_i)\). Since an exponential is always positive, this link produces a valid positive mean even when the linear predictor is negative. The coefficient \(\beta_j\) is an additive change in log mean for a one-unit increase in \(x_{ij}\), holding the other predictors fixed. On the mean scale, that change multiplies the expected count by \(e^{\beta_j}\). For a change of \(c\) units, the multiplier is \(e^{c\beta_j}\).

Key interpretation: In a Poisson GLM with a log link, \(e^{\beta_j}\) is a conditional mean ratio for a one-unit increase in predictor \(x_j\), provided the other predictors are held fixed. It is not an additive change in the expected count.

The response must match the question. A count of events per site-month is not the same outcome as whether a site-month had any events. The latter is a binary response, even if the event originated as a count. Likewise, a table with one row per event does not by itself represent counts per site-period: it omits the units with zero events unless those units are separately retained.

Why the Log Link Gives Multiplicative Effects

The multiplicative interpretation follows directly from the model, rather than being a separate approximation. Hold all predictors except \(x_j\) fixed and compare a unit with \(x_j=x\) to one with \(x_j=x+1\). Their linear predictors differ by \(\beta_j\), so their means have the ratio:

$$ \frac{\mu(x+1)}{\mu(x)} = \frac{\exp(\eta(x)+\beta_j)}{\exp(\eta(x))} = \exp(\beta_j). $$

This ratio does not depend on the starting value \(x\), although the absolute difference in expected counts generally does. For example, a mean ratio of 1.5 corresponds to an increase of 0.5 when the starting mean is 1, but an increase of 2 when the starting mean is 4.

Fitting and Predicting in R

In R, glm fits a GLM. Specify the Poisson family and log link explicitly so the response model is clear. The response column should contain nonnegative integer counts; predictor columns should be represented in forms appropriate to their meanings. For example, a categorical site classification should be stored as a factor rather than as an arbitrary numerical code.

A basic call is fit = glm(y ~ x1 + x2, family = poisson(link = "log"), data = dat). The fitted coefficients are available through coef(fit), and the fitted conditional means for the training observations through fitted(fit). For new observations, predict(fit, newdata = newdat, type = "response") returns predictions on the mean-count scale. Without type = "response", predictions are generally on the link scale, meaning the log-mean scale.

A formula such as y ~ x includes an intercept by default. The intercept is the log expected count when the numeric predictors are zero and categorical predictors are at their reference levels. That interpretation is useful only if this combination is meaningful; a prediction at an artificial predictor value should not be given an unsupported practical interpretation.

Worked Example: An Intercept-Only Model for Comparable Sites

A hypothetical service team records the number of equipment incidents at five comparable depots during one complete month. The counts are 2, 0, 3, 1, and 4. Each row is one depot-month, every depot is observed for the same full month, and the model has no predictors. Estimate the Poisson mean and the probability of zero incidents for a depot-month.

Method. In an intercept-only Poisson model, all observations share a mean \(\mu\). The log-likelihood, ignoring no terms that depend on \(\mu\), is \(\ell(\mu)=\sum_i[y_i\log(\mu)-\mu-\log(y_i!)]\). Its derivative is \(\sum_i y_i/\mu-n\). Setting this equal to zero gives \(\hat{\mu}=\sum_i y_i/n\).

Here \(n=5\) and the total count is \(2+0+3+1+4=10\), so \(\hat{\mu}=10/5=2\) incidents per depot-month. The estimated intercept is \(\log(2)=0.6931\), rounded to four decimal places. R can fit this model with dat = data.frame(y = c(2, 0, 3, 1, 4)) and fit = glm(y ~ 1, family = poisson(link = "log"), data = dat).

For a Poisson mean of 2, the probability of zero incidents is \(P(Y=0)=e^{-2}2^0/0!=e^{-2}=0.1353\), rounded to four decimal places. The fitted mean is consistent with the observed average of 2, which checks the intercept-only estimate.

Common mistake avoided: Dropping the zero-count depot would leave four depots and a mean of \(10/4=2.5\). That is not the average for the five observed depot-months; zero-event units are valid observations and must remain in the count data.

Worked Example: Interpreting a Site-Risk Predictor

A hypothetical analyst records monthly incident counts for three low-risk sites and three high-risk sites, with every site observed for one complete month. The low-risk counts are 1, 2, and 1; the high-risk counts are 2, 4, and 3. Fit the two-group log-link model conceptually, interpret its coefficient, and calculate the probability of at least one incident at a high-risk site-month.

Method. Use a binary predictor \(x\), equal to 0 for low risk and 1 for high risk. Because this model has one separate mean for each of two groups, its fitted group means are the observed group averages. The low-risk mean is \((1+2+1)/3=4/3\). The high-risk mean is \((2+4+3)/3=9/3=3\).

The intercept is \(\hat{\beta}_0=\log(4/3)=0.2877\), and the high-risk coefficient is the difference between the group log means: \(\hat{\beta}_1=\log(3)-\log(4/3)=\log(9/4)=0.8109\). Coefficients are rounded to four decimal places. The high-versus-low mean ratio is \(e^{\hat{\beta}_1}=9/4=2.25\). Thus the fitted mean is 2.25 times as large for high-risk sites, not 2.25 incidents larger.

For a high-risk site-month the fitted mean is \(\exp(0.2877+0.8109)\), which equals 3 using the unrounded coefficients. Hence \(P(Y\geq 1)=1-P(Y=0)=1-e^{-3}=0.9502\), rounded to four decimal places. As a consistency check, the fitted group means reproduce the observed totals: \(3(4/3)=4\) low-risk incidents and \(3(3)=9\) high-risk incidents.

In R, the predictor can be coded as a factor with low risk as its reference level. The fitted high-risk coefficient then represents the log mean ratio. Common mistake avoided: Treating the coefficient \(0.8109\) as an increase of about 0.81 incidents ignores that the model is linear in the log mean.

Worked Example: Preserving Zero-Count Observation Units

A hypothetical monitoring program follows each of six clinic-months for the same full month. The event counts are 0, 1, 2, 0, 1, and 3. An analyst proposes retaining only months in which an event occurred. Identify the correct intercept-only estimate and calculate the probability of at least one event for a clinic-month.

Method. The observation unit is the clinic-month, not an individual event. The six outcomes include two valid zero-count months. Their total is \(0+1+2+0+1+3=7\), so the intercept-only estimate is \(\hat{\mu}=7/6=1.1667\) events per clinic-month, rounded to four decimal places. In R, retain the zeros in dat = data.frame(y = c(0, 1, 2, 0, 1, 3)) and fit glm(y ~ 1, family = poisson(link = "log"), data = dat).

Under the fitted model, \(P(Y\geq1)=1-P(Y=0)=1-\exp(-7/6)=0.6886\), rounded to four decimal places. The complementary zero probability is \(\exp(-7/6)=0.3114\), so the two probabilities sum to 1. If the two zero months were deleted, the incorrect average would be \(7/4=1.75\) among event-positive months, not the mean count across all six monitored clinic-months.

Common mistake avoided: A table containing only events has no information about how many monitored units had zero events. The observation frame must include the full set of units to which the prediction is intended to apply.

Check the Count-Data Design Before Fitting

A Poisson GLM is not made appropriate merely by using a count-looking column. Check the response, unit, and observation period together. The following questions are useful before fitting or interpreting the model:

  • Is the response a nonnegative integer count, rather than a yes/no outcome or a continuous measurement?
  • Does each row represent one unit over a defined period, such as a policy-year, clinic-month, or machine-shift?
  • Are units with zero events included when they belong to the target population?
  • Are the observation periods comparable? If exposure durations differ, a model that treats each row as the same opportunity for events may not answer the intended rate question.
  • Is conditional independence and the Poisson mean-variance relationship a reasonable working assumption after accounting for the predictors?

The equal-period examples here deliberately use comparable exposure windows. If exposure differs across observations, the simple specification shown here does not automatically compare event rates fairly; the exposure must be handled in the model design rather than ignored. A Poisson model also imposes \(\operatorname{Var}(Y_i\mid x_i)=E[Y_i\mid x_i]\). Strong departures from this assumption can affect inference and indicate that the model needs further assessment.

A final distinction is between a count and a grouped binary outcome. For example, “three of ten members experienced an event” describes three successes among ten trials and is naturally represented as grouped binomial data. “Three events occurred at this site during the month” is a count response. The number 3 alone does not determine the family; the outcome’s meaning and observation unit do.

Key takeaway: Specify the Poisson response as a count for a defined observation unit and period, use \(\log(\mu_i)=x_i^\mathsf{T}\beta\) to keep fitted means positive, and interpret exponentiated coefficients as conditional mean ratios. Preserve valid zero-count units and make sure the data structure matches the prediction target.

Check Your Understanding

Work each problem through by identifying the count unit before using the model.

  1. A hypothetical safety team observes four comparable warehouse-months with counts 0, 2, 1, and 1. For an intercept-only Poisson model, find the fitted mean and the fitted probability of zero events. (Answer: \(\hat{\mu}=1\); \(P(Y=0)=0.3679\), to four decimals.)
  2. A fitted log-link model has \(\beta_0=-0.2\) and a numeric predictor coefficient \(\beta_1=0.5\). Find the fitted mean at \(x=2\) and the mean ratio for a one-unit increase in \(x\). (Answer: \(\hat{\mu}=e^{0.8}=2.2255\); mean ratio \(e^{0.5}=1.6487\), to four decimals.)
  3. A hypothetical service network records counts 0, 1, 2 in group A and 1, 2, 3 in group B. With a group indicator and equal observation periods, find each fitted group mean and the log-link coefficient for B relative to A. (Answer: means 1 and 2; coefficient \(\log(2)=0.6931\), to four decimals.)
  4. For a Poisson GLM, a particular predictor profile has linear predictor \(\eta=\log(2)+\log(1.5)\). Calculate the fitted mean and the probability of exactly two events. (Answer: \(\hat{\mu}=3\); \(P(Y=2)=e^{-3}3^2/2!=0.2240\), to four decimals.)
  5. A hypothetical analyst has one record per reported event at a facility, but no records for facility-months with no events. Can those rows alone estimate the mean number of events per facility-month? State the design correction required. (Answer: No; construct the full facility-month observation frame, including zero-count months, and record the count for each facility-month.)
Clinical Biostats