All problems
Confounding Bias Magnitude
Problem
Return the bias from an omitted confounder: slope * covariate_gap, where slope = correlation * sd_outcome / sd_covariate is the outcome-on-confounder regression coefficient and covariate_gap is the treated-minus-control mean of the confounder. Return 0.0 when sd_covariate is zero.
Hint
Convert the correlation to a slope first.
Test cases
case 1
in: [0.5,2,4,1.5]
expected: 1.5
case 2
in: [0,2,4,3]
expected: 0
case 3
in: [-0.4,5,2,2.5]
expected: -0.4
case 4
in: [0.3,0,2,1]
expected: 0
Starter codePython
def confounding_bias(correlation, sd_covariate, sd_outcome, covariate_gap):
# Your code here
pass4 test cases · run your code against them in the editor