4
$\begingroup$

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

$\endgroup$

1 Answer 1

5
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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