I'm wondering if anyone has insight into how prop.test()
in R calculates its confidence intervals. Although it doesn't state it explicitly in its documentation, my understanding is that this function uses the normal approximation to the binomial. This assumption is based upon the following:
- In the documentation, it states its
parameter
value represents "the degrees of freedom of the approximate chi-squared distribution of the test statistic." - It has the option to apply Yates's continuity correction
- I've seen this function used in many examples (albeit online, but at many sites with a .edu suffix if that means anything) where the normal is used to approximate the binomial
If prop.test()
really does use the normal approximation to the binomial, I would think the CI it calculates would be a Wald-type interval, but, again, the documentation doesn't state this explicitly.
The issue is the result I get is not congruent with what I get by hand, which is the same as what SAS gives. Here's an example:
Let
x = Number of successes = 319
n = Fixed number of trials = 1100
$\alpha$ = 0.01/Confidence level = 0.99
The Wald-type interval, by hand, is thus
$\hat p \mp z_\frac{\alpha}{2}\sqrt{\frac{\hat p(1 - \hat p)}{n}} = 0.29 \mp 2.575829(0.01368144) = (0.25476, 0.32524)$
I get the same result in SAS as shown here (upper portion of the output is the approximate CI, the lower is the exact CI based on the binomial):
However, when I run prop.test()
in R (also without Yates's correction, to be consistent with my hand calculation and SAS), I get something slightly different:
The 99% CI from the output above is (0.2561, 0.3264).
Any thoughts on where this discrepancy is coming from? Doesn't seem attributable to rounding error, nor would I expect an R function to round enough during its calculations so as to affect the third decimal place anyway.