All problems
Counterfactual Prediction
Problem
Return the predicted counterfactual outcome for a unit with treatment effect tau0 + tau1*x: subtract the effect from the observed outcome for treated units and add it for control units.
Hint
Flip each unit to the arm it was not observed in.
Test cases
case 1
in: [15,1,2,1,0.5]
expected: 13
case 2
in: [4,0,2,1,0.5]
expected: 6
case 3
in: [10,1,0,3,-1]
expected: 7
case 4
in: [5,0,-2,1,1]
expected: 4
Starter codePython
def counterfactual_prediction(observed, treatment, x, tau0, tau1):
# Your code here
pass4 test cases · run your code against them in the editor