Count Data Regression Lab

Regression Count Outcomes

Fit and interpret Poisson, Negative Binomial (NB2), and Two-Part Hurdle regression models for discrete marketing event counts such as orders, support tickets, store visits, and repeat shipments. Compare count distributions, adjust for unequal observation windows with exposure offsets, and translate log-count slopes into multiplicative Incidence Rate Ratios (IRRs).

👨‍🏫 Professor Mode: Guided Learning Experience

New to count data regression? Enable Professor Mode for step-by-step guidance through Incidence Rate Ratios (IRRs), overdispersion testing, exposure offsets, and two-part zero hurdles!

OVERVIEW & WHAT THIS TOOL SOLVES

Many core marketing outcomes are discrete event counts—how many deliveries a diner places in a quarter, how many support tickets a B2B client opens, or how many times a household reorders pet food. Standard linear regression fails on count data because a straight line can predict impossible negative counts and ignores the fact that count variance grows with the average rate. Count Data Regression models expected volume on a multiplicative scale while accounting for unequal observation windows, heavy-buyer overdispersion, and two-stage conversion hurdles.

🎯 Questions It Answers

  • By what percentage does a marketing lever or customer tier multiply the expected event rate, holding other drivers constant?
  • Are apparent p-values from a basic Poisson model genuine, or are they false positives caused by heavy-buyer overdispersion?
  • Do initial trial conversion (any order vs. zero) and repeat order depth follow different behavioral drivers?

📂 What Data You Need

  • Case-Level Rows: One row per customer, account, store, or time window (at least 15 observations per predictor term recommended).
  • 1 Non-Negative Integer Count Outcome: Event totals coded as 0, 1, 2, 3, and up.
  • Predictors & Optional Exposure: Continuous or categorical drivers, plus an optional positive time-at-risk or opportunity column.

💡 What You'll Discover

  • Incidence Rate Ratios (IRRs): Multiplicative rate multipliers, percentage rate shifts, and concrete expected-count shifts.
  • Guided Model Selection: Automatic head-to-head diagnostics across Poisson GLM, Negative Binomial (NB2), and Two-Part Hurdle Count models.
  • Rootogram & Dispersion Curves: Visual checks for excess zeros, variance-to-mean scaling, and out-of-sample holdout validation.
🔍 Key Nuances & Common Traps to Watch For
  • Trap 1 — The Naive Poisson Overdispersion Trap: Standard Poisson regression assumes that the conditional variance equals the conditional mean. In real customer data, unobserved loyalty and usage habits almost always create overdispersion (variance much larger than the mean), causing Naive Poisson to underestimate standard errors and flag noise variables as "statistically significant." Always check the Overdispersion Likelihood-Ratio Test and switch to Negative Binomial (NB2) when variance exceeds the mean.
  • Trap 2 — Ignoring Unequal Observation Windows (Exposure Offset): If Customer A has been active for 18 months and Customer B joined 2 months ago, comparing their raw cumulative support tickets or orders confuses tenure with rate. Selecting an Exposure Offset models the event rate per unit of time-at-risk.
  • Trap 3 — Blurring First-Time Trial and Repeat Volume: An acquisition discount often boosts first-time conversion while attracting deal-chasers who never reorder. A single-equation count model averages those two opposite effects into a flat slope; the Two-Part Hurdle Count model separates Stage 1 conversion from Stage 2 repeat volume.
  • Trap 4 — Reading IRRs Additively: An Incidence Rate Ratio of 1.25 means a +25% multiplicative lift. That adds +0.5 events for a light segment averaging 2.0 events, but +2.5 events for a heavy segment averaging 10.0 events.
📐 Under the Hood: Model Equations & Variable Definitions
1. Log-Link Mean, Exposure Offset & Incidence Rate Ratio (IRR)
\[ \ln(\mu_i) = \ln(E_i) + \beta_0 + \beta_1 X_{1i} + \cdots + \beta_p X_{pi} \quad \Longleftrightarrow \quad \mu_i = E_i \cdot \exp(\beta_0 + \beta_1 X_{1i} + \cdots + \beta_p X_{pi}), \qquad \mathrm{IRR}_j = e^{\beta_j} \]
💬 Read it in plain English: Predictors combine linearly on the natural-log scale so that exponentiating the score guarantees a strictly positive expected count (μi), scales proportionally with the observation window (Ei), and turns each slope into a multiplicative rate factor (IRRj = eβj).
Yi
Observed Event Count YOUR DATA ⓘ
Actual integer number of events (e.g., orders, tickets, visits) recorded for observation i.
μi
Expected Count OUTPUT ⓘ
Predicted mean event count for row i; dividing by exposure gives the event rate λi = μi / Ei.
Ei
Exposure / Time-at-Risk Offset YOUR DATA ⓘ
Observation window for row i (e.g., active account months); defaults to Ei = 1 when all rows share an equal window.
X1i … Xpi
Predictor Variables YOUR DATA ⓘ
Values of the p continuous drivers and dummy-coded categorical levels for observation i.
β0, βj
Log-Count Intercept & Slopes ESTIMATED ⓘ
Additive change in ln(μi) per 1-unit increase in predictor Xj holding all other predictors constant.
IRRj = eβj
Incidence Rate Ratio OUTPUT ⓘ
Factor by which the expected count multiplies per 1-unit increase in Xj; (eβj − 1) × 100% is the percentage rate change.
2. Poisson vs. Negative Binomial (NB2) Variance & Dispersion Inference
\[ \mathrm{Var}_{\text{Pois}}(Y_i \mid X_i) = \mu_i, \qquad \mathrm{Var}_{\text{NB2}}(Y_i \mid X_i) = \mu_i + \alpha\mu_i^2, \qquad \phi = \frac{1}{n-p}\sum_{i=1}^{n}\frac{(Y_i - \hat{\mu}_i)^2}{\hat{\mu}_i}, \qquad G^2 = 2\bigl(\ell_{\text{NB2}} - \ell_{\text{Pois}}\bigr) \]
💬 Read it in plain English: Poisson forces the variance to equal the mean (α = 0), whereas Negative Binomial (NB2) adds a quadratic dispersion term (αμi2) so unobserved customer heterogeneity is properly reflected in wider, honest standard errors.
α
NB2 Overdispersion Parameter ESTIMATED ⓘ
Controls how rapidly conditional count variance grows above the mean (α = 0 reduces NB2 to Poisson).
ϕ
Pearson Dispersion Ratio INFERENCE ⓘ
Diagnostic ratio of empirical variance to Poisson mean; values above 1.5× warn that Poisson standard errors are understated.
G2
Overdispersion Likelihood-Ratio Test INFERENCE ⓘ
Formal log-likelihood improvement test verifying whether NB2 significantly outperforms equidispersed Poisson.
zj, SE(β̂j)
Wald z-Statistic & Standard Error INFERENCE ⓘ
Signal-to-noise ratio testing whether predictor j significantly shifts the log-count rate.
3. Two-Part Hurdle Count Decomposition (Stage 1 Binary Logit × Stage 2 Zero-Truncated Poisson)
\[ E[Y_i \mid X_i] = \underbrace{\pi_i}_{\text{Stage 1: } P(Y_i > 0)} \times \underbrace{\frac{\lambda_i}{1 - e^{-\lambda_i}}}_{\text{Stage 2: } E[Y_i \mid Y_i > 0]}, \qquad \pi_i = \frac{1}{1 + e^{-X_i\gamma}}, \qquad \lambda_i = E_i e^{X_i\beta} \]
💬 Read it in plain English: The Two-Part Hurdle model estimates two separate equations: a logistic regression for whether the customer crosses the zero hurdle at all (Stage 1), and a zero-truncated count regression for how many events active customers generate (Stage 2).
πi, γ
Stage 1 Conversion Probability & Logit Slopes ESTIMATED ⓘ
Probability that customer i experiences at least one event (Yi > 0), with Stage 1 Odds Ratios ORj = eγj.
λi / (1 − e−λi)
Stage 2 Conditional Active Count OUTPUT ⓘ
Expected repeat count conditional on crossing the hurdle (Yi ≥ 1), driven by Stage 2 rate multipliers IRRj = eβj.

DATA SOURCE

Use a Case Study

Select a marketing case study above to explore overdispersion (Crave Food Delivery), exposure offsets (Mosaic Analytics), two-part zero hurdles (Copperpaw Pet Supply), or clean Poisson equidispersion vs. negative OLS predictions (Thistledown Market).

Upload Your Data

Drag & Drop raw data file (.csv, .tsv, .txt)

Include headers; one non-negative integer count outcome (0, 1, 2, ...), optional exposure column, and up to 40 predictors (max 5,000 rows).

No file uploaded.

INPUTS & SETTINGS

VISUAL OUTPUT

Marginal Expected Count & Rate Effect (\(\hat{\mu}\))

Shows how the predicted count \(\hat{\mu}\) (or rate per exposure unit) changes across the focal predictor while holding other predictors constant. Because count regression uses a log link, the expected count follows a smooth exponential curve that stays strictly above zero.

Interpretation Aid

Curved vs. Straight Line: In a log-link count model, each 1-unit increase in \(X\) multiplies the expected count by \(\text{IRR} = e^{\beta}\). That creates an upward-accelerating curve when \(\text{IRR} > 1\) and a decaying curve that asymptotes cleanly toward zero (never crossing below zero) when \(\text{IRR} < 1\).

Confidence Ribbon: The shaded band shows the confidence interval for the mean expected count at those predictor settings. Switching from Naive Poisson to Negative Binomial (NB2) on overdispersed data widens this ribbon to reflect true customer-to-customer variability.

Why Linear OLS Fails (Benchmark Overlay): Checking the benchmark box overlays the ordinary least squares line \(\hat{Y} = X\hat{\beta}_{\text{OLS}}\). When a predictor has a strong negative effect (such as distance from a store or price), the straight line plunges below zero into impossible negative counts.

Incidence Rate Ratio (IRR) Forest Plots (Split by Predictor Type)

Compares the multiplicative effect size (\(\text{IRR} = e^{\hat{\beta}}\)) and confidence interval of every predictor against the vertical dashed null line at \(\text{IRR} = 1.0\) (no change in expected count rate).

Continuous Predictors — IRR Forest Plot

IRR per 1-unit increase (vertical dashed line at IRR = 1 = no effect).

Categorical Predictors — IRR Forest Plot

IRR for each category vs. its reference group (vertical dashed line at IRR = 1 = no effect).

Interpretation Aid

The Null Line is 1.0 (Not 0.0): Because an Incidence Rate Ratio is a multiplier (\(\text{IRR} = e^{\hat{\beta}}\)), an IRR of \(1.00\) means multiplying the expected count by \(1.00\) (0% change). Points to the right of 1.0 increase the event rate (\(\text{IRR} = 1.35 \Rightarrow +35\%\)); points to the left of 1.0 reduce the event rate (\(\text{IRR} = 0.65 \Rightarrow -35\%\)).

Statistical Significance: If a predictor's horizontal confidence bar crosses the vertical dashed line at \(\text{IRR} = 1.0\), the rate multiplier is not statistically distinguishable from 1.0 at your chosen \(\alpha\) level.

Why Continuous and Categorical Are Split: Continuous IRRs measure the multiplier per 1-unit change in a numeric scale (e.g., per +1% discount or +1 mile), whereas categorical IRRs measure a discrete group-vs-reference jump (e.g., CravePass Annual vs. Standard). Plotting them separately keeps small-unit continuous slopes readable alongside large group multipliers.

Observed vs. Model-Predicted Count Distribution (Rootogram / Zero-Gap Check)

Compares the actual percentage of rows at each integer count \(k \in \{0, 1, 2, \dots, 15+\}\) against the probability mass predicted by Poisson, Negative Binomial (NB2), and Two-Part Hurdle models.

Interpretation Aid

Look at \(k = 0\) First (The Zero-Count Gap): In many marketing datasets, far more customers have \(Y = 0\) than a standard Poisson distribution predicts (\(\text{Observed } \%_{Y=0} \gg \text{Poisson } \%_{Y=0}\)). If the grey Observed bar at \(k = 0\) towers above the Poisson marker, you have excess zeros caused either by heavy overdispersion (handled by NB2) or by a structural conversion hurdle (handled precisely by the Two-Part Hurdle model).

Look at the Right Tail (\(k \ge 6\)): Poisson probability mass dies out rapidly at high counts. When a dataset contains heavy repeat buyers, NB2 and Hurdle models shift probability mass into the right tail to match observed high-volume customers.

Empirical Mean–Variance Relationship & Overdispersion Curve

Groups observations into deciles of fitted expected count \(\hat{\mu}\) and plots each bin's empirical sample variance \(s_Y^2\) against its mean \(\bar{\mu}\), overlaid against the Poisson equidispersion line (\(V = \mu\)) and the fitted NB2 quadratic curve (\(V = \mu + \hat{\alpha}\mu^2\)).

Interpretation Aid

Poisson Assumption (Dashed 45° Line): Standard Poisson regression assumes that a segment with an average of \(\mu = 4\) orders also has a variance of \(4\). If the empirical dots sit closely along the dashed line, Poisson equidispersion holds.

Overdispersion (Curving Above the Line): When unobserved customer habits vary within each segment, empirical variance grows quadratically (\(\text{Var}(Y) \approx \mu + \alpha\mu^2\)). When the dots climb steeply above the dashed line and track the solid NB2 curve, Negative Binomial regression is required so your standard errors and \(p\)-values are not artificially understated.

Deviance Residuals vs. Fitted Count (\(\hat{\mu}\))

Plots each observation's deviance residual \(r_{D,i}\) against its predicted count \(\hat{\mu}_i\). Well-specified count models show residuals centered around 0 mostly within the \(\pm 2\) reference band.

Interpretation Aid

Why Deviance Residuals? Raw count residuals (\(Y_i - \hat{\mu}_i\)) are naturally skewed and fan outward as \(\hat{\mu}_i\) grows. Deviance residuals measure each observation's signed contribution to model deviance (\(\text{sign}(Y_i - \hat{\mu}_i)\sqrt{d_i}\)), putting low-rate and high-rate observations on a comparable scale.

What to Look For: Points above \(+2.5\) or below \(-2.5\) represent extreme count outliers (e.g., an unexpected bulk order or a high-propensity account with zero orders). Systematic curvature indicates a missing nonlinear term or an unmodeled exposure offset.

Single-Customer What-If Count & Hurdle Simulator

Adjust the predictor values and exposure window below to predict the expected event count \(\hat{\mu}\), confidence interval, probability of zero events \(P(Y=0)\), probability of at least one event \(P(Y \ge 1)\), and (for Hurdle models) Stage 1 conversion probability vs. Stage 2 active repeat volume.

Run a count regression model to configure the What-If simulator.

Expected Count (\(\hat{\mu}\))
–
95% CI: –
Zero-Event Prob. \(P(Y = 0)\)
–
Chance of 0 events
Active Prob. \(P(Y \ge 1)\)
–
Chance of 1+ events
Rate per Unit Exposure (\(\hat{\lambda}\))
–
Exposure \(E = 1.0\)
Active Buyer Repeat \(E[Y \mid Y > 0]\)
–
Expected count if active

SUMMARY STATISTICS

Summary Statistics (Active Analysis Rows)

Count Outcome & Exposure Summary

Variable Mean Variance (\(s^2\)) Var / Mean Ratio % Zero (\(Y = 0\)) Min – Max Total \(n\)
Run an analysis to view outcome and exposure summary statistics.

Continuous Predictors

Variable Mean Median Std. Dev. Min Max
Run an analysis to view continuous predictor statistics.

Categorical Predictors (% by Level)

Predictor Level Count Percent
Run an analysis to view categorical level shares.

TEST RESULTS

Calibrated Count Regression Equation & Model Form

Select an outcome and at least one predictor to view the calibrated count regression equation, exposure offset formulation, and worked numerical prediction.

Active Model:–
Outcome (Y):–
Exposure Offset (E):None
McFadden Pseudo-R²:–
Pearson Dispersion (φ):–
NB2 Overdispersion (α̂):–
Overdispersion LRT p:–
Zero-Count Gap (Obs − Pred):–
Model AIC:–
Sample Size (n):–

Head-to-Head Model Family Comparison

Compares all three proper count models plus a Naive Linear OLS benchmark on the same sample. Click any count model row to switch the active analysis to that family.

Model Family Log-Likelihood (\(\ell\)) AIC (lower is better) BIC Dispersion (\(\phi\) or \(\hat{\alpha}\)) Observed \(\% Y=0\) Predicted \(\% Y=0\) RMSE (Count Scale) % Predicted \(< 0\)
Run an analysis to compare count model families.

🔎 Plain-English Parameter Translator (4-Layer Walkthrough)

Layer 1 · Log-Count Slope (\(\hat{\beta}_j\))
–

Additive change in \(\ln(\hat{\mu})\) per 1-unit increase in \(X_j\).

Layer 2 · Rate Multiplier (\(\text{IRR}_j = e^{\hat{\beta}_j \Delta X}\))
–

Multiplicative factor applied to the expected count.

Layer 3 · % Rate Change (\((\text{IRR}-1)\times 100\%\))
–

Percentage increase or decrease in expected event rate.

Layer 4 · Concrete Count Shift (\(\hat{\mu}_0 \to \hat{\mu}_1\))
–

Expected count shift at sample-average covariate settings.

Run a count model above to translate any coefficient into a plain-English managerial takeaway.

Model Coefficients & 4-Layer Incidence Rate Ratio (IRR) Tables

Each row reports the raw log-count slope (\(\hat{\beta}\)), the multiplicative Incidence Rate Ratio (\(\text{IRR} = e^{\hat{\beta}}\)), the percentage rate change (\(\Delta\%\)), and the concrete expected count shift (\(\hat{\mu}_0 \to \hat{\mu}_1\)) evaluated at sample-mean covariates.

Model Intercept & Baseline Rate Run analysis to see the calibrated baseline intercept and expected event rate.

Continuous Predictors & Intercept

Unstandardized: \(\hat{\beta}\) is the log-count change per 1-unit increase in \(X\); \(\text{IRR} = e^{\hat{\beta}}\) multiplies the expected count per 1-unit increase.

Predictor Log-Count (\(\hat{\beta}\)) SE IRR (\(e^{\hat{\beta}}\)) % Rate Change (\(\Delta\%\)) Count Shift (\(\hat{\mu}_0 \to \hat{\mu}_1\)) \(z\) \(p\)-value 95% IRR CI
Run an analysis to populate coefficients.

Categorical Predictors (Level vs. Reference Group)

Each row compares the listed category against its reference group: \(\text{IRR} = e^{\hat{\beta}}\) is the ratio of expected counts (\(\hat{\mu}_{\text{level}} / \hat{\mu}_{\text{ref}}\)), holding all other predictors constant.

Variable Level Reference Group Log-Count (\(\hat{\beta}\)) SE IRR (\(e^{\hat{\beta}}\)) % Rate Change (\(\Delta\%\)) Count Shift (\(\hat{\mu}_{\text{ref}} \to \hat{\mu}_{\text{lvl}}\)) \(z\) \(p\)-value 95% IRR CI
No categorical predictors in the current model.

APA-Style Statistical Report

Upload data and run a count regression model to generate the APA summary.

Managerial Interpretation

Actionable business takeaways based on Incidence Rate Ratios, dispersion diagnostics, and zero-hurdle patterns will appear here.

Export Observation-Level Predictions & Residuals

Download the active dataset augmented with each row's predicted expected count (\(\hat{\mu}_i\)), linear predictor (\(\hat{\eta}_i\)), predicted zero probability \(P(Y_i = 0)\), Pearson residual, and deviance residual.

DIAGNOSTICS & ASSUMPTIONS

Overdispersion, Zero-Count Gap, Exposure & Multicollinearity Checks

Count models rely on three structural checks beyond standard predictor collinearity: (1) whether variance exceeds the mean (\(\phi > 1.5\)), (2) whether observed zeros match predicted zeros, and (3) whether predictors are collinear (VIF).

Predictor Multicollinearity (VIF)

Predictor Term VIF Status