[R] how to calculate odd ratios with R?

Michael Dewey ||@t@ @end|ng |rom dewey@myzen@co@uk
Mon Jul 6 15:21:00 CEST 2020


Dear Luigi

You could try the epitools package which gives a large number of ways of 
doing this. I would have thought that using Wald intervals for the log 
odds ration was not optimal with small frequencies.

Michael

On 06/07/2020 14:01, Luigi Marongiu 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?
> 

-- 
Michael
http://www.dewey.myzen.co.uk/home.html



More information about the R-help mailing list