You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/11_imputation_did.ipynb
+4-25Lines changed: 4 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -69,29 +69,14 @@
69
69
{
70
70
"cell_type": "markdown",
71
71
"metadata": {},
72
-
"source": [
73
-
"## Event Study\n",
74
-
"\n",
75
-
"Event study aggregation estimates treatment effects at each relative time horizon, enabling visualization of dynamic treatment effects and pre-trend assessment."
76
-
]
72
+
"source": "## Event Study with Pre-Trend Diagnostics\n\nEvent study aggregation estimates treatment effects at each relative time horizon. Setting `pretrends=True` adds **pre-period coefficients** (negative horizons) to the event study, enabling a diagnostic check of the parallel trends assumption.\n\nUnder parallel trends, pre-period coefficients should cluster around zero — indicating no differential trends before treatment. The reference period (h = -1) is normalized to zero by construction."
" plot_event_study(results_es, title='Imputation DiD Event Study')\n",
92
-
"else:\n",
93
-
" print(\"Install matplotlib to see visualizations: pip install matplotlib\")"
94
-
]
79
+
"source": "# Fit with event study aggregation and pre-period coefficients\nest = ImputationDiD(pretrends=True)\nresults_es = est.fit(data, outcome='outcome', unit='unit', time='period',\n first_treat='first_treat', aggregate='event_study')\n\n# Plot event study — pre-period region is automatically shaded\nif HAS_MATPLOTLIB:\n plot_event_study(results_es, title='Imputation DiD Event Study (with Pre-Trends)')\nelse:\n print(\"Install matplotlib to see visualizations: pip install matplotlib\")"
95
80
},
96
81
{
97
82
"cell_type": "code",
@@ -106,13 +91,7 @@
106
91
{
107
92
"cell_type": "markdown",
108
93
"metadata": {},
109
-
"source": [
110
-
"## Pre-Trend Test\n",
111
-
"\n",
112
-
"The imputation estimator includes a built-in pre-trend test (Equation 9 in the paper). It tests whether pre-treatment leads are jointly zero using a Wald F-test on untreated observations only.\n",
113
-
"\n",
114
-
"A key advantage: the pre-trend test is **independent** of the treatment effect estimator (Proposition 9), avoiding the pre-testing problem identified by Roth (2022)."
115
-
]
94
+
"source": "## Formal Pre-Trend Test\n\nThe event study plot above gives a **visual** diagnostic — do pre-period coefficients look close to zero? For a **statistical** check, `pretrend_test()` runs a Wald F-test on whether all pre-treatment leads are jointly zero (Equation 9 in the paper). This complements the plot: the eye spots patterns, the F-test quantifies evidence consistent with parallel trends.\n\nNote: `pretrend_test()` does not require `pretrends=True` — it runs its own internal lead regression on untreated observations, independent of the treatment effect estimator (Proposition 9). This avoids the pre-testing problem identified by Roth (2022)."
0 commit comments