Solved – Confidence interval for difference between proportions

confidence intervalr

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

Best Answer

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.

Original answer

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

Related Question