Sequential A/B Test, FDR Control, Bot Posterior, Skewed AOV
Statistics & ExperimentsModel answerLast updated
Four applied statistics tasks: a two-proportion test with group-sequential boundaries, BH vs Bonferroni, a Bayes flag posterior, and robust inference for a skewed order-value metric.
Work through the four parts below. Show your arithmetic and say what each result means for a decision.
Part 1: Conversion test with repeated peeking. An experiment has been monitored at 5 planned looks. The latest data are:
| Arm | Users | Conversions |
|---|---|---|
| Control | 12,000 | 1,380 |
| Treatment | 12,200 | 1,512 |
- Compute the two-sided p-value for the difference in conversion rates, and a 95% confidence interval for that difference.
- The team used an O'Brien–Fleming alpha-spending plan. Without recomputing a full spending function, explain whether the result would still count as significant, and how the answer depends on whether this look is the last one.
Part 2: Many metrics. You track 5 metrics. Their sorted p-values are 0.001, 0.012, 0.019, 0.070 and 0.300. Apply Benjamini–Hochberg at FDR q = 0.05 and list the discoveries. Then compare with Bonferroni at familywise α = 0.05 and explain when you would pick each.
Part 3: Bot flagging. 5% of users are bots. The classifier has a 2% false-positive rate and a 10% false-negative rate. Given that a user is flagged, what is the probability they really are a bot? Show Bayes' theorem with numbers and describe the product implications.
Part 4: Skewed order value. Average order value is right-skewed (mean 32, SD 15, heavy right tail). Propose a robust plan for outliers and inference. Compare the IQR rule, z-scores, and MAD / Huber M-estimators. Recommend a log transform together with the delta method, and explain how to report the effect on the original currency scale using a smearing estimator.
Hints
Hint 1
For Part 1, use the pooled variance for the z-test and the unpooled variance for the confidence interval. Then compare z with the final O'Brien–Fleming boundary, roughly 2.04 for 5 equally spaced looks, and ask whether look 5 is the last planned look.
Hint 2
For Part 2, BH is a step-up rule: find the largest rank i with p(i) <= (i/m)q, and everything at or below that rank is a discovery. Bonferroni just divides alpha by m.
Hint 3
For Part 4, separate removing invalid data (bots, test orders, currency errors) from taming genuine big spenders. Remember that exp of a mean log difference is a ratio of geometric means, not arithmetic means, which is why a smearing factor is needed.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Part 1: Two-proportion test and sequential boundary
Estimates
- Control rate: 1,380 / 12,000 = 0.1150
- Treatment rate: 1,512 / 12,200 = 0.1239
- Difference: +0.00893 (about +0.89 percentage points, roughly a 7.8% relative lift)
Hypothesis test (pooled variance, since H0 says the rates are equal)
- Pooled rate = 2,892 / 24,200 = 0.1195, so p(1−p) = 0.1052
- SE0 = sqrt(0.1052 × (1/12,000 + 1/12,200)) ≈ 0.00417
- z = 0.00893 / 0.00417 ≈ 2.14, two-sided p ≈ 0.032
95% CI (unpooled variance, since we are estimating, not assuming H0)
- SE = sqrt(0.115·0.885/12,000 + 0.1239·0.8761/12,200) ≈ 0.00417
- CI = 0.00893 ± 1.96 × 0.00417 = [+0.08 pp, +1.71 pp]
A fixed-horizon analysis would call this significant, but the lower end of the interval is barely above zero.
Sequential adjustment. Testing 5 times at a nominal 0.05 pushes the real false-positive rate to roughly 14%. O'Brien–Fleming spends almost no alpha early and keeps most for the end. For 5 equally spaced looks and two-sided α = 0.05, the z boundaries are about 2.04·sqrt(5/k):
| Look | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| Boundary | 4.56 | 3.23 | 2.63 | 2.28 | 2.04 |
- If look 5 is the final planned analysis: z = 2.14 exceeds 2.04 (equivalently 0.032 is below the nominal 0.041), so the result stays significant. A Lan–DeMets OBF-style spending function gives nearly the same final cutoff.
- If look 5 is only an interim look in a longer plan (say 5 of 10, about half the information): the boundary is near 2.9–3.0, so 2.14 does not cross it. Keep collecting data.
Caveats: the schedule must be fixed in advance, and you cannot declare a win at an earlier look whose z was under its boundary. Also, estimates from sequentially stopped tests tend to be slightly inflated, so report the effect with that in mind.
Part 2: BH vs Bonferroni
BH: find the largest i with p(i) ≤ (i/5)(0.05). The thresholds are 0.010, 0.020, 0.030, 0.040, 0.050.
| Rank | p | Threshold | Pass |
|---|---|---|---|
| 1 | 0.001 | 0.010 | yes |
| 2 | 0.012 | 0.020 | yes |
| 3 | 0.019 | 0.030 | yes |
| 4 | 0.070 | 0.040 | no |
| 5 | 0.300 | 0.050 | no |
The largest passing rank is 3, so the first three metrics are discoveries. Their BH-adjusted p-values are 0.005, 0.030 and 0.032.
Bonferroni uses 0.05/5 = 0.01, so only p = 0.001 passes: one discovery. (Holm, a uniformly stronger FWER method, would reach two: 0.001 and 0.012, then stop at 0.019 > 0.0167.)
When to use which
- Bonferroni or Holm controls the chance of any false positive. Use it for launch-blocking or guardrail decisions.
- BH controls the expected share of false discoveries among those declared. It has more power and suits exploratory multi-metric readouts.
- BH assumes independence or positive dependence, which is usually reasonable for correlated product metrics. Under arbitrary dependence use Benjamini–Yekutieli.
Part 3: Posterior for a flagged user
Sensitivity P(F|B) = 0.90, P(F|not B) = 0.02, prior P(B) = 0.05.
P(B|F) = (0.90 × 0.05) / (0.90 × 0.05 + 0.02 × 0.95) = 0.045 / (0.045 + 0.019) = 0.045 / 0.064 ≈ 0.703
Out of 10,000 users: 450 true flags and 190 false flags. About 30% of flagged users are human, despite the low FPR, because humans vastly outnumber bots.
Implications:
- Do not auto-ban on one flag. Use a graduated response such as a challenge step.
- Choose the threshold from the relative costs of each error.
- Precision changes with prevalence, so re-evaluate per segment or traffic source.
Part 4: Skewed AOV
Outlier rules compared
- z-score (|z| > 3): Weak. The mean and SD are inflated by the very outliers you want to find (masking), and the rule assumes symmetry. With mean 32 and SD 15 the cutoff is about 77 and the lower side is irrelevant.
- IQR fences: Quantile-based, so more resistant to masking. On raw right-skewed data they flag many legitimate large orders, so apply them on the log scale.
- MAD (modified z = 0.6745·(x − median)/MAD, cut at 3.5): Breakdown point of 50%. The best of the three for detecting corrupt records such as bots, test orders or currency mistakes.
- Huber M-estimator: Quadratic near the centre, linear in the tails (tuning ≈ 1.345σ, ~95% efficiency under normality). It is stable, but it estimates a robust location, not the mean, and revenue decisions care about the mean.
Recommended plan
- Remove invalid data (MAD on the log scale), not merely large data. Genuine big spenders are part of the revenue.
- Reduce variance without changing the question: either winsorize at a pre-set percentile (for example 99.5th, computed from pooled or pre-period data and applied identically to both arms) or analyze log(AOV).
- Use correct standard errors. If randomization is by user but AOV is per order, it is a ratio metric (total revenue / total orders). The delta method gives Var(R/O) ≈ (1/Ō²)[Var(R̄) − 2(R̄/Ō)Cov(R̄,Ō) + (R̄/Ō)²Var(Ō)], which respects within-user correlation. A user-level bootstrap is a good alternative.
Log scale and back-transformation Let Δ = mean(log Y_T) − mean(log Y_C), with a Welch CI [L, U]. Then exp(Δ) is the ratio of geometric means, so report it as a change in typical order value. It is not the lift in the arithmetic mean, because E[log Y] ≠ log E[Y].
For arithmetic means use Duan's smearing estimator:
E[Y] ≈ exp(μ̂_log) × (1/n) Σ exp(ε̂_i), where ε̂_i = log y_i − μ̂_log.
Compute the smearing factor separately for each arm: if treatment changes the spread, a shared factor biases the result. The arithmetic ratio is then exp(Δ) × S_T / S_C, with a CI from a user-level bootstrap or the delta method on the log ratio.
Common mistakes
- Dropping all high orders and then reporting a revenue effect.
- Computing a per-order standard error when randomization is per user.
- Reading exp(Δ) as a mean lift.
- Choosing the winsorization cutoff separately in each arm after seeing the outcome.