Econometrics & Causal Inference
Difference-in-Differences (DiD) Causal Estimator and Pre-Trend Check
Calculate the canonical 2x2 Difference-in-Differences ATT = (Y_T,post - Y_T,pre) - (Y_C,post - Y_C,pre), counterfactual level, and pre-intervention placebo trend test.
Subtract both baseline selection differences and shared macro shocks
Naive post-launch comparisons (Y_T,post - Y_C,post) confound causal impact with permanent baseline differences between treated and control regions, whereas naive before-vs-after comparisons (Y_T,post - Y_T,pre) confound causal impact with seasonal or macro trends! Difference-in-Differences (Card & Krueger, 1994) subtracts the control group’s time trend from the treated group’s time change: ATT_DiD = (Y_T,post - Y_T,pre) - (Y_C,post - Y_C,pre), valid whenever treated and control units would have evolved along parallel trends absent treatment.
Verify with three periods (Lead t=-2 in col B, Pre-baseline t=-1 in col C, Post-launch t=0 in col D) for Treated Stores (row 2: 110, 120, 148) vs Control Stores (row 3: 85, 95, 107). First audit the pre-intervention placebo DiD from t=-2 to t=-1: Treated grew +10 (120 - 110) and Control grew +10 (95 - 85), so Placebo_PreTrend = 10 - 10 = 0.0000 (parallel pre-trends pass!). From t=-1 to t=0, Control grew +12 (107 - 95), implying Treated Counterfactual = 120 + 12 = 132, so causal ATT_DiD = 148 - 132 = +16.0000 (+12.12% lift over counterfactual)!
| Causal Comparison | Formula Expression | Sample Output |
|---|---|---|
| Naive Cross-Sectional Diff (Biased) | D2 - D3 (Post Treated - Post Control) | +41.00 (Inflated by +25 baseline gap!) |
| Naive Before-After Diff (Biased) | D2 - C2 (Post Treated - Pre Treated) | +28.00 (Inflated by +12 macro trend!) |
| Placebo Pre-Trend Check (t=-2 -> -1) | (C2 - B2) - (C3 - B3) | 0.00 (Parallel pre-trend verified) |
| Difference-in-Differences ATT_DiD | (D2 - C2) - (D3 - C3) = D2 - Counterfactual | +16.00 (Counterfactual = 132.00) |
Placebo Pre-Intervention Parallel-Trend Diagnostic Formula
Always run a placebo DiD on pre-treatment periods BEFORE reporting a post-launch treatment effect; if |Placebo_DiD| exceeds your domain tolerance tau_tol, flag a parallel-trends violation for peer review.
=ROUND((C2 - B2) - (C3 - B3), 4)Canonical 2x2 Difference-in-Differences ATT & Counterfactual Percentage Lift Formula
Compute counterfactual treated outcome Y_CF = C2 + (D3 - C3) and causal ATT = D2 - Y_CF. In a collaborative Arte Sheets workbook, invite a data-science reviewer as a suggester to stress-test pre-trend sensitivity: if lead treated revenue B2 was actually 102 instead of 110, pre-trend divergence jumps to +8.00, signaling preexisting momentum!
=IF(COUNT(B2:D3) < 6, "Missing Panel Cell", ROUND((D2 - C2) - (D3 - C3), 4))Try the example
Use the original values or change them to test your understanding.