可以使用confint函数来计算并显示置信区间。
例如,假设我们有以下数据:
x <- c(10, 15) n <- c(50, 60)
进行比例检验:
prop.test(x, n)
得到结果:
2-sample test for equality of proportions with continuity correction
data: x out of n X-squared = 0.073529, df = 1, p-value = 0.786 alternative hypothesis: two.sided 95 percent confidence interval: -0.1441969 0.2064887 sample estimates: prop 1 prop 2 0.2000000 0.2500000
可以看到,这个比例检验的结果并没有显示置信区间。我们可以使用confint函数来计算并显示置信区间:
confint(prop.test(x, n))
得到结果:
2.5 % 97.5 %
prop 1 -0.1441969 0.3206136 prop 2 -0.2155066 0.4155066
可以看到,使用confint函数可以计算并显示置信区间。