From p.dalgaard at biostat.ku.dk  Thu Jun 17 12:25:36 2004
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Thu Jun 17 12:33:16 2004
Subject: [Rd] Bug in FEXACT: gave negative key (PR#6986)
In-Reply-To: <20040617100047.B13DB1057B@slim.kubism.ku.dk>
References: <20040617100047.B13DB1057B@slim.kubism.ku.dk>
Message-ID: <x2r7sexyzj.fsf@biostat.ku.dk>

fc@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@biostat.ku.dk)             FAX: (+45) 35327907


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