# Sample size function for McNemar test of repeated proportions in R

I have been scouring CRAN and Google for a function (that I wouldn't have to code myself) that would calculate the sample size needed for a pre-post design with a dichotomous outcome - to no avail. If I'm wrong, please let me know!

I came across an R script from a university course and was wondering if someone wouldn't mind double-checking it for me - I've revised it a bit. (the URL is: http://www.statistik.lmu.de/institut/lehrstuhl/semwiso/bm-sose2009/CaCo/v8_4.pdf)

samsize.mcnemar <- function(pi.01, pi.10, alpha, beta, sided)
{
pi.d <- (pi.01 + pi.10)
N <- (qnorm(1 - alpha/sided) * sqrt(pi.d) + qnorm(1 - beta) *
sqrt(pi.d - (pi.01 - pi.10)^2))^2/(pi.01 - pi.10)^2
return(ceiling(N))
}
# in my case, I am assuming that the 0 to 1 change will be 0.13 and that no
# one will change from 1 to 0

samsize.mcnemar(pi.01 = 0.13, pi.10 = 0, alpha = 0.05, beta = 0.2, sided = 2)


First, does this look correct?

Second, since this is not a matched-pairs design, I am not assuming that the intervention will cause people to revert back (if they are already performing the healthy behaviour). Should I be more conservative?

Thanks!

• Hi, i think G*Power 3 provides power analysis for McNemar test too. You can take a look at it here. – Yulong Aug 1 '14 at 2:05