fisher.test() in ctest or perhaps uniroot() (PR#455)
thomas@biostat.washington.edu writes:
fisher.test(matrix(c(1,20,246,6873),2),hybrid=F)
Error in if (f(lower, ...) * f(upper, ...) >= 0) stop("f() values at end
points not of opposite sign") :
missing value where logical needed
Problem seems to be that mnhyper as defined doesn't like extreme arguments, and is being called with 1/.Machine$double.eps e.g.
get("mnhyper",envir=DUMP$sys.frames[[2]])(1000000000000000)
[1] NaN
get("mnhyper",envir=DUMP$sys.frames[[2]])(100000000000000)
[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.test(matrix(c(1,20,246,6873),2),hybrid=F)
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
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 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._