Paired binary sample size calculation (source code)

= Paired binary sample size calculation
{title2=$n\simeq\{z_{1-\alpha/2}\sqrt q+z_{1-\beta}\sqrt{q-\delta^2}\}^2/\delta^2$}

For a paired binary difference $D=C-M$, set $\delta=P(C=1)-P(M=1)$ and $q=P(C\ne M)$. Then $\mathbb ED=\delta$ and $\operatorname{Var}(D)=q-\delta^2$. Under equal marginal probabilities the variance is $q$. The <McNemar test> has approximate upper rejection boundary $z_{1-\alpha/2}\sqrt{nq}$ for the sum of differences. Requiring that the alternative mean $n\delta$ exceed this boundary by $z_{1-\beta}\sqrt{n(q-\delta^2)}$ gives the displayed planning size for a positive alternative, neglecting its very small lower-tail rejection probability. Use $z_{1-\alpha}$ for a pre-specified one-sided test. The marginal probabilities alone do not determine $q$: co-occurrence of positive outcomes must be specified or bounded. Discreteness and <clustered data> can change achieved <statistical power>.