28/36
Part 5 of 6 · The worked exampleLearn and do

Power: count cities, not users

Power runs the same math backwards:

Garm=niid(1+(m−1)ρ)mG_{\text{arm}} = \frac{n_{\text{iid}} \big(1 + (m - 1)\rho\big)}{m}

In words: niidn_{\text{iid}} is the users per arm you'd need if users were independent. Times the design effect, it's the users you need. Divided by mm, the users per city, it's the cities you need in each arm.

Say you want to detect a lift of 0.1 standard deviations, at 5% two-sided, with 80% power. With independent users that's niid=2(1.96+0.84)2/0.12n_{\text{iid}} = 2(1.96 + 0.84)^2 / 0.1^2, about 1,570 per arm. Here 1.96 is the two-sided 5% cutoff, and 0.84 the point with 80% of the normal curve below it. The sample-size lesson derives this.

With 50 users per city and ρ=0.05\rho = 0.05, the design effect is 3.45. So it takes 5,416 users, 109 cities per arm.

In the editor, write cities_per_arm(effect_sd, m, icc): the cities per arm for a given city size and ICC.