Commit 7e8e264
Address PR #347 R1: fix StackedDiD wording, drop dead TWFE branch, fix dCDH headline_attribute
R1 surfaced three P1s, all legitimate:
1. StackedDiD wording mismatch. Claimed ``overall_att`` is a
treated-share-weighted aggregate across sub-experiments; actual
implementation (``stacked_did.py`` ~line 541) computes
``overall_att`` as the simple average of post-treatment event-
study coefficients ``delta_h`` with delta-method SE. Per-horizon
``delta_h`` is the paper's ``theta_kappa^e`` cross-event
aggregate, but the headline is an equally-weighted average over
those per-horizon coefficients, not a separate cross-event
weighting at the ATT level. Definition rewritten to describe the
actual estimand.
2. Dead ``TwoWayFixedEffectsResults`` branch. ``TwoWayFixedEffects``
is a subclass of ``DifferenceInDifferences`` and its ``fit()``
returns ``DiDResults`` — there is no separate TWFE result class,
so the ``type(results).__name__ == "TwoWayFixedEffectsResults"``
dispatch branch was unreachable on any real fit. Removed the
dead branch and rewrote the ``DiDResults`` branch to cover both
2x2 DiD and TWFE interpretations explicitly (both estimators
route here). Follow-up for future PR: persist estimator
provenance on ``DiDResults`` (or return a dedicated TWFE result
class) so the branch can split again; documented inline.
3. dCDH ``headline_attribute="att"``. Both dCDH branches (``DID_M``
for ``L_max=None``, ``DID_l``/derivatives for ``L_max >= 1``)
named ``"att"`` as the headline attribute, but
``ChaisemartinDHaultfoeuilleResults`` stores the headline in
``overall_att`` (``chaisemartin_dhaultfoeuille_results.py:357``).
Fixed both branches to ``"overall_att"``; downstream consumers
using the machine-readable contract now point at the correct
attribute.
Tests: new ``TestTargetParameterRealFitIntegration`` covers the
gap R1 P2 flagged — prior coverage was stub-based and would not
have caught any of the three P1s. Four new real-fit tests:
- ``TwoWayFixedEffects().fit(...)`` returns ``DiDResults``; target-
parameter block uses the shared DiD/TWFE branch.
- ``StackedDiD(...).fit(...)`` on a staggered panel; the
``headline_attribute`` matches the actual real attribute and the
definition names the event-study-coefficient estimand.
- ``ChaisemartinDHaultfoeuille().fit(...)`` on a reversible-
treatment panel (both ``DID_M`` and ``DID_l`` regimes);
``headline_attribute == "overall_att"`` and the named attribute
actually exists on the real fit object.
Existing stub-based dispatch tests updated: the ``test_twfe_results``
test is now ``test_did_results_mentions_twfe`` (asserts the DiD
branch describes both estimators). The dCDH stub tests now also
assert ``headline_attribute == "overall_att"``.
All 323 BR/DR tests pass (319 prior + 4 new real-fit integration).
Out of scope (plan-review MEDIUM #2 — centralizing report metadata
in a single registry shared by estimator outputs and reporting
helpers): queued as a separate PR. Current approach (string dispatch
on ``type(results).__name__`` + REGISTRY.md references) is working
but brittle; a centralized registry is the principled fix for the
TWFE-dispatch-dead-code class of bug.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b1946fb commit 7e8e264
2 files changed
Lines changed: 184 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
73 | 83 | | |
74 | | - | |
| 84 | + | |
75 | 85 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
80 | 97 | | |
81 | 98 | | |
82 | 99 | | |
83 | | - | |
| 100 | + | |
84 | 101 | | |
85 | 102 | | |
86 | 103 | | |
| |||
97 | 114 | | |
98 | 115 | | |
99 | 116 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
197 | 198 | | |
198 | 199 | | |
199 | 200 | | |
200 | | - | |
| 201 | + | |
201 | 202 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
207 | 214 | | |
208 | 215 | | |
209 | 216 | | |
| |||
322 | 329 | | |
323 | 330 | | |
324 | 331 | | |
325 | | - | |
| 332 | + | |
326 | 333 | | |
327 | 334 | | |
328 | 335 | | |
| |||
362 | 369 | | |
363 | 370 | | |
364 | 371 | | |
365 | | - | |
| 372 | + | |
366 | 373 | | |
367 | 374 | | |
368 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
61 | 66 | | |
62 | 67 | | |
63 | 68 | | |
| |||
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
136 | 145 | | |
137 | 146 | | |
138 | 147 | | |
| |||
145 | 154 | | |
146 | 155 | | |
147 | 156 | | |
| 157 | + | |
148 | 158 | | |
149 | 159 | | |
150 | 160 | | |
| |||
344 | 354 | | |
345 | 355 | | |
346 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
0 commit comments