All problems
Difference-in-Differences Estimate
Problem
Return the difference-in-differences estimate (treated_post - treated_pre) - (control_post - control_pre) from the four group-period means.
Hint
Difference the changes, not the levels.
Test cases
case 1
in: [10,14,5,7]
expected: 2
case 2
in: [10,10,5,5]
expected: 0
case 3
in: [10,8,5,8]
expected: -5
case 4
in: [0,1,1,0]
expected: 2
case 5
in: [100,105,90,92]
expected: 3
Starter codePython
def did_estimate(treated_pre, treated_post, control_pre, control_post):
# Your code here
pass5 test cases · run your code against them in the editor