Power for difference in two independent proportions using R
Copy and paste the below inputs into R and adjust as needed.
alpha <- 0.05 p1 <- 0.19 p2 <- 0.09 delta <- 1 n1 <- 167
Now, copy and paste the below into R. The power, pow, and odds ratio, oddsr, should be outputted.
n2 <- delta*n1 pbar <- (n1*p1 + n2*p2) / (n1+n2) chisq <- ( (p1-p2) / sqrt( pbar*(1-pbar)*( (1/n1) + (1/n2) ) ) )^2 pow <- 1 - pchisq(abs(qchisq(1-alpha,1)),1,chisq) cat("Power of test=") print(pow) cat("Odds Ratio=") oddsr <- ( n1*p1*n2*(1-p2) ) / ( n1*(1-p1)*n2*p2 ) print(oddsr)