Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-272

IPW Variance

Problem

Compute the variance of the IPW average treatment effect estimator. For each unit form the influence term t*y/e - (1-t)*y/(1-e) with e clipped to [1e-6, 1 - 1e-6], then return the population variance of those terms divided by n.

Empty input returns 0.0.

Hint

The variance shrinks with n and grows when propensities are extreme.

Test cases

case 1
in: [[1,1,0,0],[1,0,1,0],[0.5,0.5,0.5,0.5]]
expected: 0.5
case 2
in: [[1,0],[2,1],[0.8,0.5]]
expected: 2.53125
case 3
in: [[1],[1],[1]]
expected: 0
case 4
in: [[],[],[]]
expected: 0
Starter codePython
def ipw_variance(treatment, outcome, propensity):
    # Your code here
    pass

4 test cases · run your code against them in the editor