# Confidence interval for difference between proportions

I'm wondering if someone could let me know if I have calculated the confidence interval for the difference between two proportions correctly.

The sample size is 34, of which 19 are females and 15 are males. Therefore, the difference in proportions is 0.1176471.

I calculate the 95% confidence interval for the difference to be between -0.1183872 and 0.3536814. As the confidence interval passes through zero, the difference is not statistically significant.

Below are my workings out in R, with results as comments:

f <- 19/34
# 0.5588235

m <- 15/34
# 0.4411765

n <- 34
# 34

difference <- f-m
# 0.1176471

lower <- difference-1.96*sqrt((f*(1-f))/n+(m*(1-m))/n)
# -0.1183872

upper <- difference+1.96*sqrt((f*(1-f))/n+(m*(1-m))/n)
# 0.3536814

• Your calculations are correct. If you use Rs internal function prop.test, you'll get the same result: prop.test(x=c(19,15), n=c(34,34), correct=FALSE) – COOLSerdash May 26 '13 at 21:26

My original answer that was accepted by OP assumes a two-sample setting. OP's question deals with a one-sample setting. Hence, @Robert Lew's answer is the correct one in this case.

Your formulas and calculations are correct. Rs internal function to compare proportions yields the same result (without continuity correction though):

prop.test(x=c(19,15), n=c(34,34), correct=FALSE)

2-sample test for equality of proportions without continuity correction

data:  c(19, 15) out of c(34, 34)
X-squared = 0.9412, df = 1, p-value = 0.332
alternative hypothesis: two.sided
95 percent confidence interval:
-0.1183829  0.3536770
sample estimates:
prop 1    prop 2
0.5588235 0.4411765


• In the OP, clearly a one sample setting is described. Your solution refers to a two sample setting and therefore seems to be wrong. – Michael M Jul 29 '15 at 19:13
• @Robert Lew's answer seems to be the correct one in this case. – Gregor - reinstate Monica Sep 29 '16 at 5:22

In this case you have to use a one-sample test, as this is a single sample. Your question boils down to whether males (or females) are one half. Here's how you'd do it using prop.test():

prop.test(x=19, n=34, p=0.5, correct=FALSE)

1-sample proportions test without continuity correction

data:  19 out of 34, null probability 0.5
X-squared = 0.47059, df = 1, p-value = 0.4927
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.3945390 0.7111652
sample estimates:
p
0.5588235


Thought of small sample sizes, an exact CI can be computed using ExactCIdiff::BinomCI such that:

library(ExactCIdiff)
BinomCI(34,34,19,15)
$conf.level  0.95$CItype
 "Two.sided"

$estimate  0.1176$ExactCI
 -0.1107  0.3393