The formula: how far the true lift must sit from zero
The formula comes from one picture: where the true lift has to sit for the test to catch it.
Predict
At two-sided alpha 0.05 and 80% power, how many standard errors must the true lift sit from zero?
How far the true lift must sit from zero
0122.8 SE
10% to 12%, 3,839 per arm: one SE is 0.71 points
1.96
0.84
1.96 SE: zero to the bar, 1.40 points0.84 SE: the bar to the true lift, 2.00 points
Picture the measured difference d^, d-hat, between the two arms' rates. If the true lift is Δ, then d^ is roughly normal around Δ. SE, the standard error, is how far a typical estimate lands from the truth. The arms are independent, so the variance of d^ is the sum of theirs, and SE is its square root:
SE=np1(1−p1)+p2(1−p2)
Here p1 is the baseline rate, p2 the treatment rate and n the users in each arm: the ab-test lesson's pA, pB and nA=nB.
The test calls the result significant when d^ lands more than z1−α/2 standard errors from zero. That's the bar in the figure.
For d^ to clear the bar with probability 1−β, the bar has to sit z1−β standard errors below the truth. So the truth has to sit z1−α/2+z1−β standard errors from zero:
Δ=(z1−α/2+z1−β)SE
Square both sides, put in the SE and solve for n. Write σ12=p1(1−p1) and σ22=p2(1−p2) for the two arms' variances, with p2=p1+Δ:
n=Δ2(z1−α/2+z1−β)2(σ12+σ22)
In words: the two z's added and squared, times the two variances added, over the lift squared.
At α=0.05 and 80% power the z's add to 1.96 + 0.84 = 2.80. So the MDE has to sit 2.8 standard errors from zero, the same anchor Gelman and Carlin use.
The test could also come out significant in the wrong direction. At the MDE that chance is about one in a million, so the formula leaves it out.
In the editor, write ses_from_zero(p_baseline, mde, n): how many standard errors the true lift sits from zero, with n users per arm.
Pick an answer above to see the rest
Instructions
1
Write ses_from_zero(p_baseline, mde, n): the lift mde over the standard error of the measured difference, with n users in each arm.
2
The standard error is the square root of both arms' p * (1 - p) added, over n. The treatment arm's rate is p_baseline + mde.