Odds ratio for a 2x2 table [[a, b], [c, d]]
Examples
# Cohort: 20/100 exposed and 10/100 unexposed develop the outcome.
res <- odds_ratio(20, 80, 10, 90)
res # rich print: estimate + CI
#> $measure
#> [1] "Odds ratio"
#>
#> $estimate
#> [1] 2.25
#>
#> $ci_lower
#> [1] 0.9942949
#>
#> $ci_upper
#> [1] 5.091548
#>
#> $se
#> [1] 0.4166667
#>
#> $n
#> [1] 200
#>
#> $extra
#> $extra$log_or
#> [1] 0.8109302
#>
#>
#> attr(,"class")
#> [1] "morie_effect_size" "list"
res$estimate # (a*d)/(b*c) = 2.25
#> [1] 2.25
c(lower = res$ci_lower, upper = res$ci_upper)
#> lower upper
#> 0.9942949 5.0915478
# OR = 1 means no association; a CI excluding 1 is "significant".
odds_ratio(50, 50, 50, 50)$estimate # 1
#> [1] 1
# `confidence` widens/narrows the interval.
odds_ratio(20, 80, 10, 90, confidence = 0.99)$ci_upper
#> [1] 6.581038
