All problems
Parallel Trends Check
Problem
Check the parallel trends assumption: compute the treated-minus-control difference in each pre period and return True when every difference is within tolerance of their mean.
Empty input returns True.
Hint
A stable pre-period gap supports the difference-in-differences design.
Test cases
case 1
in: [[10,12,14],[8,10,12],0.1]
expected: true
case 2
in: [[10,12,14],[8,10,11],0.5]
expected: false
case 3
in: [[],[],0.1]
expected: true
Starter codePython
def parallel_trends_check(treat_pre, control_pre, tolerance):
# Your code here
pass3 test cases · run your code against them in the editor