oddsRatio
Computes the odds ratio with a Woolf logit confidence interval for a 2×2 contingency table.
The odds ratio measures the strength of association between two binary variables. A value of 1.0 means no association, values above 1.0 indicate a positive association (exposure increases the odds of the outcome), and values below 1.0 indicate a negative association. The Woolf confidence interval is constructed on the log scale and exponentiated back, which ensures the interval is always positive and handles skewed sampling distributions well.
For a table [[a, b], [c, d]], the odds ratio is (a * d) / (b * c). When any cell is zero, the point estimate follows IEEE 754 arithmetic (zero, infinity, or NaN) and the confidence interval is (NaN, NaN) because the Woolf method requires all cells to be positive.
Example:
val table = arrayOf(intArrayOf(10, 5), intArrayOf(3, 12))
val result = oddsRatio(table, confidenceLevel = 0.95)
result.estimate // 8.0
result.ci // (1.522, 42.042) Woolf 95% CIReturn
a RiskEstimate containing the odds ratio and its Woolf logit confidence interval.
Parameters
a 2×2 contingency table with non-negative integer counts.
the confidence level for the Woolf interval. Must be in (0, 1). Defaults to 0.95 (95%).
See also
for the ratio of proportions rather than odds.
for a hypothesis test that also reports an odds ratio.