计算均数的可信区间
You have a sample from a population. Given that sample, you want to determine a confidence interval for the population’s mean. 公卫家园
Apply the t.test function to your sample x:
> t.test(x)
The output includes a confidence interval at the 95% confidence level. To see intervals
公卫百科
at other levels, use the conf.level argument.
> x <- rnorm(50, mean=100, sd=15)
> t.test(x)
One Sample t-test
公卫论坛
data: x
t = 59.2578, df = 49, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval: 公卫家园
97.16167 103.98297
sample estimates:
mean of x
100.5723
In this example, the confidence interval is approximately 97.16 < μ < 103.98, which is
公卫考场
sometimes written simply as (97.16, 103.98).
We can raise the confidence level to 99% by setting conf.level=0.99:
> t.test(x, conf.level=0.99)
One Sample t-test 公卫考场
data: x
t = 59.2578, df = 49, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 0
99 percent confidence interval: 公卫论坛
96.0239 105.1207
sample estimates:
mean of x
100.5723
That change widens the confidence interval to 96.02 < μ < 105.12.
附件列表
词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。
如果您认为本词条还有待完善,请 编辑
上一篇 按数据框中的变量名选择变量 下一篇 比例的可信区间