From p.dalgaard@biostat.ku.dk  Thu Feb 24 16:58:49 2000
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 24 Feb 2000 17:58:49 +0100
Subject: [Rd] fisher.test() in ctest or perhaps uniroot() (PR#455)
In-Reply-To: thomas@biostat.washington.edu's message of "Thu, 24 Feb 2000 17:35:51 +0100 (MET)"
References: <200002241635.RAA04398@pubhealth.ku.dk>
Message-ID: <x2n1oqpmeu.fsf@blueberry.kubism.ku.dk>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] fisher.test() in ctest or perhaps uniroot() (PR#455)
Peter Dalgaard BSA