4/36
Part 1 of 6 · No coin flipLearn and do

A worked example: two groups of cities over eight weeks

The treated cities sat 12 above the control cities before launch, and 16 above after

Four cities got a new policy in week 5, and four similar cities didn't. Each number is one group's average for one week, laid out like the practice data: one row per group per week.

def worked_example():
    week = np.tile(np.arange(1, 9), 2)
    treated = np.repeat([1.0, 0.0], 8)
    post = (week >= 5).astype(float)
    y = np.array([52.0, 54, 53, 56, 61, 64, 63, 66,
                  40, 42, 41, 44, 45, 48, 47, 50])
    return y, treated, post, week

y, treated, post, week = worked_example()
print("treated:", y[treated == 1])
print("control:", y[treated == 0])
print("gap:    ", y[treated == 1] - y[treated == 0])
Predict

Both groups wobble from week to week. What does the gap between them do before the policy?

Pick one to see what it prints.
Pick an answer above to see the rest