[R] how to calculate odd ratios with R?

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Mon Jul 6 15:01:34 CEST 2020


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



More information about the R-help mailing list