Commit 1e25f30
R1 CI: fix duplicate period_X dummy names on MPD multi-absorb path
CI Codex review on PR #459 surfaced a P1 newly exposed by the auto-route:
when MPD(absorb=["unit","period"]) auto-routes to fixed_effects=["unit",
"period"], the existing fixed_effects= expansion loop adds `period_X`
dummies via `pd.get_dummies(prefix="period")` that collide on name with
the event-study period dummies MPD already builds for non-reference
periods. The duplicate `var_names` entries silently collapse in
`coef_dict = {name: coef for name, coef in zip(var_names, coefficients)}`,
overwriting the real event-study coefficients with the rank-deficient
NaN drops on the redundant FE block. Result: `len(coefficients) <
vcov.shape[0]` and `coefficients["period_X"] = NaN` even though
`period_effects[X]` (read by position) was correct.
Bug was pre-existing on MPD's `fixed_effects=[<time_col>]` path; the
auto-route just made it newly reachable via `absorb=`.
Fix: in MPD's fixed_effects expansion at estimators.py:1604, skip
entries where `fe == time` — MPD's design already absorbs the time
dimension via non-reference period dummies, so the FE-block dummies
would be perfectly redundant anyway (NaN'd by solve_ols, dropping
nothing useful while corrupting the result surface).
Empirical evidence:
- Pre-fix: `MPD(absorb=["unit","period"])` -> len(coefs)=34,
vcov.shape=(38,38), coefs["period_2"]=NaN.
- Post-fix: same call -> len(coefs)=34, vcov.shape=(34,34),
coefs["period_2"]=0.345 (finite, matches MPD's event-study fit).
Tests: new `test_absorb_hc2_result_surface_invariants_multi_absorb`
asserts `len(coefficients) == vcov.shape[0]`, no duplicate names, and
finite event-study `period_X` on BOTH the auto-route and the explicit
`fixed_effects=` paths (Codex P2: regression coverage for the result-
surface contract on the newly reachable path). 11/11 MPD tests pass;
249/249 in the broader sweep (test_estimators.py / test_linalg_hc2_bm.py
unchanged).
REGISTRY/CHANGELOG: documented the time-FE skip rule for both auto-route
and pre-existing `fixed_effects=[<time_col>]` invocations.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f25373a commit 1e25f30
4 files changed
Lines changed: 76 additions & 3 deletions
File tree
- diff_diff
- docs/methodology
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1600 | 1600 | | |
1601 | 1601 | | |
1602 | 1602 | | |
1603 | | - | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
1604 | 1615 | | |
1605 | 1616 | | |
| 1617 | + | |
| 1618 | + | |
1606 | 1619 | | |
1607 | 1620 | | |
1608 | 1621 | | |
| |||
0 commit comments