From cberry at tajo.ucsd.edu  Wed Sep  3 19:57:34 2003
From: cberry at tajo.ucsd.edu (cberry@tajo.ucsd.edu)
Date: Thu Sep  4 03:58:52 2003
Subject: [Rd] fisher.test() gives wrong confidence interval (PR#4019)
In-Reply-To: <16208.30128.340961.32061@mithrandir.hornik.net>
Message-ID: <Pine.GSO.4.10.10309031812400.27155-100000@tajo.ucsd.edu>

On Sat, 30 Aug 2003, Kurt Hornik wrote:
[deleted]
> 
> 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))
>                            }
>                        })
> 

I believe that the resulting interval will sometimes fail to satisfy the
confidence statement for values of alpha other than 0 or Inf.

('sometimes' rather than always, because of the discreteness of the
distribution)

I think you need 

 if(ESTIMATE == 0)
                                c(0, ncp.U(x, 1 - conf.level / 2))
                            else if(ESTIMATE == Inf)
                                c(ncp.L(x, 1 - conf.level / 2 ), Inf)
                            else {
                                alpha <- (1 - conf.level) / 2
                                c(ncp.L(x, alpha), ncp.U(x, alpha))
                            }

> which seems to fix the problem.
> 
> Thanks,
> 
> -k
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
> 

Charles C. Berry                        (858) 534-2098 
                                         Dept of Family/Preventive Medicine
E mailto:cberry@tajo.ucsd.edu	         UC San Diego
http://hacuna.ucsd.edu/members/ccb.html  La Jolla, San Diego 92093-0717


[Rd] fisher.test() gives wrong confidence interval (PR#4019)
cberry@tajo.ucsd.edu