Reputation: 553
R
> prop.test(x =44, n = 63, p = 0.8, alternative = "two.sided", correct = FALSE)
95 percent confidence interval:
**0.5763963 0.7976231**
Stata
. prtesti 63 44 0.8, count
95% Conf. Interval
**.5850839 .8117415**
Why 95%CIs of One sample tests of proportions were different in Stata and R,Thanks!
Upvotes: 2
Views: 625
Reputation: 226162
http://www.stata.com/manuals13/rprtest.pdf suggests that Stata is using the normal approximation. The epitools
package provides a range of binomial CI calculators:
Normal approximation (matches Stata):
binom.approx(44,63)
x n proportion lower upper conf.level
1 44 63 0.6984127 0.5850839 0.8117415 0.95
Exact (matches binom.test()
in base R):
binom.exact(44,63)
x n proportion lower upper conf.level
1 44 63 0.6984127 0.5697502 0.8076894 0.95
Wilson's formula (matches prop.test()
in base R):
binom.wilson(44,63)
x n proportion lower upper conf.level
1 44 63 0.6984127 0.5763963 0.7976231 0.95
EDIT (Nick Cox) Some further Stata results, here from cii
which accepts input calculator-style:
. cii 63 44, wald
-- Binomial Wald ---
Variable | Obs Mean Std. Err. [95% Conf. Interval]
-------------+---------------------------------------------------------------
| 63 .6984127 .0578219 .5850839 .8117415
The default is so-called "exact" (Clopper-Pearson):
. cii 63 44
-- Binomial Exact --
Variable | Obs Mean Std. Err. [95% Conf. Interval]
-------------+---------------------------------------------------------------
| 63 .6984127 .0578219 .5697502 .8076894
. cii 63 44, wilson
------ Wilson ------
Variable | Obs Mean Std. Err. [95% Conf. Interval]
-------------+---------------------------------------------------------------
| 63 .6984127 .0578219 .5763963 .7976231
. cii 63 44, jeffreys
----- Jeffreys -----
Variable | Obs Mean Std. Err. [95% Conf. Interval]
-------------+---------------------------------------------------------------
| 63 .6984127 .0578219 .5781254 .8009394
The moral is simple. In any decent statistical software, several options are available for binomial confidence intervals. Just read the documentation to know what is the default for your software, and pay attention to other options that are available.
END OF EDIT
Upvotes: 3