Two proportion sample size calculation

Question

A drug maker wants to design a study in which two medications are compared. The first group has seen a improvement in 40%. Researchers want to see if the newer drug will improve this by 10% so they design a study. Assuming a study with power of 80% and a two-sided significance level of 5%. How many participants are required to detect a difference of 10% between the two groups.

My attempt and understanding

From the information gathered above there are two critical values $$Z_{1-\alpha/2} = 1.96$$ and $$Z_{\beta}=0.84$$ given the significance level of $$\alpha = 0.05$$. From the proportions, $$p_{0} = 0.4$$ and the proposed new drug should have the second group $$p_{1} = 0.5$$. The difference $$\theta = p_{1}-p_{0} = 0.1$$. The hypotheses

\begin{align} H_{0}:\theta &= 0 \\ H_{1}: \theta &\neq 0 \end{align}

However, I am unsure what formula has been used to calculate this. I have run command in R which has given me $$\approx 388$$ per group.

> power.prop.test(p1 = 0.4, p2 = 0.5, alternative = "two.sided",
+                 sig.level = 0.05,
+                 power = 0.80)

Two-sample comparison of proportions power calculation

n = 387.3385
p1 = 0.4
p2 = 0.5
sig.level = 0.05
power = 0.8
alternative = two.sided

NOTE: n is number in *each* group


However, I am unsure what formula has been used to calculate the sample size. From my understanding this has been a comparison of two binomial proportions. If I could get any assistance in understand how this was calculated, it would be greatly appreciated!

• Minor nitpick in the phrasing of question, there isn't one sample size that lets you detect "a difference of 10%", as that depends on the actual values that differ - this is specifically the number of patients needed to detect the difference between 40% and 50%. Finding the 10% difference between 40% and 50% requires more than five times as many subjects as finding the 10% difference between 0% and 10%! Apr 14, 2023 at 17:41

A formula based on a large sample test for the equality of two independent proportions is:

\begin{align} n_1 &= \kappa n_2 \\ n_2 &= \frac{(z_{\alpha/2} + z_{\beta})^2}{(p_1 - p_2)^2}\left[\frac{p_1(1 - p_1)}{\kappa} + p_2(1 - p_2)\right] \end{align}

Where $$p_1$$ and $$p_2$$ are the proportions, $$\kappa$$ is the allocation ratio and $$\alpha$$ and $$\beta$$ are the significance level and 1-Power.

Reference

Chow S-C, Shao J, Wang H, Lokhnygina Y (2018): Sample size calculations in clinical research. 3rd ed. CRC Press.

It isn't precisely from a formula. According to the code inside power.prop.test, the power for any value of n is calculated as

pnorm((sqrt(n) * abs(p1 - p2) - (qnorm(sig.level/2,lower.tail = FALSE) *
sqrt((p1 + p2) * (1 - (p1 + p2)/2))))/
sqrt(p1 * (1 - p1) + p2 * (1 - p2)))


or in traditional notation $$\Phi\left(\frac{\sqrt{n}|p_1-p_2|-z_{\alpha/2}\sqrt{(p_1+p_2)(1-(p_1+p_2)/2)}}{\sqrt{p_1(1-p_2)+p_2(1-p_2)}} \right)$$ and numerical root-finding methods are used to get the value of n that makes this equal to 80%.

That's not necessarily how you'd do the computations by hand.

• That is interesting. How would one go about calculating sample sizes by hand given the context? Apr 14, 2023 at 6:37