[Rd] Bug in FEXACT: gave negative key (PR#6986)

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Jun 17 12:25:36 CEST 2004


fc at maths.uq.edu.au writes:

> Hello,
> 
> I'm using R to apply Fishers exact test to a whole pile of
> contingency tables, and I've run into the bug shown below.
> 
> regards,
> 
> Francis
> 
> --
> 
> > dat1 = matrix(c(0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1,0,0,1,0,0,0,0,
>            1,1,0,0,1,0,0,1,0,0,1,0,0,3,0,0,2,0,0,1,0,0,0,1,0,0,2,0,0,
>           2,0,0,1,0,1,0,0,3,0,0,2,0,0,0,1,0,5,0,0,0,1,0,1,0,0),    nrow=3)
> 
> > fisher.test( dat1 )
> 
> Error in fisher.test(dat1) : Bug in FEXACT: gave negative key

I suppose it counts as a bug when FEXACT says so. However it is most
likely caused by integer overrun, and so really a code for "problem too
large". I.e. we can probably fix the error message, put not get
fisher.test to do the problem. Consider instead

> chisq.test(dat1,sim=T,B=50000)

        Pearson's Chi-squared test with simulated p-value (based on 50000
        replicates)

data:  dat1
X-squared = 80, df = NA, p-value = 2e-05


BTW, a line with "-- " at the start means beginning of signature, and
mail readers may do funny things with the subsequent text. Mine just
puts it in italics, but others might elect to discard the signature
completely or chop it to four lines, etc.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907



More information about the R-devel mailing list