Modeling Engagement Durations and Rare Event Counts
Statistics & ExperimentsModel answerLast updated
Derive and validate exponential session-length models and Poisson comment-count models, covering memorylessness, survival diagnostics, and overdispersion.
Modeling Engagement Durations and Rare Event Counts
You are analyzing two aspects of user behavior on a content platform.
Part 1 – Session durations
Assume that at every moment during an active session, a user's probability of leaving is constant — it does not depend on how long they have already been there.
(a) Starting from that constant-hazard assumption, derive the distribution of session durations. State the memoryless property precisely and prove it holds for the distribution you derived.
(b) Describe two empirical checks you would run on logged session data to test whether the constant-hazard assumption actually holds. Be specific about what you would plot, what pattern would confirm the model, and what departures would look like. Account for the fact that some sessions may not have ended by the time the data were collected.
Part 2 – Per-user comment counts
Suppose that every time a user sees a post, they independently decide whether to leave a comment, each time with a small probability p. A given user sees M posts in a time window.
(c) Justify using a Poisson distribution to model the number of comments that user leaves. Give the Poisson parameter in terms of p and M, and state the conditions under which the approximation is reliable.
(d) After fitting the Poisson model to a sample of users, you suspect the fit is poor. Describe the diagnostics you would use to detect overdispersion and excess zeros, and name at least one alternative model for each problem, including how you would decide whether the alternative is warranted.
Hints
Hint 1
For part (a), write the hazard as h(t) = f(t)/S(t) = –d/dt log S(t), set it equal to a constant λ, and integrate with the boundary condition S(0) = 1. The memoryless property then follows directly from the form of S(t).
Hint 2
For part (b), plot log Ŝ(t) against t using the Kaplan–Meier estimator — linearity is what you are looking for. Be careful: a decreasing hazard in pooled data can come from user heterogeneity rather than a violation of per-user memorylessness.
Hint 3
For part (d), start with a simple dispersion check (sample variance vs. sample mean, or Pearson χ²/df from a Poisson GLM) before reaching for a zero-inflated model. Excess zeros sometimes disappear once overdispersion is accounted for with a negative binomial.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
What a strong answer covers
This question tests whether you can move from a verbal modeling assumption to a named distribution by derivation, state what the model predicts precisely, and then explain how you would challenge it with real data. Derivations should be quick; most of the answer's value is in the diagnostics.
(a) Deriving the exponential from constant hazard
Let T be session duration with survival function S(t) = P(T > t) and density f(t). The hazard — the instantaneous rate of leaving, given that the session has lasted to time t — is:
h(t) = f(t) / S(t) = –d/dt log S(t)
Setting h(t) = λ (constant) and integrating, with the boundary condition S(0) = 1:
log S(t) = –λt → S(t) = e^{–λt} → f(t) = λe^{–λt}, t ≥ 0
So T ~ Exponential(λ) with mean 1/λ, variance 1/λ², and coefficient of variation exactly 1.
Memoryless property: P(T > s + t | T > s) = P(T > t) for all s, t ≥ 0.
Proof: P(T > s + t) / P(T > s) = e^{–λ(s+t)} / e^{–λs} = e^{–λt} = P(T > t). ∎
In plain terms: a user who has been browsing for 20 minutes has exactly the same remaining-session distribution as a user who just opened the app. The mean residual life is 1/λ regardless of elapsed time. The exponential is the only continuous distribution with this property; the geometric is its discrete analogue.
(b) Empirical checks using survival data
Before plotting anything, handle right censoring. Sessions still open at data collection, or cut off by a logging window, are censored. Using only completed sessions biases the estimated rate upward. Use survival estimators throughout.
Check 1: Log-survival plot (Kaplan–Meier)
Compute the Kaplan–Meier estimate Ŝ(t) and plot log Ŝ(t) against t. Under an exponential model this is a straight line through the origin with slope –λ̂. Curvature is the diagnostic signal:
- Concave-up (flattening over time): hazard is decreasing — long sessions are getting "stickier," inconsistent with constant hazard.
- Concave-down: hazard is increasing — sessions become more likely to end as they go on.
A sharper version is a Weibull probability plot: plot log(–log Ŝ(t)) against log t. Under the exponential, the slope should be 1. A fitted slope k ≠ 1 quantifies the departure. You can also run a likelihood ratio test of the exponential nested within the Weibull.
Check 2: Empirical hazard estimate
Compute the Nelson–Aalen cumulative hazard Ĥ(t) = Σ dₖ/nₖ over event times. Under the exponential, Ĥ(t) should be linear in t. Alternatively, bin time into intervals and compute (events in bin) / (person-time at risk in bin) as a piecewise hazard estimate and plot it — it should be flat within confidence bands.
Important nuance — heterogeneity vs. model failure: If users each have their own constant rate λᵢ drawn from some distribution, the pooled data follow a mixture of exponentials, which always has a decreasing hazard (high-rate users leave the risk set first). A downward-sloping pooled hazard therefore does not prove per-user non-memorylessness. Stratify by user segment or fit a frailty model before concluding the assumption is violated. Also watch for structural spikes: hazard often jumps at video endpoints, app-backgrounding events, or hard inactivity timeouts (e.g., 30 minutes), none of which refute memorylessness between those thresholds.
(c) Justifying the Poisson model
Given M views each independently resulting in a comment with probability p, the exact count is:
C ~ Binomial(M, p)
Taking M → ∞ and p → 0 with Mp = λ held fixed, term by term:
C(M,k) p^k (1–p)^{M–k} → (λ^k / k!) · e^{–λ}
So C ≈ Poisson(λ = Mp). Mean and variance are both λ. The binomial variance is Mp(1–p), so the relative error is just p — tiny when p is small.
Conditions for the approximation to be reliable:
- p is small. Le Cam's bound gives total variation distance ≤ Mp². With p = 0.01 and M = 200, that bound is 0.02. Common rule of thumb: p ≤ 0.05.
- Trials are independent. Commenting on one post must not affect the next. Reply threads and social nudges violate this.
- p is roughly constant across posts (or at least small for every post — if the pᵢ vary but each is small, the count is still approximately Poisson(Σpᵢ)).
- M is treated as a known exposure per user. Users with different M should each be modeled as Poisson(Mᵢp); do not pool raw counts and ignore exposure differences.
A common mistake is saying "Poisson works because M is large." The key condition is that p is small. A large M with a moderate p calls for a normal approximation to the binomial instead.
(d) Diagnostics for overdispersion and zero inflation
Overdispersion (variance > mean)
The Poisson imposes variance = mean. To check it:
- Compute the dispersion ratio: sample variance of comment counts divided by sample mean. Values meaningfully above 1 (say, ≥ 2) are a red flag. With unequal exposure, fit a Poisson GLM with offset log M and examine Pearson χ² / residual df; values well above 1 signal overdispersion.
- Plot squared Pearson residuals against fitted μ̂. A positive trend means the variance is growing faster than μ.
- Use a rootogram (hanging or suspended) to compare observed and Poisson-expected frequencies. Overdispersion typically shows too many zeros, too many large counts, and a deficit in the middle.
Excess zeros
Compare the observed zero-count fraction to Σᵢ e^{–μ̂ᵢ} / n from the fitted model. A persistent surplus suggests a structural "never-commenter" subpopulation with p ≡ 0. Check this after fitting a negative binomial first, because NB often explains the zeros on its own — jumping straight to a zero-inflated model adds parameters that may not be necessary.
Alternative models
- Negative binomial (NB2): appropriate when p varies across users — treat individual rates as Gamma-distributed. Variance is μ + μ²/k. Test against Poisson with a likelihood ratio test on the dispersion parameter α = 1/k; because the null is on the boundary, divide the p-value by 2.
- Zero-inflated Poisson or NB: models a two-component process — a logistic component deciding whether a user ever comments, and a count component for those who do. Prefer a hurdle model when zero and non-zero processes are conceptually distinct. Compare to the non-inflated NB using AIC/BIC or held-out likelihood.
- Always include the offset log M in every model so that exposure differences do not contaminate the dispersion estimate.
Common mistakes to avoid
- Forgetting censoring and plotting histograms of completed sessions only, which biases λ̂ upward.
- Concluding per-user non-memorylessness from a decreasing pooled hazard without accounting for frailty.
- Attributing overdispersion to clustering when it actually comes from unequal exposure M across users.
- Adding zero-inflation before ruling out the simpler negative binomial explanation.