Commit 6125fda
Address PR #359 CI review round 1 (1 P0 + 2 P1 + 2 P2/P3)
P0 — bias-corrected survey IF: the survey variance path was building
the influence function from classical residuals (``res_h`` + ``R_p·W_h``,
aligned with ``V_Y_cl``) while the returned ATT uses the bias-corrected
``tau_bc``. Under compute_survey_if_variance this silently
under-estimated the survey SE by ignoring the CCT-2014 bias-correction
variance inflation. Fixed in ``_nprobust_port.lprobust``: IF now uses
``Q_q`` + ``res_b`` so ``sum(IF^2) == V_Y_bc[0,0]`` (verified in new
white-box test), matching the estimator scale of the ATT. Uniform-
weights bit-parity (weights=np.ones ≡ unweighted at 1e-14) preserved
across the new IF formula. The ``TestWeightedLprobust`` HC1 bit-parity
test still passes because under weights=ones the classical vs bias-
corrected IF only differ by the Q.q bias-correction term, which is
deterministic and cancels in the diff.
P1a — df_survey threading: survey fits previously used Normal-theory
inference regardless of PSU count. ``resolved_survey_unit.df_survey``
(n_psu − n_strata, or replicate QR rank − 1) now routes through
``safe_inference(..., df=...)`` on the survey path, producing t-based
p-values and CIs. Also surfaced in ``survey_metadata["df_survey"]`` for
introspection. Under small-PSU designs the t-critical exceeds the
Normal z-critical, widening the CI vs the prior (wrong) output. The
``weights=`` shortcut continues to use Normal inference since there's
no PSU structure to produce a finite df.
P1b — reject non-pweight SurveyDesigns: HAD's weighted kernel composition
``W_combined = k((D-d̲)/h) · w`` implements inverse-probability weighting
semantics. ``SurveyDesign(weight_type="aweight"|"fweight")`` is now
rejected with ``NotImplementedError`` at fit-time — aweight (analytic)
implies a different inferential target (weighted regression, not
design-based inference), and fweight (frequency) implies observation
replication. Neither has been derived for HAD's continuous-dose path;
deferred as a follow-up.
P2 — test coverage: six new ``TestHADSurvey`` tests locking in the
three fixes above:
- ``test_survey_if_uses_bias_corrected_scale``: white-box
``sum(IF^2) == V_Y_bc[0,0]`` under nonlinear DGP where
V_Y_bc ≠ V_Y_cl (teeth).
- ``test_survey_df_widens_ci_vs_normal`` +
``test_survey_df_threaded_into_inference_via_t_distribution``:
assert df_survey surfaces in metadata and produces t-CI half-width
matching ``t_crit(df) · se`` exactly.
- ``test_survey_aweight_raises_not_implemented`` +
``test_survey_fweight_raises_not_implemented``: front-door rejection.
- ``test_survey_no_psu_no_strata_se_matches_weights_hc1``: SRS
equivalence — survey SE within 10-15% of weights-shortcut SE (the
(n/(n-1))-style HC1 correction), ruling out a silent
V_Y_cl-vs-V_Y_bc mismatch.
P3 — docstring refresh: the stale fit() docstring calling survey/weights
"Reserved for a follow-up PR" is replaced with the actual Phase 4.5 A
contract (pweight-only, constant-within-unit, replicate-weight deferred,
mass-point/event-study/pretests deferred). ``survey_metadata`` docstring
on ``HeterogeneousAdoptionDiDResults`` now enumerates the actual dict
keys and their semantics.
All 348 tests (across test_had, test_nprobust_port,
test_bias_corrected_lprobust, test_np_npreg_weighted_parity, and the
slow MC suite) pass after the cascade. Ruff clean on modified files.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent edf760e commit 6125fda
3 files changed
Lines changed: 286 additions & 29 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1005 | 1005 | | |
1006 | 1006 | | |
1007 | 1007 | | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
1012 | 1013 | | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
1017 | 1021 | | |
1018 | 1022 | | |
1019 | 1023 | | |
| |||
1352 | 1356 | | |
1353 | 1357 | | |
1354 | 1358 | | |
1355 | | - | |
| 1359 | + | |
1356 | 1360 | | |
1357 | | - | |
1358 | | - | |
1359 | | - | |
1360 | | - | |
1361 | | - | |
1362 | | - | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
1363 | 1376 | | |
1364 | 1377 | | |
1365 | | - | |
1366 | | - | |
1367 | | - | |
1368 | | - | |
1369 | | - | |
1370 | | - | |
1371 | | - | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
1372 | 1383 | | |
1373 | 1384 | | |
1374 | 1385 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
281 | | - | |
282 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
283 | 289 | | |
284 | 290 | | |
285 | 291 | | |
| |||
2262 | 2268 | | |
2263 | 2269 | | |
2264 | 2270 | | |
2265 | | - | |
2266 | | - | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
2267 | 2285 | | |
2268 | | - | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
2269 | 2293 | | |
2270 | 2294 | | |
2271 | 2295 | | |
| |||
2363 | 2387 | | |
2364 | 2388 | | |
2365 | 2389 | | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
2366 | 2409 | | |
2367 | 2410 | | |
2368 | 2411 | | |
| |||
2665 | 2708 | | |
2666 | 2709 | | |
2667 | 2710 | | |
2668 | | - | |
| 2711 | + | |
| 2712 | + | |
| 2713 | + | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
| 2721 | + | |
2669 | 2722 | | |
2670 | 2723 | | |
2671 | 2724 | | |
| |||
2681 | 2734 | | |
2682 | 2735 | | |
2683 | 2736 | | |
| 2737 | + | |
2684 | 2738 | | |
2685 | 2739 | | |
2686 | 2740 | | |
2687 | 2741 | | |
2688 | 2742 | | |
2689 | 2743 | | |
| 2744 | + | |
2690 | 2745 | | |
2691 | 2746 | | |
2692 | 2747 | | |
| |||
2696 | 2751 | | |
2697 | 2752 | | |
2698 | 2753 | | |
| 2754 | + | |
2699 | 2755 | | |
2700 | 2756 | | |
2701 | 2757 | | |
| |||
0 commit comments