You can actually also get results from fisher.test when one of the entries is 0. One of your confidence limits will just be either 0 or Inf. But that should hardly be a surprise.
You could also try the twoby2 command from the Epi package which will summarize your table analysis nicely. > m [,1] [,2] [1,] 360 0 [2,] 7 120 > fisher.test(m) Fisher's Exact Test for Count Data data: m p-value < 2.2e-16 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 1204.706 Inf sample estimates: odds ratio Inf > fisher.test(m[,2:1]) Fisher's Exact Test for Count Data data: m[, 2:1] p-value < 2.2e-16 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.0000000000 0.0008300781 sample estimates: > twoby2(m) 2 by 2 table analysis: ------------------------------------------------------ Outcome : Col 1 Comparing : Row 1 vs. Row 2 Col 1 Col 2 P(Col 1) 95% conf. interval Row 1 360 0 1.0000 NaN 1.0000 Row 2 7 120 0.0551 0.0265 0.1111 95% conf. interval Relative Risk: 18.1429 8.8303 37.2767 Sample Odds Ratio: Inf NaN Inf Conditional MLE Odds Ratio: Inf 1204.7059 Inf Probability difference: 0.9449 0.8896 0.9730 Exact P-value: 0 Asymptotic P-value: NaN ------------------------------------------------------ Best regards, Bendix _______________________________________________ Bendix Carstensen Senior Statistician Steno Diabetes Center Niels Steensens Vej 2-4 DK-2820 Gentofte Denmark +45 44 43 87 38 (direct) +45 30 75 87 38 (mobile) b...@steno.dk http://www.biostat.ku.dk/~bxc www.steno.dk > -----Original Message----- > From: r-sig-epi-boun...@stat.math.ethz.ch > [mailto:r-sig-epi-boun...@stat.math.ethz.ch] On Behalf Of C.H. > Sent: 5. marts 2010 12:49 > To: Pedro Emmanuel Alvarenga Americano do Brasil > Cc: r-sig-epi@stat.math.ethz.ch > Subject: Re: [R-sig-Epi] epitools::oddsratio error numbers > close to zero in cells? > > It is possible to calculate the OR with non-zero cells using > fisher.test > > > m<-matrix(c(360,7,4,120),byrow=F,nrow=2,ncol=2) > > fisher.test(m)$estimate > odds ratio > 1419.605 > > fisher.test(m)$conf.int > [1] 407.324 8192.000 > attr(,"conf.level") > [1] 0.95 > > For cases with zero cell, it is a problem. A typical work > round (by usual software such as Revman, Prism or SPSS) is to > add 0.5 to all cells to prevent the problem of division of > zero. I don't know if any packages implemented this. > > > > On Fri, Mar 5, 2010 at 9:02 AM, Pedro Emmanuel Alvarenga > Americano do Brasil <emmanuel.bra...@gmail.com> wrote: > > Hello all, > > > > I was runing some analysis here and found an error with > epitools::oddsratio. > > First I tought it was in my data, later I tought I was running the > > function incorrectly but I now realize that there is something with > > numbers close to zero or cells with zero... > > > > below the same error with a simulated data... but it > happens exactly > > the same with mine wich has one cell with 1. > > > >> m<-matrix(c(360,7,0,120),byrow=F,nrow=2,ncol=2) > >> m > > [,1] [,2] > > [1,] 360 0 > > [2,] 7 120 > >> oddsratio(m) > > Erro em uniroot(function(or) { : > > f() values at end points not of opposite sign > > > >> m<-matrix(c(360,7,4,120),byrow=F,nrow=2,ncol=2) > >> m > > [,1] [,2] > > [1,] 360 4 > > [2,] 7 120 > >> oddsratio(m) > > Erro em uniroot(function(or) { : > > f() values at end points not of opposite sign > > > >> m<-matrix(c(360,7,7,120),byrow=F,nrow=2,ncol=2) > >> m > > [,1] [,2] > > [1,] 360 7 > > [2,] 7 120 > >> oddsratio(m) > > $data > > Outcome > > Predictor Disease1 Disease2 Total > > Exposed1 360 7 367 > > Exposed2 7 120 127 > > Total 367 127 494 > > > > $measure > > odds ratio with 95% C.I. > > Predictor estimate lower upper > > Exposed1 1.0000 NA NA > > Exposed2 806.1128 300.7302 2560 > > > > $p.value > > two-sided > > Predictor midp.exact fisher.exact chi.square > > Exposed1 NA NA NA > > Exposed2 0 1.896808e-96 4.400778e-94 > > > > Is it impoossible to estimate OR confidence intervals with > tables with > > very low numbers? Any work around sugestions? > > > > Abraço forte e que a força esteja com você, > > > > Dr. Pedro Emmanuel A. A. do Brasil > > Instituto de Pesquisa Clínica Evandro Chagas Fundação > Oswaldo Cruz Rio > > de Janeiro - Brasil > > > > [[alternative HTML version deleted]] > > > > > > _______________________________________________ > > R-sig-Epi@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-sig-epi > > > > > > > > -- > CH Chan > Research Assistant - KWH > http://www.macgrass.com > > _______________________________________________ > R-sig-Epi@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-epi > _______________________________________________ R-sig-Epi@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-epi