R中t.test返回2.2e – 16的最小p值的原因是什么?


当我们在R中执行t检验时,如果两个组之间的差异很大,则检验的p值显示为2.2e – 16,这是R对假设检验过程的打印行为。实际的p值可以通过使用t检验函数作为t.test(“Var1”,”Var2”,var.equal=FALSE)$p.value来提取。此p值不可能与2.2e – 16相同。

示例1

 在线演示

> x1<-1:100
> y1<-100001:110000
> t.test(x1,y1,var.equal=FALSE)

输出

   Welch Two Sample t-test
data: x1 and y1
t = -3617.2, df = 10098, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-105006.9 -104893.1
sample estimates:
mean of x mean of y
   50.5 105000.5
> t.test(x1,y1,var.equal=FALSE)$p.value
[1] 0

示例2

 在线演示

> x2<-sample(1:10,50,replace=TRUE)
> y2<-sample(500:510,replace=TRUE)
> t.test(x2,y2,var.equal=FALSE)

输出

   Welch Two Sample t-test
data: x2 and y2
t = -427.61, df = 12.789, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-500.4179 -495.3785
sample estimates:
mean of x mean of y
   5.9200 503.8182
> t.test(x2,y2,var.equal=FALSE)$p.value
[1] 5.881324e-28

示例3

 在线演示

> x3<-sample(101:110,50,replace=TRUE)
> y3<-sample(1001:1010,50,replace=TRUE)
> t.test(x3,y3,var.equal=FALSE)

输出

   Welch Two Sample t-test
data: x3 and y3
t = -1730.7, df = 97.907, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-901.4725 -899.4075
sample estimates:
mean of x mean of y
   105.38 1005.82
> t.test(x3,y3,var.equal=FALSE)$p.value
[1] 2.07048e-221

示例4

 在线演示

> x4<-sample(1001:1010,50,replace=TRUE)
> y4<-sample(100001:1000010,50)
> t.test(x4,y4,var.equal=FALSE)

输出

   Welch Two Sample t-test
data: x4 and y4
t = -14.798, df = 49, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-620129.5 -471835.6
sample estimates:
mean of x mean of y
   1005.6 546988.1
> t.test(x4,y4,var.equal=FALSE)$p.value
[1] 1.043251e-19

更新日期:2020年9月4日

2K+浏览量

开启你的 职业生涯

通过完成课程获得认证

开始吧
广告