[Rd] negative p-values from fisher's test (PR#7801)

mnason at Niaid.nih.gov mnason at Niaid.nih.gov
Wed Apr 20 23:31:35 CEST 2005


Full_Name: Martha Nason
Version: 2.0.1
OS: Windows XP
Submission from: (NULL) (137.187.154.154)


I am running simulations using fisher's test on 2 x c tables and a very small
p.value from fisher's test (<2.2e-16) is returned as a negative number. Code
follows. 

> set.seed(0)
> nreps.outer <-7
> pvalue.fisher <- rep(NA,nreps.outer)
> 
> population1 <- c( rep("A",300),seq(1:100)) 
> 
> population2 <- c( rep("A",100),seq(101:200))
> 
> 
> for (j in 1:nreps.outer){
+ n1 <- sample(30:100,1)
+ n2 <- sample(30:100,1)
+ 
+ group1 <- sample(population1, n1, replace=T)
+ group2 <- sample(population2, n2, replace=T)
+ 
+ pvalue.fisher[j] <-
fisher.test(table(c(group1,group2),c(rep("group1",n1),rep("group2",n2))))$p.value
+ 
+ print(c(j,pvalue.fisher[j]))
+ 
+ }
[1] 1.000000e+00 3.581362e-05
[1] 2.0000000 0.1424779
[1] 3.0000000 0.1196600
[1] 4.000000000 0.004222897
[1] 5.000000e+00 3.234016e-07
[1] 6.000000000 0.003240286
[1]  7.000000e+00 -3.847298e-05

> 
> fisher.test(table(c(group1,group2),c(rep("group1",n1),rep("group2",n2))))

        Fisher's Exact Test for Count Data

data:  table(c(group1, group2), c(rep("group1", n1), rep("group2", n2))) 
p-value < 2.2e-16
alternative hypothesis: two.sided 

> fisher.test(table(c(group1,group2),c(rep("group1",n1),rep("group2",n2))))$p.value
[1] -3.847298e-05



More information about the R-devel mailing list