Commit c78b68f
fix(did): gardner_did event-study reference-category contamination
The Stage-2 dummy regression pooled all non-event rows (never-treated +
treated units outside the event-study horizon) into a single baseline
category, dragging every event-time coefficient toward the mean of that
pool. On a synthetic panel with true τ=2 and strict parallel trends,
this produced:
before: pre-trends ≈ -0.30 (should be 0), post ≈ +1.72 (should be 2.0)
after: pre-trends ≈ +0.01 (≈0), post ≈ +2.02 (≈2.0)
The fix replaces the Stage-2 dummy regression in event-study mode with a
direct Borusyak-Jaravel-Spiess-style within-(cohort × relative-time)
averaging of the imputed gap ỹ = Y - Ŷ(0). The non-event-study path
(single ATT) already used the correct regression and is unchanged.
Cluster-robust SEs in event-study mode now use the standard cluster
sum-of-residuals formula on each bin separately.
Also tightens test_gardner_event_study_support to require np.mean(post)
> 1.6 and |pre_trend| < 0.3 (previously 1.0 / 0.8).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 14056b6 commit c78b68f
2 files changed
Lines changed: 55 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
224 | 233 | | |
225 | 234 | | |
226 | 235 | | |
| |||
234 | 243 | | |
235 | 244 | | |
236 | 245 | | |
237 | | - | |
| 246 | + | |
238 | 247 | | |
239 | | - | |
240 | | - | |
241 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
242 | 279 | | |
243 | 280 | | |
244 | 281 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
259 | 291 | | |
260 | 292 | | |
261 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
0 commit comments