All problems
Odds Ratio CI (Delta Method)
Problem
Return the delta-method confidence interval for the odds ratio ad/(bc): exp(ln(OR) +/- z*sqrt(1/a + 1/b + 1/c + 1/d)). Return [0.0, 0.0] when any cell is zero.
Hint
The log odds ratio has an easily computed standard error.
Test cases
case 1
in: [20,80,10,90,1.96]
expected: [0.994279971565182,5.091624235405931]
case 2
in: [10,10,10,10,1.96]
expected: [0.289496276817444,3.4542758580297694]
case 3
in: [5,0,1,1,1.96]
expected: [0,0]
case 4
in: [1,1,1,1,1.645]
expected: [0.03725384939621581,26.842863655898565]
case 5
in: [30,70,15,85,1.96]
expected: [1.210983724248975,4.870386831442554]
Starter codePython
import math
def odds_ratio_ci(a, b, c, d, z_crit):
# Your code here
pass5 test cases · run your code against them in the editor