Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-289

Trimming Threshold Effect

Problem

Return how much the Horvitz-Thompson IPW ATE changes when propensities are clipped to [lower, upper]: the clipped estimate minus the raw estimate. Return 0.0 for invalid bounds or input, or when clipping forces a treated propensity to 0 or a control propensity to 1.

Hint

Clip the propensity, recompute the IPW estimate, then subtract.

Test cases

case 1
in: [[1,1,0,0],[10,12,4,6],[0.5,0.5,0.5,0.5],0.2,0.8]
expected: 0
case 2
in: [[1,1,0,0],[10,12,4,6],[0.1,0.9,0.1,0.9],0.2,0.8]
expected: -4.72222222222222
case 3
in: [[1,0],[5,1],[0.5,0.5],0,0]
expected: 0
case 4
in: [[],[],[],0.2,0.8]
expected: 0
case 5
in: [[1,0],[5,1],[0.5,0.5],0.6,0.4]
expected: 0
Starter codePython
def trimming_threshold_effect(treatment, outcome, propensity, lower, upper):
    # Your code here
    pass

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