Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
SIZE = 2000
assignment = np.random.binomial(1,0.5, size=SIZE)
pre_experiment = assignment + np.random.normal(-1, size=SIZE)
start = assignment + np.random.normal(1, size=SIZE)
end = start + np.random.normal(2.*assignment) + np.random.normal(2, size=SIZE)
self.X_pre = pd.DataFrame({'Start' : pre_experiment, 'End' : start, 'assignment' : assignment})
self.X = pd.DataFrame({'Start' : start, 'End' : end, 'assignment' : assignment})
self.did = DifferenceInDifferences()
def test_did_estimator(self):
lower, exp, upper = self.did.average_treatment_effect(self.X)
assert 1.8 <= exp <= 2.2
assert lower <= exp <= upper
self.did = DifferenceInDifferences(robust=True)
lower, exp, upper = self.did.average_treatment_effect(self.X)
assert 1.8 <= exp <= 2.2
assert lower <= exp <= upper