Sample Size Planning for a Conversion Experiment and Its Levers
Statistics & ExperimentsModel answerLast updated
Size a two-arm conversion test from a baseline rate and relative lift, then explain how tighter alpha, higher power, uneven splits, clustering, interim looks and overdispersed counts change the required n.
You are planning a randomized experiment on a checkout flow. The current conversion rate is 8.0%. You want the test to reliably detect a relative lift of 8%, which is an absolute increase of 0.64 percentage points (8.00% to 8.64%). Use a two-sided test at alpha = 0.05, 80% power, and an even 1:1 split.
Part A. Starting from the sampling distribution of the difference between two observed proportions, derive the per-arm sample size with a normal approximation. Show the z quantiles you use and compute the number.
Part B. Change one thing at a time from the Part A setup, and say both qualitatively and numerically what happens to the required sample size:
- The detectable lift is cut in half.
- Alpha is tightened to 0.01.
- Power is raised to 90%.
- Traffic is split 75% / 25% instead of 50% / 50%.
- Observations are clustered within users, with intra-cluster correlation 0.02 and an average of 5 observations per user. Compute the design effect.
- You plan two equally spaced analyses (one interim, one final) with O'Brien-Fleming stopping boundaries.
Part C. Suppose the metric is instead an overdispersed count per user, such as items viewed per week, modeled as negative binomial (NB2). Describe how you would re-estimate the required sample size.
Give a structured answer with reasoning, numbers, and the pitfalls you would watch for.
Hints
Hint 1
Set the standardized effect equal to the sum of two quantiles: the distance from the null to the rejection cutoff (z for 1 - alpha/2) plus the distance from the cutoff to the true effect (z for power). Then solve for n.
Hint 2
Most levers act through the factor (z_alpha + z_beta)^2 or through the effect size squared. For the rest, find the variance multiplier: 1/(4r(1-r)) for uneven splits, 1 + (m-1)*ICC for clustering, and a small inflation constant for O'Brien-Fleming.
Hint 3
For NB2 counts, replace the binomial variance with mu + alpha*mu^2 (or work on the log rate-ratio scale, where the variance per arm is about (1/mu + alpha)/n). Always sanity-check by simulating the exact analysis you will run.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Overview
Sample size is driven by one idea: the true effect must sit far enough above the rejection cutoff, in standard-error units, to give the desired power. Everything else is a change to the variance or to the quantiles.
Part A: Per-arm n for the baseline setup
Let p0 = 0.08, p1 = 0.0864, and Δ = 0.0064. With n users per arm, the observed difference is approximately
d̂ ~ Normal(Δ, (p0·q0 + p1·q1) / n)
We reject when |d̂| / SE exceeds z(1 − α/2). Power requires that this event has probability 1 − β under the true Δ. Ignoring the negligible opposite tail, this gives
Δ / SE = z(1 − α/2) + z(1 − β)
and therefore
n = (z(1 − α/2) + z(1 − β))² · (p0·q0 + p1·q1) / Δ²
Numbers:
| Quantity | Value |
|---|---|
| z(0.975) | 1.960 |
| z(0.80) | 0.842 |
| (sum of z)² | 7.849 |
| p0·q0 | 0.0736 |
| p1·q1 | 0.0789 |
| Variance sum | 0.1525 |
| Δ² | 4.096 × 10⁻⁵ |
n = 7.849 × 0.1525 / 4.096×10⁻⁵ ≈ 29,230 per arm (about 58,500 in total). Using a pooled variance under the null gives almost the same answer (about 29,232). Always round up.
Part B: Sensitivity to each lever
Each row changes only one input from the baseline.
| Change | Reasoning | Result |
|---|---|---|
| Lift halved (Δ = 0.32 pp) | n scales with 1/Δ². The variance term shrinks slightly (0.1499 vs 0.1525), so the factor is just under 4. | ≈ 114,900 per arm (about 3.93×) |
| α = 0.01 | (2.576 + 0.842)² = 11.68 | ≈ 43,500 per arm (1.49×) |
| Power 90% | (1.960 + 1.282)² = 10.51 | ≈ 39,100 per arm (1.34×) |
| 75/25 split | N = (zα + zβ)² · (p0q0/r0 + p1q1/r1) / Δ², giving 7.849 × 0.4139 / 4.096×10⁻⁵ | Total ≈ 79,300 (about 59,500 control and 19,800 treatment), 1.36× the total |
| Clustering, ICC 0.02, m = 5 | DEFF = 1 + (m − 1)·ICC = 1.08 | ≈ 31,600 observations per arm (about 6,300 users) |
| O'Brien-Fleming, 2 looks | Inflation of the maximum sample size ≈ 1.008 | Max ≈ 29,500 per arm; expected ≈ 26,400 under the alternative |
Notes:
- Direction and magnitude. Effect size is the most expensive lever because it enters squared. Alpha and power only move the quantile sum, so they cost tens of percent, not multiples.
- Uneven allocation. For a roughly equal-variance case the total-N penalty is 1/(4r(1 − r)); at 75/25 that is 1.33×. The smaller arm dominates the variance, so the cost is real. Uneven splits are justified only by risk or business limits on exposure.
- Clustering. The design effect applies when the analysis unit (sessions, page views) is nested inside the randomization unit (users). Inflate n by DEFF and use cluster-robust or delta-method standard errors. If you randomize and analyze at the user level with a user-level metric, there is no inflation. Even a small ICC matters when clusters are large: with m = 50, DEFF is about 2.
- Group-sequential testing. With two equally spaced looks, O'Brien-Fleming cutoffs are about 2.80 at half the information and about 1.98 at the end, with overall two-sided alpha still 0.05. Almost no alpha is spent early, so the worst-case sample size rises under 1%. Under the alternative the drift at the interim look is about 2.0, so the chance of stopping early is around 21%, and expected sample size falls to roughly 26,400 per arm. Pocock boundaries stop earlier more often but inflate the maximum by about 11%.
- Peeking without a plan. Checking twice at an unadjusted 1.96 raises the real false-positive rate to about 8%. Pre-planned boundaries avoid this.
- Combining. Effects multiply approximately. For example, α = 0.01, 90% power, and DEFF 1.08 together give (3.857² / 7.849) × 1.08 ≈ 2.05× the baseline.
Part C: Overdispersed counts (NB2)
For NB2, Var(Y) = μ + αμ², where α is the dispersion and α → 0 recovers Poisson. Binomial or Poisson variance would badly understate the noise.
Plan:
- Fix the unit and window. Use per-user counts over a fixed exposure window, or model rates with an exposure offset if exposure varies.
- Estimate μ0 and α by maximum likelihood on a comparable historical cohort. Check stability over weeks and segments, and take a conservative (higher) α if it drifts.
- Choose the effect scale and plug in.
- Difference in means: n = (zα + zβ)² · [μ0 + αμ0² + μ1 + αμ1²] / (μ1 − μ0)².
- Rate ratio via a Wald test on the log rate ratio: n = (zα + zβ)² · [(1/μ0 + α) + (1/μ1 + α)] / (log RR)².
- Worked example. With μ0 = 2, α = 0.5, RR = 1.05 (μ1 = 2.1), the bracket is 1.0 + 0.976 = 1.976, so n ≈ 7.849 × 1.976 / 0.04879² ≈ 6,520 per arm. A Poisson assumption would give about 3,220, so ignoring overdispersion would leave the test badly underpowered.
- Validate by simulation. Simulate from the fitted NB, or bootstrap historical users. Include heavy tails or zero inflation and the exact estimator you will use (GLM, t-test, winsorized mean). Confirm both power and the Type I error rate.
- Layer on adjustments. Variance reduction with a pre-period covariate (CUPED) scales n by (1 − ρ²). Then apply any design effect and sequential inflation as in Part B.
Common mistakes
- Mixing up relative and absolute MDE. Using 8 pp instead of 0.64 pp understates n by roughly 156×.
- Using the one-sided quantile (1.645) for a two-sided test.
- Reporting total N when per-arm n is asked, or vice versa.
- Applying the uneven-split penalty to only one arm.
- Applying DEFF when randomization and analysis units already match, or omitting it when they differ.
- Treating peeking as free, or assuming O'Brien-Fleming is expensive.
- Assuming Poisson variance for engagement counts without checking dispersion.