Sub topic 11
Why peeking at results early gives false winners
This chapter assumes you can run a two-proportion z-test and know what a p-value is, as covered in the previous chapters. You also need the sample-size calculation from "Calculating sample size before you send". The code uses Python with numpy.
The problem: a p-value is only valid at one planned moment
A p-value of 0.05 means that if the two variants were truly identical, a result this extreme would appear by chance about 5% of the time. That guarantee holds for one test, on one sample size, fixed before the data arrived.
Peeking breaks that condition. Suppose you send a subject line test and check the dashboard every hour. If you stop the first time p drops below 0.05, you have run many tests, not one. Each look is another chance for random noise to cross the line. The chance that at least one look crosses it is much higher than 5%.
Early data is also noisy. With only a few hundred clicks per variant, the observed click rates swing widely. A gap that looks like a 30% lift at hour two often shrinks to nothing by hour forty-eight. This is regression to the mean. The early winner was often just the variant that got lucky.
Seeing the inflation with an A/A simulation
An A/A test compares two identical variants. Every "significant" result is a false positive by construction. The simulation below sends 20,000 recipients to each of two identical variants with a true click rate of 2%. It then compares two policies:
- Look once at the end.
- Look ten times, at every 10% of the sample, and stop at the first significant result.
import numpy as np
from statistics import NormalDist
def simulate(n_sims=2000, n_per_variant=20000, looks=10, p=0.02,
alpha=0.05, bonferroni=False, seed=1):
rng = np.random.default_rng(seed)
step = n_per_variant // looks
per_look_alpha = alpha / looks if bonferroni else alpha
crit = NormalDist().inv_cdf(1 - per_look_alpha / 2)
# Cumulative clicks for each simulated test at each look.
a = rng.binomial(step, p, size=(n_sims, looks)).cumsum(axis=1)
b = rng.binomial(step, p, size=(n_sims, looks)).cumsum(axis=1)
n = step * np.arange(1, looks + 1)
pooled = (a + b) / (2 * n)
se = np.sqrt(pooled * (1 - pooled) * 2 / n)
with np.errstate(divide="ignore", invalid="ignore"):
z = np.where(se > 0, (b - a) / n / se, 0.0)
significant = np.abs(z) > crit
final_only = significant[:, -1].mean()
any_look = significant.any(axis=1).mean()
return final_only, any_look
print("single look, alpha=0.05:", simulate()[0])
print("ten looks, alpha=0.05: ", simulate()[1])
print("ten looks, alpha/10: ", simulate(bonferroni=True)[1])Expect the single look to give about 0.05. The ten-look policy gives roughly 0.15 to 0.20, so about one in five identical subject lines gets declared a winner. The exact numbers vary with the seed. The third line, with a stricter threshold at each look, stays at or below 0.05.
The statistical test is the same in all three runs. Only the stopping rule changed.
Why the false-positive rate grows
The looks are not independent. The data at look 5 includes the data from look 4. So the false-positive rate does not grow as fast as 1 - 0.95^10, which would be about 40%. It still climbs with each look, and more so for the first few looks. Roughly, with a 0.05 threshold at every look:
| Number of looks | Approximate chance of a false winner |
|---|---|
| 1 | 5% |
| 2 | 8% |
| 5 | 14% |
| 10 | 19% |
| Continuous monitoring | Approaches 100% if you wait long enough |
These figures come from the standard sequential-testing results (Armitage and colleagues). Treat them as approximations.
Why email makes peeking worse
Three features of email tests add to the problem:
- Responses arrive unevenly. Most clicks come in the first few hours after a send, and then the rate slows down. The early sample is dominated by your most engaged recipients, who may react differently to a subject line than everyone else.
- Send-time tests change who responds when. A morning send and an evening send have different response curves. Comparing them at hour three measures speed of response, not the final click rate.
- The metric may not be final. Open and click events can be recorded late. Mail Privacy Protection can prefetch images in batches, which creates jumps in opens (see the open-rate chapter). A mid-test snapshot can be distorted by these artifacts.
Stopping rules that keep the error rate honest
You have three practical options. Choose one before you send, and write it in the hypothesis document.
Fixed horizon (the default)
Compute the sample size, send, wait until every recipient has had the planned observation window, and test once. This is the simplest option and the one to use for most subject line tests. You are allowed to look at the dashboard to check that the send worked. You are not allowed to act on the p-value.
Planned looks with a corrected threshold
If you have a business reason to stop early, decide the number of looks in advance and split the error budget across them. The simplest method is Bonferroni: use alpha / number_of_looks at each look. The simulation above shows it works. It is conservative, because it ignores that the looks overlap, so you lose some power. Alpha-spending methods such as O'Brien-Fleming give a very strict threshold at early looks and nearly the full 0.05 at the end. They cost less power than Bonferroni but require a library or a lookup table.
Sequential tests
Methods such as the sequential probability ratio test, or "always valid" p-values, allow continuous monitoring. Some email testing platforms offer these. They are valid only if you use the platform's own decision rule, not a standard p-value displayed next to it.
| Approach | Number of looks | Threshold at each look | Cost |
|---|---|---|---|
| Fixed horizon | 1 | 0.05 | Wait for the full sample |
| Bonferroni | Planned, k | 0.05 / k | Some lost power |
| Alpha spending | Planned, k | Strict early, about 0.05 late | Needs a library |
| Sequential | Any | Set by the method | Needs the platform or method |
Related traps that behave like peeking
- Stopping when the result looks good, extending when it does not. This is optional stopping and gives the same inflation.
- Changing the sample size after seeing data. If the test "needs more recipients" because p is 0.07, you are adding a look.
- Switching the metric. If clicks show no difference, you check opens, then click-to-open. Each metric is another look at the data, even if the time is fixed.
- Segment digging. Slicing the result by device or region after the fact and reporting the segment that "won" is a multiple-comparison problem. The next chapter covers this.
A practical protocol
- Before sending, write down the primary metric, the minimum detectable effect, the sample size per variant, and the analysis time. Include the response window, for example "48 hours after send".
- Send. Only check delivery and error rates in the meantime.
- At the analysis time, run the z-test once and record the lift, the p-value, and the confidence interval.
- If you really need interim looks, state the number of looks and the per-look threshold in step 1.
- If the result is not significant, report it as "no detectable difference at this sample size". Do not extend the test to rescue it.
Exercise
You plan a click-rate test with 20,000 recipients per variant and a single analysis at 48 hours. After 6 hours, the dashboard shows variant B ahead with p = 0.03. A colleague wants to stop the test and send B to the full list. What is wrong with that, and what should you do?
Show answer
The p-value was computed at an unplanned look, so it does not carry the 5% false-positive guarantee. Early data comes mostly from highly engaged recipients, and early gaps often shrink. Stopping on a significant look is peeking and can raise the chance of a false winner well above 5%. Keep the test running to the planned 48 hours with the full sample, run the z-test once, and decide from that result. If early decisions are truly required, redesign the test with a planned number of looks and a corrected threshold such as alpha divided by the number of looks.
Exercise
You plan 4 looks at equal intervals and use the Bonferroni rule with overall alpha = 0.05. What p-value threshold applies at each look, and what is the cost of this method?
Show answer
The threshold is 0.05 / 4 = 0.0125 at each look. The cost is lower power: the test is conservative because the looks overlap and Bonferroni ignores that, so a real effect needs a larger sample or a bigger lift to be detected.