Commit d24ae25
Address PR igerber#378 R3 P1: precise parity condition + heterogeneous-F_g regression
Reviewer flagged that the parity condition documented for by_path +
controls (single-baseline switcher panel) might not be sufficient,
hypothesizing that R's per-path subset could exclude pre-switch
rows of other-path switchers and produce a different first-stage
residualization sample.
Verified the hypothesis is empirically falsified and analytically
incorrect by reading R/R/did_multiplegt_dyn.R lines 401-405 line-by-
line. R's per-path subset for path B includes:
- Rows where path_XX == B (path-B switchers, all rows)
- OR rows where yet_to_switch=1 AND baseline matches (pre-switch
rows of any group with matching baseline, regardless of path)
So R's per-path first-stage sample equals (pre-switch rows of all
switchers with matching baseline + all rows of never-switchers with
matching baseline) — bit-identical to our global first-stage sample
under single-baseline switcher panels, regardless of how F_g varies
across paths or within a path. Empirical confirmation: scenario 16
(`multi_path_reversible_by_path_controls`) has switcher F_g spanning
[0..6] across 4 distinct paths under D_{g,1}=0 and Python matches
R to rtol ~1e-11 across all (path, horizon) cells.
Strengthened the contract:
- Expanded the warning code comment to spell out R's per-path subset
construction (citing R source line numbers) and why single-baseline-
switcher is the precise parity condition (control-pool equivalence
via the OR clause), with the empirical scenario reference baked in
- Updated REGISTRY.md "Per-path covariate residualization (DID^X)"
paragraph to cite R lines 401-405 and clarify never-switcher
baselines do not affect parity
- New regression test
`test_single_baseline_heterogeneous_F_g_no_warning_and_matches_r`
uses the golden-value scenario (single-baseline, heterogeneous F_g
across paths) to assert: (a) no UserWarning fires, (b) per-path
point estimates are produced finite. The numeric R-parity is locked
separately in TestDCDHDynRParityByPathControls.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1e49dff commit d24ae25
3 files changed
Lines changed: 123 additions & 13 deletions
File tree
- diff_diff
- docs/methodology
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1490 | 1490 | | |
1491 | 1491 | | |
1492 | 1492 | | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
1496 | | - | |
1497 | | - | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
1505 | 1529 | | |
1506 | 1530 | | |
1507 | 1531 | | |
| |||
0 commit comments