Skip to content
Prev 3341 / 63424 Next

fisher.test() in ctest or perhaps uniroot() (PR#455)

thomas@biostat.washington.edu writes:
Problem seems to be that mnhyper as defined doesn't like extreme
arguments, and is being called with

 1/.Machine$double.eps

e.g.
[1] NaN
[1] 21

The code looks like this:

    if (ncp == 0) 
        return(lo)
    if (ncp == Inf) 
        return(hi)
    q <- lo:hi
    d <- dhyper(q, m, n, k) * ncp^(0:(hi - lo))

And I suspect that the test should be ncp^(hi-lo)==Inf.

Seems to work:
Fisher's Exact Test for Count Data 

data:  matrix(c(1, 20, 246, 6873), 2) 
p-value = 0.5231 
alternative hypothesis: true odds ratio is not equal to 1 
95 percent confidence interval:
 0.0335691 8.8064130 
sample estimates:
odds ratio 
  1.396855