I am running the following simple Z test for proportions in R:
prop.test(x = c(10, 20), n = c(100, 500))
The results are as follows:
2-sample test for equality of proportions with continuity correction
data: c(10, 20) out of c(100, 500)
X-squared = 5.1158, df = 1, p-value = 0.02371
alternative hypothesis: two.sided
95 percent confidence interval:
-0.007256322 0.127256322
sample estimates:
prop 1 prop 2
0.10 0.04
How is it possible for the p value of the Z test to be below 0.05, but for the 95% confidence interval to straddle zero? I've found this question on the behaviour of the prop.test function itself and this one on the alternative ways of constructing the CI but I don't think either explains what's going on in this case.
The top answer to this question suggests I'm right in thinking this output should be impossible!