I'm wondering how odds ratio is computed. I thought that it is
(n11/n12)/(n21/n22), but it is not what fisher.test() computes. Could
somebody let me know?

> n11=3
> n12=1
> n21=1
> n22=3
>
> n1_=n11+n12
> n2_=n21+n22
>
> n_1=n11+n21
> n_2=n12+n22
>
> x=rbind(c(n11,n12),c(n21,n22))
>
> threshold=dhyper(n11,n1_,n2_,n_1)
> probability=dhyper(0:n_1,n1_,n2_,n_1)
> sum(probability[probability<=threshold])
[1] 0.4857143
> (n11/n12)/(n21/n22)
[1] 9
> fisher.test(x)

        Fisher's Exact Test for Count Data

data:  x
p-value = 0.4857
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
   0.2117329 621.9337505
sample estimates:
odds ratio
  6.408309

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to