为什么在Stata和R中,一个样本比例测试的95%CI是不同的

时间:2014-06-05 15:02:52

标签: r stata

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**

为什么在Stata和R中,一个样本测试比例的95%CI是不同的,谢谢!

1 个答案:

答案 0 :(得分:3)

http://www.stata.com/manuals13/rprtest.pdf表明Stata正在使用正常近似值。 epitools包提供了一系列二项式CI计算器:

正态近似(匹配Stata):

binom.approx(44,63)
   x  n proportion     lower     upper conf.level
1 44 63  0.6984127 0.5850839 0.8117415       0.95

确切(匹配基础R中的binom.test()):

binom.exact(44,63)
   x  n proportion     lower     upper conf.level
1 44 63  0.6984127 0.5697502 0.8076894       0.95

威尔逊的公式(匹配基础R中的prop.test()):

binom.wilson(44,63)
   x  n proportion     lower     upper conf.level
1 44 63  0.6984127 0.5763963 0.7976231       0.95
编辑(尼克考克斯)进一步的Stata结果,来自cii接受输入计算器风格:

. cii 63 44, wald

                                                     -- Binomial Wald ---
    Variable |        Obs        Mean    Std. Err.       [95% Conf. Interval]
-------------+---------------------------------------------------------------
             |         63    .6984127    .0578219        .5850839    .8117415

默认是所谓的“确切”(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

道德很简单。在任何体面的统计软件中,有两个选项可用于二项式置信区间。只需阅读文档即可了解软件的默认设置,并注意其他可用选项。

编辑结束