Sub topic 3
Testing the Difference Between Two Rates
Assume you know basic email metrics, percentages, proportions, and simple probability. This chapter uses Python, but the method also works in an email platform or spreadsheet.
Testing the Difference Between Two Rates
For a subject-line test, compare each variant's click rate:
\[ \text{click rate}=\frac{\text{clicks}}{\text{delivered messages}} \]
A two-proportion z-test estimates whether the observed difference is larger than random variation. The p-value is the probability of seeing a difference this large if both variants perform equally.
from math import sqrt
from statistics import NormalDist
def two_proportion_z_test(success_a, sent_a, success_b, sent_b):
p_a = success_a / sent_a
p_b = success_b / sent_b
pooled = (success_a + success_b) / (sent_a + sent_b)
se = sqrt(pooled * (1 - pooled) * (1 / sent_a + 1 / sent_b))
z = (p_b - p_a) / se
p_value = 2 * (1 - NormalDist().cdf(abs(z)))
return p_b - p_a, z, p_value
diff, z, p = two_proportion_z_test(400, 20000, 470, 20000)
print(f"lift={diff:.4f} z={z:.2f} p={p:.4f}")The difference is about 0.35 percentage points. Report this effect size with the p-value. A statistically detectable change can still be too small to matter commercially.
Peeking and Stopping Rules
Do not repeatedly check results and stop when a p-value falls below 0.05. Each check creates another opportunity to observe a misleading extreme. Set the sample size, test duration, primary metric, and stopping rule before sending.
More Than Two Variants
Testing A, B, C, and D creates several pairwise comparisons. Even when every variant is equal, repeated tests increase the chance of a false winner. Use an omnibus test followed by a correction such as Holm's method, or limit the number of planned comparisons.
Rollout and Experiment Logs
Send the winner to the remaining eligible recipients only after the planned analysis. Keep the audience, dates, variants, delivery counts, clicks, exclusions, test method, p-value, effect size, and decision in an experiment log. Record unexpected events, such as a delivery outage or holiday. Reuse the log to choose stronger hypotheses instead of repeating inconclusive tests.
Exercise
Variant A has 400 clicks from 20,000 deliveries. Variant B has 470 clicks from 20,000 deliveries. What should you report besides the p-value?
Show answer
Report the absolute lift, about 0.35 percentage points, and explain whether that lift is large enough to justify a rollout.