Menu
Inputs
Calculate Sample Size Needed to Compare 2 Proportions: 2-Sample, 1-Sided
This calculator is useful for tests concerning whether the proportions in two groups are different. Suppose the two groups are 'A' and 'B', and we collect a sample from both groups -- i.e. we have two samples. We perform a two-sample test to determine whether the proportion in group A, , is different from the proportion in group B, . The hypotheses are
.
or
.
where the ratio between the sample sizes of the two groups is
Formulas
This calculator uses the following formulas to compute sample size and power, respectively:
where
is the matching ratio
is the standard Normal distribution function
is the standard Normal quantile function
is Type I error
is Type II error, meaning is power
R Code
1pA=0.65
2pB=0.85
3kappa=1
4alpha=0.05
5beta=0.20
6(nB=(pA*(1-pA)/kappa+pB*(1-pB))*((qnorm(1-alpha)+qnorm(1-beta))/(pA-pB))^2)
7ceiling(nB) # 55
8z=(pA-pB)/sqrt(pA*(1-pA)/nB/kappa+pB*(1-pB)/nB)
9(Power=pnorm(abs(z)-qnorm(1-alpha)))
10## Note:The example from Chow p.89 is obtained
11## by using alpha=0.025References
Chow S, Shao J, Wang H. 2008. Sample Size Calculations in Clinical Research. 2nd Ed. Chapman & Hall/CRC Biostatistics Series. page 89.