This Analytics & Experimentation question evaluates basic causal-inference and data-manipulation skills by requiring computation of a difference-in-differences (DID) estimate and a binary pretrend flag from panel-like arrays, at an implementation-level focused on summary statistics and edge-case handling.
You are given three equal-length arrays describing observations from a panel-like dataset:
period[i]
∈ {0,1}: 0 = pre period, 1 = post period
treat[i]
∈ {0,1}: 1 = treated group, 0 = control group
y[i]
(float): outcome
Tasks:
A) Compute the difference-in-differences (DID) estimate of the treatment effect:
B) Compute a simple pretrend flag:
threshold
≥ 0, return
pretrend=True
if
, else
False
.
Assumptions/requirements:
period
,
treat
).