Sample Size, $n$

Power, $1-\beta$

Type I error rate, $\alpha$

X-axis

min

max

Documentation
Test 1 Mean
Compare 2 Means
Compare k Means
Test 1 Proportion
Compare 2 Proportions
Compare Paired Proportions
Compare k Proportions
Test Time-To-Event Data
Test Odds Ratio
Test Relative Incidence in Self Controlled Case Series Studies
Other

## Calculate Sample Size Needed to Compare Paired Proportions: McNemar's Z-test, 1-Sided

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.

 Group 'B' Success Failure Group 'A' Success $n_{11}$ $n_{10}$ Failure $n_{01}$ $n_{00}$

Here, $n_{ij}$ represents the number of pairs having $i$ successes in Group 'A' and $j$ successes in Group 'B'. The corresponding proportions are denoted $p_{ij}$, with table

 Group 'B' Success Failure Group 'A' Success $p_{11}$ $p_{10}$ Failure $p_{01}$ $p_{00}$

Interest is in comparing the following hypotheses:

$H_0:$ Both groups have the same success probability
$H_1:$The success probability is not equal between the Groups

Mathematically, this can be represented as
$H_0:p_{10}=p_{01}$
$H_1:p_{10}\lt p_{01}$

or
$H_0:p_{10}=p_{01}$
$H_1:p_{10}\gt p_{01}$

In the formulas below, we use the notation that
$p_{disc}=p_{10}+p_{01}$

and
$p_{diff}=p_{10}-p_{01}$

### Formulas

This calculator uses the following formulas to compute sample size and power, respectively: $$n=\left(\frac{z_{1-\alpha}\sqrt{p_{disc}}+z_{1-\beta}\sqrt{p_{disc}-p_{diff}^2}}{p_{diff}}\right)^2$$
$$1-\beta=\Phi\left(\frac{|p_{diff}|\sqrt{n}-z_{1-\alpha}\sqrt{p_{disc}}}{\sqrt{p_{disc}-p_{diff}^2}}\right)$$
where

### R Code

R code to implement these functions:

p01=0.45
p10=0.05
alpha=0.05
beta=0.10
pdisc=p10+p01
pdiff=p10-p01
(n=((qnorm(1-alpha)*sqrt(pdisc)+qnorm(1-beta)*sqrt(pdisc-pdiff^2))/pdiff)^2)
ceiling(n) # 23
x=(abs(pdiff)*sqrt(n)-qnorm(1-alpha)*sqrt(pdisc))/sqrt(pdisc-pdiff^2);
(Power = pnorm(x))

### References

Connor R. J. 1987. Sample size for testing differences in proportions for the paired-sample design. Biometrics 43(1):207-211. page 209.