Correct a Ratio Metric Confidence Interval Built on Wrong Assumptions
Statistics & ExperimentsModel answerLast updated
Diagnose why a naively constructed CI for a ratio metric (revenue per session) is invalid and derive the correct interval using the delta method.
Setting
Your team ran an A/B test on a checkout flow. The primary metric is revenue per session (RPS):
$$\text{RPS} = \frac{\text{total revenue}}{\text{total sessions}}$$
A junior analyst computes a 95% confidence interval for the treatment group's RPS as follows:
- For each session, define
r_i = revenue_i(0 for sessions with no purchase). - Compute the sample mean:
r̄ = total_revenue / n - Compute the sample standard deviation of
r_i:s - Report CI:
r̄ ± 1.96 * s / sqrt(n)
The treatment group has:
n = 40,000sessions- Total revenue = $200,000 →
r̄ = $5.00 - Sample std dev of per-session revenue
s = $48.00 - Reported CI:
$5.00 ± $0.47→[$4.53, $5.47]
Your tasks:
- Is this CI correct? Identify any statistical assumption or structural issue.
- The analyst's manager suggests the real metric of interest is the ratio
R = μ_revenue / μ_sessionswhere revenue and sessions are measured at the user level (a user may have multiple sessions). Explain why user-level aggregation matters and how it changes the problem. - Using the delta method, derive the correct asymptotic CI for a ratio
R = X̄ / ȲwhereXandYare user-level totals. State all required quantities and the formula clearly. - Given the following user-level summary statistics (treatment,
m = 10,000users), compute the 95% CI:- Mean sessions per user:
ȳ = 4.0, Var(sessions per user):σ²_Y = 9.0 - Mean revenue per user:
x̄ = $20.00, Var(revenue per user):σ²_X = 38,400 - Cov(revenue, sessions) per user:
σ_XY = 120.0
- Mean sessions per user:
- Compare the two CIs and explain which to use and when.
Hints
Hint 1
The session-level CI treats sessions as independent observations — think about what happens when one user contributes many sessions. What assumption does that violate?
Hint 2
The delta method linearizes a non-linear function of two means. Write R = X̄/Ȳ, then apply the first-order Taylor expansion around (μ_X, μ_Y) to get Var(R̂).
Hint 3
The delta method variance for X̄/Ȳ is (1/Ȳ²)[σ²_X + R²σ²_Y − 2R·σ_XY] / m. Plug in the numbers carefully — the covariance term can meaningfully shrink the variance.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. What Is Wrong with the Session-Level CI
The formula r̄ ± 1.96 * s / sqrt(n) is the standard CI for a population mean when observations are i.i.d. Here the observations are individual sessions.
The critical flaw: sessions from the same user are not independent. A single high-value user who has 20 sessions inflates both the revenue total and the session count in a correlated way. Treating 40,000 sessions as 40,000 independent draws ignores this within-user correlation, which causes:
- The effective sample size to be smaller than
n(the design effect > 1). - The standard error to be understated, making the CI too narrow (anti-conservative).
Additionally, RPS is a ratio of two random quantities. Treating the denominator (total sessions) as a fixed constant is only valid if the experiment randomizes at the session level with no repeat users — an assumption that almost never holds in practice.
2. Why User-Level Aggregation Matters
When randomization is at the user level (standard in most A/B platforms), the independent unit is the user, not the session. For user i, define:
X_i= total revenue from useriY_i= total sessions from useri
The estimand is:
$$R = \frac{E[X_i]}{E[Y_i]} = \frac{\mu_X}{\mu_Y}$$
With m = 10,000 users, we have m i.i.d. pairs (X_i, Y_i). The ratio R̂ = X̄ / Ȳ is consistent but biased in small samples and non-linear, so we need the delta method to get its variance.
Using session-level n instead of user-level m inflates the apparent precision by a factor of roughly sqrt(n/m) = sqrt(4) = 2 in this example — a substantial error.
3. Delta Method Derivation
Let R̂ = X̄ / Ȳ. Define f(a, b) = a/b. By first-order Taylor expansion around (μ_X, μ_Y):
$$R̂ - R \approx \frac{\partial f}{\partial a}(X̄ - \mu_X) + \frac{\partial f}{\partial b}(Ȳ - \mu_Y) = \frac{1}{\mu_Y}(X̄ - \mu_X) - \frac{\mu_X}{\mu_Y^2}(Ȳ - \mu_Y)$$
Taking variance (using Var(X̄) = σ²_X/m, Var(Ȳ) = σ²_Y/m, Cov(X̄,Ȳ) = σ_{XY}/m):
$$\text{Var}(R̂) \approx \frac{1}{m} \cdot \frac{1}{\mu_Y^2}\left[\sigma^2_X + R^2 \sigma^2_Y - 2R,\sigma_{XY}\right]$$
The 95% CI is:
$$R̂ \pm 1.96 \cdot \sqrt{\hat{\text{Var}}(R̂)}$$
where you substitute sample estimates x̄, ȳ, s²_X, s²_Y, s_{XY} for the population quantities.
4. Numerical Computation
Given:
m = 10,000,x̄ = 20.00,ȳ = 4.0R̂ = 20.00 / 4.0 = $5.00✓ (same point estimate)σ²_X = 38,400,σ²_Y = 9.0,σ_{XY} = 120.0
Step 1 — bracket term:
$$\sigma^2_X + R^2\sigma^2_Y - 2R,\sigma_{XY} = 38400 + (25)(9) - 2(5)(120)$$ $$= 38400 + 225 - 1200 = 37425$$
Step 2 — divide by μ²_Y = 16:
$$\frac{37425}{16} = 2339.06$$
Step 3 — divide by m = 10,000:
$$\text{Var}(R̂) = \frac{2339.06}{10000} = 0.2339$$
Step 4 — standard error:
$$\text{SE} = \sqrt{0.2339} \approx $0.484$$
Step 5 — 95% CI:
$$$5.00 \pm 1.96 \times $0.484 = $5.00 \pm $0.95 \implies [$4.05,\ $5.95]$$
5. Comparison and Guidance
| Session-level (flawed) | Delta method (correct) | |
|---|---|---|
| Unit of independence | Session (n = 40,000) | User (m = 10,000) |
| SE | $0.47 | $0.48 |
| 95% CI | [$4.53, $5.47] | [$4.05, $5.95] |
| Width | $0.94 | $1.90 |
The session-level CI is roughly 2× too narrow — the ratio sqrt(n/m) = 2 is not a coincidence; it reflects that each user has on average 4 sessions, inflating the apparent sample size.
When to use which:
- Delta method (user-level): Always use when randomization is at the user level. This is correct and accounts for within-user correlation and ratio non-linearity.
- Session-level CI: Only defensible if sessions are truly independently assigned (e.g., a cookie is minted fresh each session with no user identity), which is rare.
- Bootstrap alternative: For small
mor heavy-tailed revenue distributions, the percentile bootstrap on user-level pairs is more robust and avoids the normal approximation in the delta method.
Common mistakes to call out in an interview:
- Forgetting that the experimental unit (user) differs from the observation unit (session).
- Ignoring the covariance term — it can either widen or narrow the CI significantly.
- Using
n(sessions) as the denominator in the SE formula instead ofm(users). - Reporting only the point estimate without checking whether the CI crosses meaningful business thresholds.