[R] hypergeometric vs fisher.test
peter dalgaard
pdalgd at gmail.com
Fri Aug 13 17:05:36 CEST 2010
On Aug 13, 2010, at 3:47 PM, Andrea Franceschini wrote:
>
> Dear R team,
> I have a simple question.
>
> I tried this command:
> phyper(17,449,19551,181, FALSE)
> [1] 1.47295e-07
>
> and then I tried this command:
> (fisher.test(matrix(c(17,449,181,19551),2,2),
> alternative='greater'))$p.value
> [1] 3.693347e-06
>
>
> Shouldn't be identical the results of the two commands ?
> What is the difference ?
Just read the phyper docs more carefully (and perhaps revisit the theory), and you'll see that phyper is using margin totals of the table, where fisher.test is using the individual entries. Also beware of left/right continuity issues with tails of discrete distributions: The convention is that the lower and the upper tail sums to 1, so your "17" is NOT included in the upper tail.
>
> Thx a lot
> --
> View this message in context: http://r.789695.n4.nabble.com/hypergeometric-vs-fisher-test-tp2324223p2324223.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list