I'm having trouble calculating 95% confidence intervals for a change in binomial proportion. For example, in group $A$, there are $4$ successes out of $n =20$. In group $B$, there are $12$ successes out of $n =20$. I am able to calculate the CIs for the proportions separately in R using:


However, I'm interested in the change in proportion for these two groups, group $A = 0.2$ and group $B = 0.6$ with the change in proportion being $0.4$. What I'm really lost on is how to calculate the CIs for this change ($0.4$)?


The function prop.test in R calculates the confidence interval for the difference of proprotions if two proportions are entered. Use it in the following way prop.test(x=c(12, 4), n=c(20, 20), alternative="two.sided", conf.level=0.95). The 95%-confidence interval for the difference in your case is $(0.073, 0.727)$.


You could also do a permutation test with the package exactRankTests in R. The code is:


groupB <- c(rep(1, 12), rep(0, 8))
groupA <- c(rep(1, 4), rep(0, 16))

perm.test(groupB, groupA, exact=TRUE, conf.int=TRUE)

The confidence interval based on the permutation test is $(0.1, 0.7)$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.