如何在 R 中查找二项分布的 95% 置信区间?


二项分布数据有两个参数,样本容量和成功次数。要查找 95% 置信区间,我们只需使用 R 中的 prop.test 函数即可,但我们需要确保将正确的参数设为 FALSE,以便在不进行连续修正的情况下计算置信区间。在以下示例中,我们查找了不同样本容量值和成功次数的 95% 置信区间。

范例

 在线演示

prop.test(x=25,n=100,conf.level=0.95,correct=FALSE)

输出

1-sample proportions test without continuity correction
data: 25 out of 100, null probability 0.5
X-squared = 25, df = 1, p-value = 5.733e-07
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.1754521 0.3430446
sample estimates:
p
0.25

Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.

范例

 在线演示

prop.test(x=5,n=100,conf.level=0.95,correct=FALSE)

输出

1-sample proportions test without continuity correction
data: 5 out of 100, null probability 0.5
X-squared = 81, df = 1, p-value < 2.2e-16
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.02154368 0.11175047
sample estimates:
p
0.05

范例

 在线演示

prop.test(x=5,n=1000,conf.level=0.95,correct=FALSE)

输出

1-sample proportions test without continuity correction
data: 5 out of 1000, null probability 0.5
X-squared = 980.1, df = 1, p-value < 2.2e-16
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.002137536 0.011650955
sample estimates:
p
0.005

范例

 在线演示

prop.test(x=5,n=10,conf.level=0.95,correct=FALSE)

输出

1-sample proportions test without continuity correction
data: 5 out of 1000, null probability 0.5
X-squared = 980.1, df = 1, p-value < 2.2e-16
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.002137536 0.011650955
sample estimates:
p
0.005

范例

 在线演示

prop.test(x=50,n=100,conf.level=0.95,correct=FALSE)

输出

1-sample proportions test without continuity correction
data: 50 out of 100, null probability 0.5
X-squared = 0, df = 1, p-value = 1
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.4038315 0.5961685
sample estimates:
 p
 0.5

范例

 在线演示

prop.test(x=500,n=1125,conf.level=0.95,correct=FALSE)

输出

1-sample proportions test without continuity correction
data: 500 out of 1125, null probability 0.5
X-squared = 13.889, df = 1, p-value = 0.0001939
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.4156458 0.4736212
sample estimates:
 p
 0.4444444

范例

 在线演示

prop.test(x=5000,n=9874,conf.level=0.95,correct=FALSE)

输出

1-sample proportions test without continuity correction
data: 5000 out of 9874, null probability 0.5
X-squared = 1.6079, df = 1, p-value = 0.2048
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.4965185 0.5162373
sample estimates:
p
0.5063804

更新时间:2020 年 10 月 10 日

703 次浏览

开启您的事业

通过完成课程获得认证

开始吧
广告