[Rd] Possible bug in fisher.test() (PR#14196)

From: <nhorton_at_smith.edu>
Date: Wed, 27 Jan 2010 18:30:10 +0100 (CET)


# 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



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 27 Jan 2010 - 17:36:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 27 Jan 2010 - 22:50:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive