A/B Test Design with Clustered Users and Sequential Looks
Statistics & ExperimentsModel answerLast updated
Design a statistically rigorous A/B test that accounts for within-cluster correlation and daily interim checks while controlling the false-positive rate.
Setting the Scene
A product team is rolling out a new streamlined checkout flow and wants to measure its effect on purchase conversion, which currently sits at 10%. Your job is to design the experiment from the ground up.
The goal is to detect a minimum detectable effect (MDE) of 0.5% relative lift (i.e., a shift from 10.00% to 10.05%) with 80% power at a two-sided significance level of α = 0.05.
Two real-world complications make the standard textbook formula insufficient:
Complication 1 — Users share households
Users are not statistically independent. They live in households, and people in the same household tend to buy similarly (shared payment methods, shared accounts, shared habits). The platform observes:
- Intra-class correlation coefficient (ICC) = 0.05
- Average household size m = 2.5 users
You must inflate the sample size to account for this clustering.
Complication 2 — The team wants daily progress checks
Rather than waiting for the full experiment to conclude, stakeholders want to peek at the results every day for up to 10 days and stop early if the effect looks significant. Naively testing at p < 0.05 on each peek inflates the true false-positive rate well above 5%.
Your Tasks
- Base sample size: Using the formula below, calculate the per-arm sample size N assuming users are fully independent.
- Clustered adjustment: Apply the design effect to compute the adjusted per-arm sample size.
- Sequential monitoring: Explain how you would set per-look thresholds so that the overall Type I error rate stays at 0.05 across all 10 interim checks.
Formulas and Constants
Per-arm sample size (standard):
$$N = \frac{(Z_{\alpha/2} + Z_{\beta})^2 \cdot 2p(1-p)}{\delta^2}$$
Design Effect:
$$DE = 1 + (m - 1) \cdot ICC$$
Z-values to use:
- $Z_{0.025} = 1.96$ (two-sided α = 0.05)
- $Z_{0.20} = 0.84$ (power = 80%)
What a Strong Answer Covers
- Correct conversion of the relative MDE into an absolute delta (this is the most common trap)
- Arithmetic for both the base and clustered sample sizes, with units clearly stated (users per arm, total users, households)
- Why clustering inflates variance and why randomization must happen at the household level
- A named, principled method for controlling error under sequential monitoring — not just "be careful when peeking"
- At least one practical consideration about running this test in the real world
Hints
Hint 1
The MDE is stated as a relative lift. Convert it to an absolute difference in conversion rates before plugging it into the sample size formula — 0.5% of 10% is not 0.5 percentage points.
Hint 2
The design effect tells you how much the variance is inflated by clustering. Multiplying N by the DE gives you the number of users you need; dividing that by the average household size gives you the number of households to randomize.
Hint 3
Testing daily for 10 days is a multiple-looks problem, not a multiple-treatments problem. Think about methods like Pocock, O'Brien–Fleming, or alpha-spending functions that distribute the total α budget across planned interim analyses.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Step 1 — Base Sample Size (Independent Users)
The first thing to get right is the absolute delta. The MDE is a 0.5% relative lift on a 10% baseline:
$$\delta = 0.10 \times 0.005 = 0.0005$$
That is a shift from 10.00% to 10.05% — a very small absolute effect, and the source of the most common mistake candidates make (using δ = 0.005 instead, which is ten times larger and produces a sample size 100× too small).
Plugging into the formula:
$$N = \frac{(1.96 + 0.84)^2 \cdot 2 \times 0.10 \times 0.90}{(0.0005)^2}$$
- $(2.80)^2 = 7.84$
- $2 \times 0.10 \times 0.90 = 0.18$
- Numerator: $7.84 \times 0.18 = 1.4112$
- Denominator: $2.5 \times 10^{-7}$
$$N = \frac{1.4112}{2.5 \times 10^{-7}} \approx \mathbf{5{,}644{,}800 \text{ users per arm}}$$
Total across both arms: roughly 11.3 million users. That number should prompt a sanity check — is that achievable in 10 days given the platform's daily traffic?
Step 2 — Adjusting for Household Clustering
Users in the same household are not independent observations. They share purchase history, payment methods, and account settings. Each additional user from the same household contributes less than one independent unit of information.
The design effect captures this inflation:
$$DE = 1 + (m - 1) \cdot ICC = 1 + (2.5 - 1)(0.05) = 1 + 0.075 = 1.075$$
Adjusted per-arm sample size:
$$N_{\text{clustered}} = 5{,}644{,}800 \times 1.075 \approx \mathbf{6{,}068{,}160 \text{ users per arm}}$$
Total: roughly 12.1 million users, or about 2.43 million households per arm.
Two critical points that separate strong answers from adequate ones:
Randomize at the household level, not the user level. If the checkout feature is tied to a shared account, assigning one household member to control and another to treatment creates within-household contamination and violates the stable unit treatment value assumption (SUTVA). Household-level randomization prevents this.
The analysis must match the randomization unit. A naive user-level z-test would underestimate variance by about 7.5%, inflating the false-positive rate. Use cluster-robust (sandwich) standard errors, or aggregate to household-level conversion rates and apply the delta method.
Step 3 — Preserving α = 0.05 Under Daily Monitoring
Why peeking is a problem. Stopping as soon as any daily test hits p < 0.05 across 10 looks gives a true false-positive rate of roughly 19–20%. The test statistics across looks are correlated (they share overlapping data), so the inflation is lower than the 40% you'd get from 10 independent tests — but still far above 5%.
Available approaches:
| Method | Per-look threshold | Trade-off |
|---|---|---|
| Bonferroni | p < 0.005 at every look | Valid but conservative; ignores correlation between looks |
| Pocock | Constant z ≈ 2.56 (p ≈ 0.0106) | Symmetric, easy to explain; requires ~20–25% larger maximum N and makes the final look much stricter than 0.05 |
| O'Brien–Fleming | z starts ~6.6 on day 1, relaxes to ~2.09 (p ≈ 0.037) on day 10 | Hard to stop early on noise; final threshold stays near 0.05; only ~2–3% sample-size inflation |
| Lan–DeMets alpha spending | Spends α as a smooth function of information fraction | Flexible: handles unequal daily traffic and unplanned looks |
Recommendation: use an O'Brien–Fleming-type Lan–DeMets alpha-spending function, with the clustered N from Step 2 as the maximum information bound. Early stopping requires overwhelming evidence, not a marginal signal. The experiment retains nearly the full 0.05 significance level if it runs to completion. Pre-register the boundaries before the experiment launches.
A candidate can also mention always-valid inference (e.g., mixture sequential probability ratio tests or confidence sequences), which allow continuous peeking without pre-specifying a number of looks.
Common Mistakes
- Using δ = 0.005 (treating the relative MDE as absolute): produces a per-arm N around 56,000 — about 100× too small.
- Confusing per-arm and total N: the formula gives users per arm; double it for the experiment total.
- Applying the DE but randomizing at the user level: negates the entire point of the adjustment.
- "Just use Bonferroni" without noting it's conservative, or worse, "check daily and stop at p < 0.05" without any correction.
- Mixing up the OBF boundary shape: OBF thresholds are extremely strict early (nearly impossible to stop on day 1) and relax over time — the opposite of Pocock.
Practical Considerations
Run in full-week multiples. Ten days straddles weekday and weekend traffic patterns unevenly. Fourteen days (two full weeks) avoids day-of-week confounding and makes interim looks cleaner.
Check for a Sample Ratio Mismatch (SRM). Before trusting any result, run a chi-square test on the observed household and user counts per arm against the expected split. An SRM signals an assignment or logging bug, not a real effect.
CUPED can offset the large N. Using pre-period conversion rate as a covariate in the analysis reduces residual variance and effectively lowers the required sample size — useful when 12 million users is a tight ask on available traffic.