4

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:

binom.test(4,20,(1/2),alternative="two.sided")
binom.test(12,20,(1/2),alternative="two.sided")

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$)?

gung - Reinstate Monica
  • 132,789
  • 81
  • 357
  • 650
user25493
  • 43
  • 2

1 Answers1

5

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)$.

EDIT

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

library(exactRankTests)

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)$.

COOLSerdash
  • 25,317
  • 8
  • 73
  • 123