R中二项式数据的置信区间? [英] Confidence interval for binomial data in R?
问题描述
我知道我需要 mean 和 s.d 才能找到间隔,但是,如果问题是:
I know that I need mean and s.d to find the interval, however, what if the question is:
在对 1,000 名随机选择的工人进行的调查中,其中 520 名是女性.根据调查为女性员工的比例创建 95% 的置信区间.
For a survey of 1,000 randomly chosen workers, 520 of them are female. Create a 95% confidence interval for the proportion of workers who are female based on the survey.
我如何找到平均值和标准差?
How do I find mean and s.d for that?
推荐答案
您也可以使用 stats
包中的 prop.test
或 binom.test代码>
You can also use prop.test
from package stats
, or binom.test
prop.test(x, n, conf.level=0.95, correct = FALSE)
1-sample proportions test without continuity correction
data: x out of n, null probability 0.5
X-squared = 1.6, df = 1, p-value = 0.2059
alternative hypothesis: true p is not equal to 0.5
95 percent confidence interval:
0.4890177 0.5508292
sample estimates:
p
0.52
您可能会发现有趣的这篇文章,其中第 861 页的表 1 给出了单个比例的不同置信区间,使用七种方法计算(针对选定的 n 和 r 组合).使用 prop.test
,您可以获得在表的第 3 行和第 4 行中找到的结果,而 binom.test
返回您在第 5 行中看到的结果.
You may find interesting this article, where in Table 1 on page 861 are given different confidence intervals, for a single proportion, calculated using seven methods (for selected combinations of n and r). Using prop.test
you can get the results found in rows 3 and 4 of the table, while binom.test
returns what you see in row 5.
这篇关于R中二项式数据的置信区间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!