均值差检验 returns 错误结果

test for difference of means returns wrong result

我是运行R-intro手册的例子:

A = c(79.98, 80.04, 80.02, 80.04, 80.03, 80.03, 80.04, 79.97, 80.05, 80.03, 80.02, 80.00, 80.02)
B = c(80.02, 79.94, 79.98, 79.97, 79.97, 80.03, 79.95, 79.97)
t.test(A, B)

产生以下结果:

Welch Two Sample t-test

data:  A and B
t = 3.2499, df = 12.027, p-value = 0.006939
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
 0.01385526 0.07018320
sample estimates:
mean of x mean of y 
 80.02077  79.97875 

问题是:如果平均值的差异包含在置信区间内(80.02077-79.97875=0.04202 和 0.01385526<0.04202<0.07018320),为什么得出备择假设为真而不是原假设为真是吗?

我认为这是一个 language/interpretation 问题。您正在翻译

alternative hypothesis: true difference in means is not equal to 0

作为

The alternative hypothesis is true. The difference in means is not equal to 0

而不是(按预期)

The alternative hypothesis is: "the true difference in means is not equal to 0"

(根据严格的常客逻辑,我们 永远不会 得出结论 "the alternative hypothesis is true",只有我们可以拒绝原假设。)

为了评估测试的结论,您应该查看 95% 置信区间 (0.01385526, 0.07018320) and/or p 值 (0.0069)。 R 中实现的过程 而不是 遵循 "Neyman-Pearson" 风格,您可以预先指定一个 alpha 级别并将结果二分为 "reject null hypothesis" 或 "fail to reject null hypothesis"。如果你想这样做,你可以只看 p 值,或者,如果你想让 R 为你做,

alpha <- 0.05  ## or whatever your preferred cutoff is
t_result <- t.test(A,B)
t_result$p.value<alpha ## TRUE (reject null hypothesis)

此外,您对置信区间的解释是错误的。您应该查看置信区间 是否包含零 ;它将始终以观察到的差异为中心(因此观察到的差异将 始终 包含在 95% CI 中)。