[R-sig-Epi] epitools::oddsratio error numbers close to zero in cells?

Philippe Glaziou glaziou at gmail.com
Fri Mar 5 13:53:48 CET 2010


On 5 March 2010 03:26, BXC (Bendix Carstensen) <bxc at steno.dk> wrote:
> 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



Another approach is to run a logistic regression model. Using the same
data as above:

> (dp <- data.frame (a=c(320,7,0,0), b=c(0,0,4,120), t=c(1,0,1,0)))
   a   b t
1 320   0 1
2   7   0 0
3   0   4 1
4   0 120 0

> fit <- glm(cbind(a,b) ~ t, binomial, dp)

The estimated odds ratio is here (OR=1371):

> exp(coef(fit))
(Intercept)           t
 5.833e-02   1.371e+03


And its confidence interval:

> exp(confint(fit))
Waiting for profiling to be done...
                2.5 %    97.5 %
(Intercept)   0.02466    0.1159
t           442.87000 5551.2516


With less unbalanced data, glm() gives results very close to those
from fisher.test()

> dp2
    a   b t
1 320   0 1
2 200   0 0
3   0 100 1
4   0 150 0

> fit2 <- glm(cbind(a,b) ~ t, binomial, dp2)

> exp(coef(fit2))
(Intercept)           t
      1.333       2.400

> exp(confint(fit2))
Waiting for profiling to be done...
            2.5 % 97.5 %
(Intercept) 1.080  1.650
t           1.766  3.274

> fisher.test(matrix(c(320,200,100,150),2))

        Fisher's Exact Test for Count Data

data:  matrix(c(320, 200, 100, 150), 2)
p-value = 2.294e-08
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 1.742 3.309
sample estimates:
odds ratio
     2.397



--Philippe
Senior Epidemiologist,
World Health Organization
Geneva, Switzerland



More information about the R-sig-Epi mailing list