Articles
Poisson Regression Interview Questions: Exposure, Overdispersion, and Count Predictions
Practice Poisson regression interview answers with unequal exposure, log offsets, count and rate predictions, and an original overdispersion diagnostic.
“Site A recorded more incidents than Site B. Which one is riskier?” A strong answer asks how long each site was observed before choosing a model. A count of eight over one hour is not the same rate as eight over eight hours. Poisson regression connects a nonnegative count to predictors, but exposure and variability determine whether its coefficients and uncertainty mean what the interviewer thinks they mean.
This article works through one original eight-row dataset, a log-exposure offset, a prediction table, and an overdispersion check. Evidence boundary: Penn State's STAT 504 and official statsmodels/scikit-learn documentation support the model properties and APIs; the numbers and scenarios below are original editorial examples. No candidate reports are used for process claims.
First question: are you predicting a count or a rate?
Define one row and its exposure. A service may count incidents per machine-hour, a hospital may count admissions per patient-day, and an app may count failures per thousand requests. The exposure is the amount of opportunity for events to occur, not simply another outcome. If one row spans twice as much at-risk time as another, equal rates imply roughly twice the expected count. Rates are counts divided by exposure; raw counts are not directly comparable when denominators differ.
Penn State STAT 504's Poisson regression lesson gives the rate form log(mu_i / t_i) = alpha + beta*x_i, equivalently log(mu_i) = alpha + beta*x_i + log(t_i). Here Y_i is the observed count, mu_i its expected count, and t_i > 0 the exposure. The log of exposure is an offset: its coefficient is fixed at one. A normal feature gets an estimated coefficient; an offset encodes a known proportional scaling. This distinction is an interview staple because treating log(exposure) as a free predictor asks a different modeling question.
If all rows share the same exposure, a simple log-link count model can omit a separate offset without distorting relative exposure. If exposure varies, omitting it can make a high-traffic site appear intrinsically risky merely because it had more opportunities for events. Check that exposure is positive and in consistent units. An observed zero count with positive exposure is valid; an exposure of zero cannot be logged and needs a data-contract decision, not an arbitrary tiny replacement.
Worked exercise: unequal windows and an intercept-only baseline
Suppose eight monitoring windows have exposure measured in standardized machine-hours. Counts fluctuate more than a simple Poisson model will expect; the exercise is deliberately constructed to make that problem visible.
| Window | Exposure, hours | Observed incidents | Observed incidents per hour |
|---|---|---|---|
| 1 | 1 | 1 | 1.00 |
| 2 | 1 | 7 | 7.00 |
| 3 | 2 | 2 | 1.00 |
| 4 | 2 | 14 | 7.00 |
| 5 | 4 | 5 | 1.25 |
| 6 | 4 | 25 | 6.25 |
| 7 | 8 | 8 | 1.00 |
| 8 | 8 | 40 | 5.00 |
Total events are 102 over 30 exposure-hours. With only an intercept and the offset log(t_i), the fitted common event rate is 102/30 = 3.4 incidents per hour. The expected count for one hour is 3.4, for two hours 6.8, for four hours 13.6, and for eight hours 27.2. A count prediction and a rate prediction are therefore related but not identical: the predicted rate is 3.4 for all eight rows under this baseline, while predicted counts scale with each row's exposure.
| Exposure | Baseline predicted count | Baseline predicted rate |
|---|---|---|
| 1 hour | 3.4 | 3.4 per hour |
| 2 hours | 6.8 | 3.4 per hour |
| 4 hours | 13.6 | 3.4 per hour |
| 8 hours | 27.2 | 3.4 per hour |
Do not confuse the unweighted average of the eight observed rates with the pooled rate. The pooled rate weights each window by its exposure because an eight-hour window contributes more event opportunity than a one-hour window. Here the paired low/high windows are designed to suggest unmodeled heterogeneity: perhaps two device classes share the same exposure durations but have very different underlying incident rates. Before adding a fancy distribution, ask whether a missing covariate or a bad denominator explains the split.
Reproduce the baseline and the dispersion check
The following NumPy code calculates the intercept-only Poisson maximum-likelihood rate and Pearson diagnostic directly. It does not claim to fit a multi-feature model. Running it locally yielded the values shown below.
import numpy as np
exposure = np.array([1, 1, 2, 2, 4, 4, 8, 8], dtype=float)
count = np.array([1, 7, 2, 14, 5, 25, 8, 40], dtype=float)
assert np.all(exposure > 0)
rate = count.sum() / exposure.sum()
expected = exposure * rate
pearson_chi2 = np.sum((count - expected) ** 2 / expected)
df_resid = len(count) - 1 # one fitted intercept
phi = pearson_chi2 / df_resid
print(rate, expected, pearson_chi2, df_resid, phi)
The output is rate 3.4, expected counts [3.4, 3.4, 6.8, 6.8, 13.6, 13.6, 27.2, 27.2], Pearson chi-square 51.0882, residual degrees of freedom 7, and ratio phi ≈ 7.2983. That large ratio is a warning that observed variability is far above what this simple fitted Poisson mean-variance relationship would predict. It is not a diagnosis that every Poisson model on the business problem must fail. The intercept-only model intentionally ignores a plausible high/low risk subgroup.
For a more realistic regression, include prespecified covariates such as device class, site, workload, or hour of day, while keeping the exposure offset. Recompute residual diagnostics after fitting. If the dispersion persists, consider a negative binomial count model, robust or quasi-likelihood standard errors when the mean specification is defensible, or a model for excess zeros if a real zero-generating mechanism exists. Pick an alternative for the observed failure and decision objective, not because its name sounds more advanced.
Second question: how does the log link change interpretation?
A log-link Poisson model has mu_i = exposure_i * exp(beta_0 + beta_1*x_i + ...). Exponentiating a coefficient gives a multiplicative change in the expected rate for a one-unit predictor change, holding the other predictors and exposure constant. For a binary device indicator, exp(beta_1) = 1.5 would mean a modeled rate 50% higher for the indicated class, subject to the model and data. It would not mean 1.5 extra incidents in every window; the absolute count difference grows with exposure.
If the baseline predicted rate is 3.4 per hour and a hypothetical covariate multiplier is 1.5, an eight-hour prediction is 8 × 3.4 × 1.5 = 40.8 expected incidents, whereas a one-hour prediction is 5.1. These are conditional means, not promises that observed counts will equal 40.8 or 5.1. A count is discrete; a predicted mean need not be. For a business report, show the relevant exposure, predicted count, predicted rate, and uncertainty separately so the reader cannot mistake one for another.
Do not exponentiate a coefficient and call it an odds ratio. Logistic regression uses odds for a binary outcome; Poisson log-link coefficients describe rate ratios under the specified exposure model. If the event count is actually bounded by a known number of trials, ask whether a binomial model with the trial denominator better represents the data. If events can recur for the same person or device, assess dependence and clustering before trusting a simple independent-count standard error.
Third question: what does overdispersion change?
A basic Poisson model has conditional variance equal to its conditional mean. Official statsmodels GLM documentation lists that mean-variance relation for the Poisson family. Real count data can be more variable because of latent groups, bursts, contagion, repeated observations, omitted predictors, or recording mistakes. In that case, naive model-based standard errors can be too small and intervals too confident even if a mean prediction looks reasonable.
A Pearson statistic divided by residual degrees of freedom is a useful first screen, as in our exercise, but it needs context. With very few rows, individual outliers can dominate it. Predicted means near zero, dependence, or model misspecification can distort interpretation. Plot observed counts and residuals against exposure and important covariates; inspect zeros and tails; compare behavior by time or site. Do not announce “negative binomial” solely because a single ratio exceeds one. Explain which mechanism you are trying to capture and how you will validate it on held-out periods or sites.
The Penn State lesson explicitly discusses offsets for unequal observation windows and negative binomial as an option for overdispersion. A negative binomial variance can exceed the mean, but selecting it does not repair a missing exposure denominator or wrong join. A quasi-Poisson or robust standard error can adjust inference without necessarily changing the predicted mean, which may be useful if the mean equation is credible. If the goal is predicting extreme tail counts for capacity planning, evaluate predictive calibration and tail coverage, not just coefficient significance.
Fourth question: how would you evaluate predictions?
Split data along the axis on which the model will be used. For recurring sites, a random row split may leak site-specific patterns into both train and test; a future-time holdout or held-out sites may better represent deployment. Compare a simple exposure-adjusted baseline with a covariate model. Report count error by exposure band and rate error where rates are meaningful. A model that predicts total counts well by favoring long windows may still misrank risk among short windows.
Calibration asks whether groups of windows predicted to have, say, an average of three incidents actually average near three over many comparable windows. Discrimination asks whether high-risk windows tend to rank above low-risk ones. Zero frequency and upper-tail coverage matter if the product decision involves alerts or staffing. Scikit-learn's generalized-linear-model documentation describes Poisson regression with a log link; using an implementation does not remove the need to align exposure, target, weights, and evaluation.
When the interviewer asks for “the probability of at least one event,” the mean count alone is not that probability. Under a valid Poisson model with mean mu, it is 1 - exp(-mu). In our intercept-only example, a one-hour window has mu=3.4, so the modeled probability is about 0.967. Because the example is highly overdispersed, that probability is a model output to question, not an empirical risk statement. A model with extra zeros could produce a different probability even at the same average count.
Sources and Further Reading
- Penn State STAT 504, Poisson Regression — offset, rate model, and overdispersion teaching notes.
- statsmodels, Generalized Linear Models — official Poisson-family mean, variance, and link documentation.
- scikit-learn, Generalized Linear Models — official implementation guidance and log-link overview.