Calculating Experiment Sample Sizes, Multiplicity Corrections, and Duration
Statistics & ExperimentsModel answerLast updated
Derive sample sizes, adjust for variance misspecification and multiple testing, and design sequential stopping rules for online A/B tests.
You are designing online experiments for a social network platform to evaluate features intended to improve the connection request acceptance rate (baseline $p_0 = 9.0%$). Analyze the following two operational scenarios and provide detailed statistical justification for your design choices:
Scenario A: Two-Arm AB Test
- Baseline Rate ($p_0$): $9.0%$
- Target Minimum Detectable Effect (MDE): $+0.5$ percentage points (absolute increase to $9.5%$)
- Parameters: Two-sided $\alpha = 0.05$, Power ($1-\beta$) = $0.80$, equal $1:1$ split.
- Traffic: $10$ million eligible active users daily.
- Compute the required per-arm sample size ($n$) and discuss calendar runtime constraints.
- Evaluate the impact if the empirical standard deviation turns out to be $20%$ higher than the standard binomial assumption. What happens to statistical power if the sample size remains fixed at the value derived in step 1?
Scenario B: Three-Arm Experiment (Control vs. Two Treatments)
- Design: Shared Control ($C$) vs. Variant 1 ($T_1$) and Variant 2 ($T_2$).
- Target MDE: $+0.3$ percentage points (absolute) for either variant against control.
- Familywise Error Rate (FWER): $\alpha = 0.05$, Power = $0.80$.
- Allocation: $20%$ Control, $40%$ Variant 1, $40%$ Variant 2.
- Compare Bonferroni, Holm, and Dunnett procedures for controlling FWER in this setup. Justify which method is most appropriate.
- Compute the total required sample size ($N$) under your chosen correction method and calculate the split per arm. Discuss the efficiency of a $20/40/40$ allocation relative to balanced or optimal allocation rules.
Statistical Rigor & Monitoring (Applies to both scenarios)
- Explain the mathematical and practical risks of continuous monitoring ("peeking") using fixed-sample $p$-value thresholds. Propose a group-sequential boundary framework (such as O'Brien–Fleming) to mitigate these risks.
- Discuss under what circumstances you would apply variance reduction techniques (e.g., CUPED) or cluster-robust standard errors. How does each technique impact the required sample size and design parameters?
Hints
Hint 1
Recall that the variance of the difference in two independent sample proportions is p1(1-p1)/n1 + p2(1-p2)/n2. Convert standard normal z-scores for alpha=0.05 (two-sided) and beta=0.20.
Hint 2
When standard deviation scales by a factor of k, variance scales by k^2. Factor this directly into the sample size formula.
Hint 3
Dunnett's test accounts for the positive correlation introduced by comparing multiple treatment groups against a single shared control group.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Scenario A: Standard Two-Arm Evaluation
1. Per-Arm Sample Size and Test Duration
For a two-sample test of proportions with equal allocation ($n_1 = n_2 = n$), the formula for sample size per arm is:
$$n = \frac{(z_{1-\alpha/2} + z_{1-\beta})^2 \cdot \left[ p_0(1-p_0) + p_1(1-p_1) \right]}{\delta^2}$$
Step-by-Step Calculation:
- Significance & Power Thresholds:
- $z_{1-\alpha/2} = z_{0.975} \approx 1.960$
- $z_{1-\beta} = z_{0.80} \approx 0.8416$
- Multiplier: $(1.960 + 0.8416)^2 = (2.8016)^2 \approx 7.849$
- Variance Components:
- Baseline ($p_0 = 0.090$): $p_0(1-p_0) = 0.090 \times 0.910 = 0.0819$
- Treatment ($p_1 = 0.095$): $p_1(1-p_1) = 0.095 \times 0.905 = 0.085975$
- Combined variance sum: $0.0819 + 0.085975 = 0.167875$
- Effect Size:
- $\delta = 0.005 \implies \delta^2 = 0.000025$
Result:
$$n = \frac{7.849 \times 0.167875}{0.000025} \approx 52,735 \text{ users per arm}$$ Total users across both arms: $N \approx 105,470$.
Operational Duration Consideration:
At $10\text{M}$ active users per day, $105\text{k}$ total users could theoretically be exposed in a few hours (under $2%$ of daily traffic). However, never stop an online experiment after a few hours.
A standard experiment duration must be at least 7 to 14 full calendar days for the following structural reasons:
- Day-of-Week Seasonality: User engagement patterns differ significantly between weekdays and weekends.
- Novelty / Primacy Effects: Initial user behavior right after a feature rollout often reflects curiosity or friction rather than steady-state adoption.
- Traffic Accumulation non-linearity: $10\text{M}$ daily active users (DAUs) does not equal $10\text{M}$ unique new users per day; user return rates cause unique user accumulation to flatten over time.
2. Sensitivity to Variance Misspecification
If the true standard deviation is $20%$ higher than calculated under the standard binomial assumption: $$\text{SD}{\text{true}} = 1.20 \times \text{SD}{\text{assumed}} \implies \text{Var}{\text{true}} = 1.20^2 \times \text{Var}{\text{assumed}} = 1.44 \times \text{Var}_{\text{assumed}}$$
Case A: Adjusting Sample Size
Sample size scales linearly with variance. To maintain $80%$ power at $\alpha=0.05$: $$n_{\text{adjusted}} = 1.44 \times 52,735 \approx 75,938 \text{ users per arm}$$ Total required sample size increases to $N \approx 151,876$.
Case B: Fixed Sample Size ($n = 52,735$), Impact on Power
If the sample size cannot be increased, statistical power decreases. We solve for $z_{1-\beta}$:
$$z_{1-\beta} = \frac{\delta}{\sqrt{\text{Var}{\text{true}} / n}} - z{1-\alpha/2}$$
Because $\text{SD}$ increased by $1.2$, the standard error of the estimate $\text{SE}(\hat{\delta})$ increases by a factor of $1.2$: $$\text{SE}{\text{true}} = 1.2 \times \text{SE}{\text{assumed}} = 1.2 \times \frac{\delta}{z_{1-\alpha/2} + z_{1-\beta}} = 1.2 \times \frac{0.005}{2.8016} \approx 0.002142$$
Calculating the new $z_{1-\beta}$: $$z_{1-\beta} = \frac{0.005}{0.002142} - 1.960 = 2.334 - 1.960 = 0.374$$
Looking up $0.374$ on the standard normal CDF ($\Phi$): $$\text{Power} = \Phi(0.374) \approx 64.6%$$
Power drops from $80%$ to roughly $65%$.
Scenario B: Multi-Arm Evaluation with Shared Control
1. Selection of Multiple Comparison Adjustment
When testing two treatment variants against a single shared control ($T_1 \text{ vs } C$ and $T_2 \text{ vs } C$), familywise error rate (FWER) must be controlled.
- Bonferroni: Adjusts individual $\alpha_i = \alpha / k = 0.05 / 2 = 0.025$. It assumes maximum independence across tests, making it overly conservative.
- Holm (Step-Down Bonferroni): Evaluates ordered $p$-values sequentially. While strictly more powerful than standard Bonferroni, the critical value for the smallest $p$-value remains identical to Bonferroni ($\alpha / 2$). It offers no extra advantage for detecting the first significant variant.
- Dunnett’s Test: Tailor-made for comparing multiple treatments against a common control. Because both test statistics share the control group estimator $\bar{Y}_C$, the two test statistics are positively correlated:
$$\rho = \frac{\text{Var}(\bar{Y}C)}{\text{Var}(\bar{Y}{T_1} - \bar{Y}C)^{1/2} \text{Var}(\bar{Y}{T_2} - \bar{Y}_C)^{1/2}}$$
Dunnett's procedure incorporates this known covariance structure explicitly to yield exact critical values ($z_{\text{Dunnett}} \approx 2.19$ for $k=2$ treatments at $\alpha=0.05$), making it strictly more powerful than Bonferroni or Holm ($z_{\text{Bonferroni}} \approx 2.241$).
2. Sample Size for Allocation Split (20% C / 40% T1 / 40% T2)
Let $N$ be the total sample size across all three arms:
- $n_C = 0.20 N$
- $n_{T1} = 0.40 N$
- $n_{T2} = 0.40 N$
Variance of the estimated difference $\hat{\delta} = \bar{Y}{T1} - \bar{Y}C$: $$\text{Var}(\hat{\delta}) = \frac{p_C(1-p_C)}{0.20 N} + \frac{p{T1}(1-p{T1})}{0.40 N}$$
Using baseline $p_C = 0.090$ and expected $p_{T1} = 0.093$ ($\text{MDE} = +0.003$):
- $p_C(1-p_C) = 0.0819$
- $p_{T1}(1-p_{T1}) = 0.093 \times 0.907 = 0.084351$
$$\text{Var}(\hat{\delta}) = \frac{1}{N} \left[ \frac{0.0819}{0.20} + \frac{0.084351}{0.40} \right] = \frac{1}{N} \left[ 0.4095 + 0.21088 \right] = \frac{0.62038}{N}$$
Computing Total $N$ using Dunnett's Critical Value:
Using $z_{\text{Dunnett}} \approx 2.19$ and $z_{1-\beta} = 0.8416$: $$\text{Multiplier} = (2.19 + 0.8416)^2 = (3.0316)^2 \approx 9.1906$$
$$\delta^2 = (0.003)^2 = 0.000009$$
$$N = \frac{9.1906 \times 0.62038}{0.000009} \approx 633,485 \text{ total users}$$
Per-Arm Breakdown:
- Control ($20%$): $n_C \approx 126,697$
- Variant 1 ($40%$): $n_{T1} \approx 253,394$
- Variant 2 ($40%$): $n_{T2} \approx 253,394$
Evaluation of the $20/40/40$ Allocation Scheme:
The $20/40/40$ split is statistically inefficient. By Dunnett’s Optimal Allocation Rule (or standard variance minimization), when comparing $k$ variants against a common control, allocation to control should scale as $\sqrt{k}$ relative to each treatment arm:
$$\frac{n_C}{n_T} = \sqrt{k} = \sqrt{2} \approx 1.414$$
The optimal sample distribution for $k=2$ is roughly $41.4%$ Control, $29.3%$ Variant 1, and $29.3%$ Variant 2. Constraining the control group to only $20%$ inflates the variance of the comparison estimator, requiring roughly $25%$ more overall total traffic than an optimal allocation split.
Statistical Monitoring & Advanced Adjustments
1. Consequences of Naive Peeking and Sequential Solutions
Consequences of Naive Peeking:
Checking $p$-values daily and stopping the experiment as soon as $p < 0.05$ causes severe Type I error inflation. Repeated significance testing on accumulating data increases the cumulative false positive rate substantially:
| Number of Looks | Empirical False Positive Rate ($\alpha_{\text{actual}}$) |
|---|---|
| 1 (Fixed Sample) | $5.0%$ |
| 5 Looks | $\approx 14.2%$ |
| 10 Looks | $\approx 19.3%$ |
| Continuous | $> 30.0%$ |
Additionally, early stopping under naive rules introduces severe selection bias (Winner’s Curse): point estimates of the treatment effect at the moment of early stopping are systematically inflated relative to their true effect size.
Group Sequential Design Mitigation:
To allow interim analysis while preserving the overall FWER at $\alpha = 0.05$, adopt an O’Brien–Fleming group sequential design.
Z-Score Boundary
^
5.0 -| * (Look 1: z = 4.56)
4.0 -|
3.0 -| * (Look 2: z = 3.23)
2.0 -| * (Look 3: z = 2.63) * (Look 4: z = 2.28) * (Look 5: z = 2.04)
1.0 -|---------------------------------------------------------------------------- (Standard z = 1.96)
+--------------------------------------------------------------------->
20% 40% 60% 80% 100% Information Fraction (t)
O'Brien–Fleming imposes conservative decision boundaries at early interim looks and relaxes them near sample completion. For $K=5$ equally spaced looks:
- Information Fractions ($t_k$): $0.20, 0.40, 0.60, 0.80, 1.00$
- Critical Values ($z_k$): $\approx 4.56, 3.23, 2.63, 2.28, 2.04$
Operational Implementation:
- Flexible Schedule: If interim looks are unpredictable, use an $\alpha$-spending function such as the Lan–DeMets approximation: $$\alpha(t) = 2 - 2\Phi\left(\frac{z_{1-\alpha/2}}{\sqrt{t}}\right)$$
- Futility Boundaries: Incorporate non-binding futility thresholds to stop underperforming variants early for poor efficacy, freeing up traffic allocation.
2. Variance Reduction (CUPED) vs. Clustering Adjustments
CUPED (Controlled-experiment Using Pre-Experiment Data):
- When to Apply: Applied at the individual user level when historical, pre-experiment metric baseline measurements exist (e.g., historical user engagement or acceptance rate over the 14 days prior to test start).
- Mathematical Mechanism: Defines a variance-reduced metric $\tilde{Y} = Y - \theta X$, where $X$ is the pre-experiment metric value and $\theta = \frac{\text{Cov}(Y, X)}{\text{Var}(X)}$.
- Impact on Variance and Sample Size: $$\text{Var}(\tilde{Y}) = \text{Var}(Y) \cdot (1 - \rho^2)$$ where $\rho = \text{Corr}(X, Y)$.
- Sample Size Effect: If $\rho = 0.60$, variance is reduced by $1 - 0.60^2 = 0.64$ ($36%$ reduction). The required sample size $n$ directly drops by $36%$, significantly lowering runtime.
Cluster-Robust Standard Errors (CRSE):
- When to Apply: Applied when the unit of randomization differs from the unit of analysis. For example, randomizing at the user level but measuring outcomes at the connection request level (or feed impression level).
- Mathematical Mechanism: Requests originating from the same user are correlated. The standard binomial variance underestimates true variance by ignoring intra-cluster correlation ($\rho_{\text{icc}}$).
- Variance Inflation Factor (Design Effect): $$\text{VIF} = 1 + (\bar{m} - 1) \rho_{\text{icc}}$$ where $\bar{m}$ is the average number of requests per user.
- Sample Size Effect: If a user sends an average of $\bar{m} = 10$ requests with an intra-user correlation $\rho_{\text{icc}} = 0.15$: $$\text{VIF} = 1 + (10 - 1) \times 0.15 = 2.35$$ Standard errors must be inflated by $\sqrt{2.35}$, and required sample size increases by $135%$ ($n_{\text{cluster}} = n \times \text{VIF}$).
- Design Action: Switch to cluster-robust standard errors (e.g., sandwich estimators or bootstrap by user) to avoid severely underestimating $p$-values and producing false positives.