Choosing a Count Model for Contacts per Caller and Checking Fit
Statistics & ExperimentsModel answerLast updated
Pick a probability model for how many distinct people each caller contacts in a period, estimate it, and show with tests and diagnostics that it describes the data well enough for capacity planning.
Scenario
A communications platform wants to forecast load and growth. For each caller, you have the number of distinct people they phoned during a fixed observation window (for example, one week). The planning team needs a statistical model of this per-caller count.
Question
- Which probability distribution would you use for the number of unique recipients per caller? Justify the choice against the obvious alternatives.
- How would you estimate its parameters?
- How would you check whether the model really fits the data, and whether a simpler model would have been enough?
What a strong answer covers
- Questions you would ask before modelling (window length, who is in the population, segments).
- Why some candidate distributions are a poor match and which one you would start from.
- Estimation approach, including any quantity that has no closed form.
- Formal tests, visual diagnostics, and model comparison, with attention to pitfalls when data is discrete, parameters are estimated, or the sample is very large.
- How you would tie the evaluation back to the planning use case.
Hints
Hint 1
The outcome is a non-negative integer. Think about what a Poisson model assumes about the relationship between mean and variance, and whether callers are really interchangeable.
Hint 2
If every caller has their own latent rate, drawn from a skewed distribution, what marginal distribution do the counts follow? Consider how it relates to Poisson as a special case.
Hint 3
For goodness-of-fit, think about degrees of freedom when parameters are estimated, minimum expected counts per bin, why classical KS p-values are unreliable here, and what happens to every test when n is in the millions.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Framing
The data are non-negative integer counts over a fixed exposure window. Planning for capacity depends on the upper tail (heavy callers), not just the average, so the model must be judged on how well it describes the tail.
Clarify first
- Window: counts are only comparable over a fixed period. If windows differ, use an exposure offset.
- Population: if only users with at least one call are included, zero is impossible and a zero-truncated model is needed. If all users are included, check for excess zeros.
- Unique vs total: distinct recipients are capped by each person's contact set, so they grow more slowly than call volume.
- Segments: personal accounts, businesses, and automated or abusive accounts behave very differently. Mixing them inflates the tail.
Candidate distributions
| Model | Assumption | Verdict |
|---|---|---|
| Binomial(n, p) | Fixed trial count n, same p | n (contact list size) varies and is unknown; variance is below the mean, which is the wrong direction for this data |
| Poisson(λ) | Constant rate, independent events | Mean equals variance; good baseline but callers differ in sociability |
| Negative binomial(μ, r) | Poisson with caller-specific gamma-distributed rate | Usually the best default |
| Zero-truncated or hurdle NB | Only active callers, or structural zeros | Use depending on population definition |
| Discrete lognormal / power-law tail | Extremely heavy tail | Consider for a separate heavy-user segment |
Why negative binomial: if a caller's rate λᵢ ~ Gamma with mean μ and shape r, and the count given λᵢ is Poisson(λᵢ), the marginal count is negative binomial with
- E[X] = μ
- Var[X] = μ + μ²/r
The extra μ²/r term represents heterogeneity between callers. As r grows large, the model reduces to Poisson, so the two are nested and easy to compare.
Estimation
- Poisson: the MLE is λ̂ = x̄.
- Negative binomial: the MLE of μ is x̄. The MLE of r has no closed form, so solve the score equation numerically (Newton or a scipy/statsmodels optimizer). A method-of-moments start, r₀ = x̄² / (s² − x̄) when s² > x̄, works well.
- With covariates (region, account age, device): fit an NB regression with log μᵢ = xᵢᵀβ + log(exposureᵢ). Covariates absorb part of the overdispersion but rarely all of it.
Step 1: Test for overdispersion
- Compare sample variance s² with mean x̄. Variance several times the mean is typical.
- Dispersion index: under Poisson, (n−1)s²/x̄ ≈ χ²ₙ₋₁. A large value rejects Poisson.
- Likelihood-ratio test, Poisson vs NB: LR = 2(ℓ_NB − ℓ_Pois). The null (1/r = 0) lies on the boundary of the parameter space, so the reference is a 50:50 mixture of χ²₀ and χ²₁. In practice, halve the χ²₁ p-value.
- In a regression setting, use a Cameron–Trivedi auxiliary regression, or check Pearson χ² divided by residual degrees of freedom (values well above 1 indicate overdispersion).
Step 2: Goodness-of-fit
- Pearson χ² on binned counts: Σ (O − E)²/E. Merge tail bins so every expected count is at least 5. Degrees of freedom = bins − 1 − number of estimated parameters (1 for Poisson, 2 for NB).
- KS test: classic critical values assume a continuous distribution with known parameters. With discrete data and fitted parameters, the textbook p-values are wrong (conservative). Use a parametric bootstrap: simulate from the fitted model, refit on each simulated sample, recompute the statistic, and use that empirical null.
- Information criteria: compare AIC = 2k − 2ℓ and BIC. With millions of rows, formal tests reject every model, so rely on relative comparison and effect size.
- Visual checks: a hanging rootogram (observed vs fitted frequencies on a square-root scale) and a log-log plot of P(X ≥ k) to inspect the tail.
- Purpose-driven validation: on a holdout period, compare predicted vs observed P95 and P99 and the expected number of callers above capacity thresholds. A model that matches the bulk but misses the tail is not fit for planning.
Code sketch
import numpy as np
from scipy import stats, optimize
def fit_and_compare(x):
x = np.asarray(x)
n, m, v = len(x), x.mean(), x.var(ddof=1)
ll_pois = stats.poisson.logpmf(x, m).sum()
D = (n - 1) * v / m
p_disp = stats.chi2.sf(D, n - 1)
def nll(log_r):
r = np.exp(log_r)
p = r / (r + m)
return -stats.nbinom.logpmf(x, r, p).sum()
r0 = m**2 / (v - m) if v > m else 100.0
res = optimize.minimize_scalar(nll, bracket=(np.log(r0) - 1, np.log(r0) + 1))
r_hat, ll_nb = np.exp(res.x), -res.fun
lr = 2 * (ll_nb - ll_pois)
p_lrt = 0.5 * stats.chi2.sf(lr, 1)
aic = {"poisson": 2 - 2 * ll_pois, "negbin": 4 - 2 * ll_nb}
return dict(dispersion_p=p_disp, r_hat=r_hat, lrt_p=p_lrt, aic=aic)
Complexity is O(n) per likelihood evaluation, with a handful of evaluations for the one-dimensional search. The bootstrap multiplies this by the number of replicates.
Trade-offs and common mistakes
- Assuming Poisson without checking dispersion, which understates tail risk and makes capacity estimates too optimistic.
- Forgetting zero-truncation when only active callers are observed.
- Using the plain χ²₁ p-value for the Poisson-vs-NB LRT, ignoring the boundary issue.
- Using textbook KS p-values for discrete data with fitted parameters.
- Not subtracting estimated parameters from the χ² degrees of freedom, or leaving sparse bins unmerged.
- Treating a tiny p-value at huge n as meaningful by itself rather than looking at effect size and diagnostics.
- Pooling very different segments, so one distribution tries to describe both ordinary users and automated heavy senders. Fit segments separately or add a tail component.
Summary answer
Start with Poisson as a baseline (λ̂ = x̄) and expect overdispersion. Use a negative binomial (gamma–Poisson mixture, Var = μ + μ²/r), zero-truncated if only active callers are included, with an NB regression and exposure offset when covariates exist. Fit by maximum likelihood, confirm overdispersion with the dispersion index and a boundary-corrected LRT, then assess fit with binned χ² (correct degrees of freedom), bootstrap-calibrated KS-type statistics, AIC/BIC, rootograms and tail plots, and finally holdout checks of upper quantiles that matter for capacity.