Menu

Inputs

Calculate Sample Size Needed to Test 1 Proportion: 1-Sample, 2-Sided Equality

This calculator is useful for tests concerning whether a proportion, pp, is equal to a reference value, p0p_0. The Null and Alternative hypotheses are
H0:p=p0H_0:p=p_0
H1:pp0H_1:p\neq p_0

Formulas

This calculator uses the following formulas to compute sample size and power, respectively:
n=p(1p)(z1α/2+z1βpp0)2n=p(1-p)\left(\frac{z_{1-\alpha/2}+z_{1-\beta}}{p-p_0}\right)^2
1β=Φ(zz1α/2)+Φ(zz1α/2),z=pp0p(1p)n1-\beta= \Phi\left(z-z_{1-\alpha/2}\right)+\Phi\left(-z-z_{1-\alpha/2}\right) \quad ,\quad z=\frac{p-p_0}{\sqrt{\frac{p(1-p)}{n}}}
where nn is sample size p0p_0 is the comparison value Φ\Phi is the standard Normal distribution function Φ1\Phi^{-1} is the standard Normal quantile function α\alpha is Type I error β\beta is Type II error, meaning 1β1-\beta is power

R Code

1p=0.5
2p0=0.3
3alpha=0.05
4beta=0.20(n=p*(1-p)*((qnorm(1-alpha/2)+qnorm(1-beta))/(p-p0))^2)
5ceiling(n) # 50
6z=(p-p0)/sqrt(p*(1-p)/n)(Power=pnorm(z-qnorm(1-alpha/2))+pnorm(-z-qnorm(1-alpha/2)))

References

Chow S, Shao J, Wang H. 2008. Sample Size Calculations in Clinical Research. 2nd Ed. Chapman & Hall/CRC Biostatistics Series. page 85.