Skip to content
Prev 10407 / 63424 Next

fisher.test() gives wrong confidence interval (PR#4019)

Right.  When going for a confidence interval that is to include the
parameter estimate and this is already at the boundary of the parameter
range, then there is no point finding mass even further away as there
obviously cannot be any.

I changed the code (r-devel) to

        CINT <- switch(alternative,
                       less = c(0, ncp.U(x, 1 - conf.level)),
                       greater = c(ncp.L(x, 1 - conf.level), Inf),
                       two.sided = {
                           if(ESTIMATE == 0)
                               c(0, ncp.U(x, 1 - conf.level))
                           else if(ESTIMATE == Inf)
                               c(ncp.L(x, 1 - conf.level), Inf)
                           else {
                               alpha <- (1 - conf.level) / 2
                               c(ncp.L(x, alpha), ncp.U(x, alpha))
                           }
                       })

which seems to fix the problem.

Thanks,

-k