All problems
Risk Difference Confidence Interval
Problem
Return the Wald confidence interval for the risk difference a/(a+b) - c/(c+d) with standard error sqrt(p1(1-p1)/n1 + p2(1-p2)/n2). Return [0.0, 0.0] when either group is empty.
Hint
The two groups are treated as independent samples.
Test cases
case 1
in: [20,80,10,90,1.96]
expected: [0.0020000000000000018,0.198]
case 2
in: [10,10,10,10,1.96]
expected: [-0.3099032106965012,0.3099032106965012]
case 3
in: [5,0,1,1,1.96]
expected: [-0.19296464556281656,1.1929646455628165]
case 4
in: [0,10,5,5,2]
expected: [-0.816227766016838,-0.18377223398316206]
case 5
in: [0,0,1,1,1.96]
expected: [0,0]
Starter codePython
def risk_difference_ci(a, b, c, d, z_crit):
# Your code here
pass5 test cases · run your code against them in the editor