Menu
Inputs
Calculate Sample Size Needed to Compare Paired Proportions: McNemar's Z-test, 2-Sided Equality
This calculator is useful for tests comparing paired proportions. Suppose that our sample consists of pairs of subjects, and that each pair contains a subject from group 'A' and a subject from group 'B'. Further suppose that we wish to compare the probability that an event occurs in group 'A' to that in group 'B'. Example study designs include matched case-control studies and cross-over studies. Conceptually, the data can be listed as in the following table.
Here, represents the number of pairs having successes in Group 'A' and successes in Group 'B'. The corresponding proportions are denoted , with table
Interest is in comparing the following hypotheses:
Mathematically, this can be represented as
In the formulas below, we use the notation that
and
Formulas
This calculator uses the following formulas to compute sample size and power, respectively:
where
is sample size
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
1p01=0.45
2p10=0.05
3alpha=0.05
4beta=0.20
5pdisc=p10+p01
6pdiff=p10-p01
7(n=((qnorm(1-alpha/2)*sqrt(pdisc)+qnorm(1-beta)*sqrt(pdisc-pdiff^2))/pdiff)^2)
8ceiling(n) # 23
9x1=( pdiff*sqrt(n)-qnorm(1-alpha/2)*sqrt(pdisc))/sqrt(pdisc-pdiff^2);
10x2=(-pdiff*sqrt(n)-qnorm(1-alpha/2)*sqrt(pdisc))/sqrt(pdisc-pdiff^2);
11(Power = pnorm(x1)+pnorm(x2))References
Connor R. J. 1987. Sample size for testing differences in proportions for the paired-sample design. Biometrics 43(1):207-211. page 209.