All problems
Stabilized IPW Estimate
Problem
Return the stabilized IPW ATE: (1/n) * (sum(t_i*y_i*p1/e_i) - sum((1-t_i)*y_i*p0/(1-e_i))), where p1 and p0 are the observed treated and control shares. Stabilized weights stay bounded when the arms are unbalanced. Return 0.0 for invalid input or when either arm has no units.
Hint
Multiply treated weights by p1 and control weights by p0.
Test cases
case 1
in: [[1,1,0,0],[10,12,4,6],[0.6,0.4,0.3,0.7]]
expected: 9.047619047619047
case 2
in: [[1,0],[5,1],[0.5,0.5]]
expected: 3
case 3
in: [[1,1],[2,4],[0.5,0.8]]
expected: 0
case 4
in: [[1,0],[5,1],[0.5,1]]
expected: 0
case 5
in: [[],[],[]]
expected: 0
Starter codePython
def stabilized_ipw_ate(treatment, outcome, propensity):
# Your code here
pass5 test cases · run your code against them in the editor