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

jerome at hivnet.ubc.ca jerome at hivnet.ubc.ca
Sat Aug 30 03:05:27 MEST 2003


The problem occurs when the sample odds ratio is Inf, such as in the 
following example. Given the fact that both upper bounds of the two 95% 
confidence intervals are Inf, I would have expected that the two lower 
bounds be equal, but they aren't.

x <- matrix(c(9,4,0,2),2,2)
x
#     [,1] [,2]
#[1,]    9    0
#[2,]    4    2
rbind("two.sided.95CI"=fisher.test(x)$conf.int,
"greater.95CI"=fisher.test(x,alt="greater")$conf.int)
#                    [,1] [,2]
#two.sided.95CI 0.2985103  Inf
#greater.95CI   0.4625314  Inf

Using the noncentral hypergeometric distribution, we can calculate the 
probability mass of each possible table with same marginals as x.
Ref.: Alan Agresti (1990). Categorical data analysis. New York: Wiley. 
Page 67.

Hence, the result below suggests that the two-sided confidence interval 
has a confidence level of 97.5% as opposed to 95%.

n11 <- 7:9
theta <- 0.2985103
choose(9,n11)*choose(15-9,13-n11)*theta^n11/
  sum(choose(9,n11)*choose(15-9,13-n11)*theta^n11)
#[1] 0.67344877 0.30154709 0.02500414

The 95% confidence interval with one-sided (greater) alternative appears 
to be correct.

theta <- 0.4625314
choose(9,n11)*choose(15-9,13-n11)*theta^n11/
  sum(choose(9,n11)*choose(15-9,13-n11)*theta^n11)
#[1] 0.5608724 0.3891316 0.0499960

Sincerely,
Jerome Asselin

-- 

Jerome Asselin (Jérôme), Statistical Analyst
British Columbia Centre for Excellence in HIV/AIDS
St. Paul's Hospital, 608 - 1081 Burrard Street
Vancouver, British Columbia, CANADA V6Z 1Y6
Email: jerome at hivnet.ubc.ca
Phone: 604 806-9112   Fax: 604 806-9044



More information about the R-devel mailing list