[R] hypergeometric vs fisher.test

Peter Dalgaard pdalgd at gmail.com
Fri Aug 13 23:11:57 CEST 2010


Andrea Franceschini wrote:
> I ask the question also because I found this line in Wikipedia:
> "The test (see above) based on the hypergeometric distribution
> (hypergeometric test) is identical to the corresponding one-tailed
> version of Fisher's exact test".
> 
> Is this wrong ?  May I kindly ask a friendly explanation for
> not-experts in statistics ?
> 
> Thx a lot,
> 

You never said you were a non-expert. A question like that might very
well have come from a student, or an incompetent claiming to have found
a bug in fisher.test...

The point was that Fisher's test takes the 2x2 table

a b
c d

and interprets the situation under the null hypothesis as taking a
sample of size a+c from an urn with a+b white balls and c+d black balls.

Once you read the docs for phyper properly (it _is_ tricky to get it
right), you arrive at

> phyper(16,17+181,449+19551,17+449, lower.tail=FALSE)
[1] 3.693347e-06


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list