[R] fisher.test gives p>1

Bernardo Rangel Tura tura at centroin.com.br
Thu Mar 4 20:27:16 CET 2010


On Thu, 2010-03-04 at 11:15 -0500, Jacob Wegelin wrote:
> The purpose of this email is to
> 
> (1) report an example where fisher.test returns p > 1
> 
> (2) ask if there is a reliable way to avoid p>1 with fisher.test.
> 
> If one has designed one's code to return an error when it finds a "nonsensical" probability, of course a value of p>1 can cause havoc.
> 
> Example:
> 
> > junk<-data.frame(score=c(rep(0,14), rep(1,29), rep(2, 16)))
> > junk<-rbind(junk, junk)
> > junk$group<-c(rep("DOG", nrow(junk)/2), rep("kitty", nrow(junk)/2))
> > table(junk$score, junk$group)
> 
>      DOG kitty
>    0  14    14
>    1  29    29
>    2  16    16
> > dput(fisher.test(junk$score, junk$group)$p.value)
> 1.00000000000012

Hi jacob,

I think this is cover in R FAQ 7.31, but look this command
all.equal(dput(fisher.test(matrix(c(14,14,29,29,16,16),byrow=T,ncol=2))$p.value),1)
1.00000000000012
[1] TRUE

P.S
R FAQ 7.31 -
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil



More information about the R-help mailing list