From nhorton at smith.edu  Wed Jan 27 18:30:10 2010
From: nhorton at smith.edu (nhorton at smith.edu)
Date: Wed, 27 Jan 2010 18:30:10 +0100 (CET)
Subject: [Rd] Possible bug in fisher.test() (PR#14196)
Message-ID: <20100127173010.77EEA282EF55@mail.pubhealth.ku.dk>

# is there a bug in the calculation of the odds ratio in fisher.test?
# Nicholas Horton, nhorton at smith.edu Fri Jan 22 08:29:07 EST 2010

x1 = c(rep(0, 244), rep(1, 209))
x2 = c(rep(0, 177), rep(1, 67), rep(0, 169), rep(1, 40))

or1 = sum(x1==1&x2==1)*sum(x1==0&x2==0)/
     (sum(x1==1&x2==0)*sum(x1==0&x2==1))

library(epitools)
or2 = oddsratio.wald(x1, x2)$measure[2,1]

or3 = fisher.test(x1, x2)$estimate

# or1=or2 = 0.625276, but or3=0.6259267!


I'm running R 2.10.1 under Mac OS X 10.6.2.

Nick

Nicholas Horton 
Department of Mathematics and Statistics, Smith College
Clark Science Center, Northampton, MA 01063-0001
http://www.math.smith.edu/~nhorton



[Rd] Possible bug in fisher.test() (PR#14196)
nhorton at smith.edu