A review (sorry in Japanese) on the calculation of odds ratios 
with confidence intervals using several packages in R is given
by Prof. Okumura, Mie Univ.

https://oku.edu.mie-u.ac.jp/~okumura/stat/2by2.html

x <- matrix(c(6, 3, 4, 5), 2)
# using vcd
library(vcd)
res <- oddsratio(x)
exp(confint(res))
summary(res)
# Note: summary(oddsratio(x, log=FALSE)) gives inappropriate p-value.
# using fmsb
library(fmsb)
oddsratio(x, p.calc.by.independence=FALSE)

Best,
Minato Nakazawa

On Mon, 6 Jul 2020 15:01:34 +0200
Luigi Marongiu <marongiu.lu...@gmail.com> wrote:

> Hello,
> Is it possible to calculate with a single function the odd ratios?
> Now I can use this implement:
> ```
> or <- (De/He)/(Dn/Hn) # Disease exposed, Healthy non-exposed
> logo <- log(or)
> x <- sqrt(((1/De) + (1/He) + (1/Dn) + (1/Hn)))
> lower_ci = exp(logo - 1.96*x)
> upper_ci = exp(logo + 1.96*x)
> cat("OR:", round(or, 3), "(", round(lower_ci, 3), "-", round(upper_ci, 3), 
> ")",
>     spe = "")
> ```
> for instance,
> ```
> De <-6
> Dn <-3
> He <-4
> Hn <-5
> or <- (De/He)/(Dn/Hn)
> logo <- log(or)
> x <- sqrt(((1/De) + (1/He) + (1/Dn) + (1/Hn)))
> lower_ci = exp(logo - 1.96*x)
> upper_ci = exp(logo + 1.96*x)
> cat("OR:", round(or, 3), "(", round(lower_ci, 3), "-", round(upper_ci, 3), 
> ")",
>     spe = "")
> > OR: 2.5 ( 0.37 - 16.889 )
> ```
> Is there a simple function from some package that can also add a
> p-value to this test? Or how can I calculate the p-value on my own?
> -- 
> Best regards,
> Luigi
> 
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
> 


-- 
Minato Nakazawa <minato-nakaz...@umin.net>
Professor, Division of Global Health, Department of Public Health,
Kobe University Graduate School of Health Sciences
[web] http://minato.sip21c.org/
[phone] +81-78-796-4551
[mobile e-mail] minatonakaz...@gmail.com

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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