Why the t.test returns a smallest p-value of 2.2e – 16 in R?


When we perform a t test in R and the difference between two groups is very large then the p-value of the test is printed as 2.2e – 16 which is a printing behaviour of R for hypothesis testing procedures. The actual p-value can be extracted by using the t test function as t.test(“Var1”,”Var2”,var.equal=FALSE)$p.value. This p-value is not likely to be the same as 2.2e – 16.

Example1

 Live Demo

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

Output

   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

Example2

 Live Demo

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

Output

   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

Example3

 Live Demo

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

Output

   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

Example4

 Live Demo

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

Output

   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

Updated on: 04-Sep-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements