Bug 7801 - negative p-values from fisher's test
Summary: negative p-values from fisher's test
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Accuracy (show other bugs)
Version: old
Hardware: ix86 (32-bit) Windows 32-bit
: P5 normal
Assignee: Jitterbug compatibility account
URL:
Depends on:
Blocks:
 
Reported: 2005-04-21 02:31 UTC by Jitterbug compatibility account
Modified: 2005-04-21 02:31 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jitterbug compatibility account 2005-04-21 02:31:28 UTC
From: mnason@Niaid.nih.gov
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

Comment 1 Jitterbug compatibility account 2005-05-28 03:30:00 UTC
NOTES:
 Bug is in TOMS 643.  One of the authors attributes it to rounding error.
Comment 2 Jitterbug compatibility account 2005-05-28 05:25:33 UTC
Audit (from Jitterbug):
Thu May 12 16:57:45 2005	thomas	changed notes
Fri May 13 16:21:53 2005	thomas	moved from incoming to Accuracy
Tue May 17 17:37:42 2005	thomas	changed notes
Sat May 28 00:25:33 2005	thomas	changed notes