ImputationDiD: thread vcov_type as narrow {hc1} contract per BJS Theorem 3 (Phase 1b interstitial #3)#492
Conversation
|
Overall Assessment Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Highest unmitigated severity is P2. Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Highest unmitigated severity is P3. Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
b295273 to
1249ded
Compare
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment✅ Looks good Highest unmitigated severity is P3. I did not find an unmitigated P0 or P1 in the changed Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
… 3 (Phase 1b interstitial #3) Phase 1b interstitial #3 for ImputationDiD. Mirrors the CallawaySantAnna (PR #487) + TripleDifference (PR #488) template for IF-based estimators: vcov_type is permanently narrow to {"hc1"} because the per-unit influence function aggregation (Borusyak-Jaravel-Spiess 2024 Theorem 3) has no single design matrix on which hat-matrix leverage or Bell-McCaffrey Satterthwaite DOF can be defined. Source surface (diff_diff/): - imputation.py: vcov_type param + @staticmethod _validate_vcov_type + fit()-time revalidation + cluster+replicate-weights NotImplementedError guard + Results metadata resolution (cluster_name=unit by default for the Theorem 3 unit-clustered IF variance; suppressed under ANY survey design — analytical OR replicate — because replicate variance ignores cluster/PSU entirely) - imputation_results.py: vcov_type/cluster_name/n_clusters fields, new to_dict() method, summary() variance line via shared _format_vcov_label (default cluster=None renders "CR1 cluster-robust at <unit>, G=<n>"; bootstrap fits suppress the analytical label and render "Inference method: bootstrap" instead, mirroring DiDResults.summary() gate at results.py:213-226) - imputation_bootstrap.py: dual-site n_clusters<2 / n_psu<2 NaN guards via new _build_nan_bootstrap_results helper (closes the BLAS-roundoff zero-SE class predicted to recur on IF-based estimators) Tests: 42 new tests in TestImputationDiDVcovType covering default / cluster / TSL-survey / replicate-survey + bootstrap × cluster + bootstrap × survey bit-equality (ALL parametrized over aggregate ∈ {None, "event_study", "group"} with per-horizon and per-group SE override branches pinned); fit()-time revalidation after set_params bypass; bootstrap n_psu<2 / n_clusters<2 NaN propagation including coef_var NaN; pretrends=True × vcov_type='hc1' × cluster bit-equality; introspection (default attr, get_params, Results carries, to_dict, summary label default+cluster+bootstrap-suppressed, cluster_name suppression under both analytical AND replicate survey, fit-clone idempotence, convenience function); input rejection on classical/hc2/hc2_bm/conley/ unknown with distinct methodology-keyword pins; cluster+replicate rejection. Full pytest tests/test_imputation.py: 128 passed. Docs: - REGISTRY.md: IF-based taxonomy adds ImputationDiD to "Enforced today" tier; ImputationDiD section gains 4 new Notes (vcov_type contract, cluster+replicate fail-closed, bootstrap n<2 NaN, default unit-cluster CR1 rendering) - CHANGELOG.md: [Unreleased] entry - TODO.md: Phase 1b row narrowed to TwoStageDiD + EfficientDiD; ImputationDiD Conley follow-up row added - guides/llms-full.txt: vcov_type + pretrends signature drift fix + shared staggered-results section advertises new variance metadata fields and to_dict() Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1249ded to
098dc7c
Compare
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Highest unmitigated severity is P3. I did not find an unmitigated P0 or P1 in the changed Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
Summary
vcov_typethroughImputationDiDas a permanently narrow{"hc1"}contract per Borusyak-Jaravel-Spiess (2024) Theorem 3 (Phase 1b interstitial Add robust parallel trends testing with Wasserstein distance #3, mirrors CS callaway-santanna: fix cluster= silent no-op + narrow vcov_type contract #487 + TD Phase 1b interstitial #2: TripleDifference vcov_type narrow contract #488 template for IF-based estimators).cluster=Nonesummary()now renders unit-cluster CR1 label (was misleadingly generic HC1); bootstrap fits suppress the analytical variance-family label and render "Inference method: bootstrap" instead.n_clusters<2/n_psu<2NaN guard on the bootstrap path closes the BLAS-roundoff zero-SE failure mode predicted to recur on IF-based estimators;cluster=<col>+ replicate-weightSurveyDesignraisesNotImplementedErrormirroring the CS+TD fail-closed guard.Methodology references
ImputationDiD(Phase 1b interstitial Add robust parallel trends testing with Wasserstein distance #3 —vcov_typecontract narrowing + summary label correction + bootstrap NaN guard).vcov_type = {"hc1"}contract is library-architectural, not paper-prescribed. Analytical-sandwich families{classical, hc2, hc2_bm}andconleyspatial-HAC are rejected at__init__because the per-unit IF aggregation has no equivalent single design matrix on which hat-matrix leverage or Bell-McCaffrey Satterthwaite DOF can be defined. Documented indocs/methodology/REGISTRY.mdIF-vs-sandwich taxonomy + two new ImputationDiD**Note:**bullets.Validation
tests/test_imputation.py::TestImputationDiDVcovType(+41 new tests across 7 surfaces — default / cluster / TSL-survey / replicate-survey + bootstrap × cluster + bootstrap × survey bit-equality ALL parametrized overaggregate ∈ {None, "event_study", "group"}with per-horizon and per-group SE override branches pinned;fit()-time revalidation afterset_paramsbypass; bootstrap n_psu<2 / n_clusters<2 NaN propagation includingcoef_varNaN;pretrends=True×vcov_type='hc1'× cluster bit-equality; introspection on default attr /get_params/ Results carries /to_dict/ summary label default+cluster+bootstrap-suppressed / cluster_name suppression under survey / fit-clone idempotence / convenience function; input rejection on classical/hc2/hc2_bm/conley/unknown with distinct methodology-keyword pins;cluster + replicate_weightsrejection). Fullpytest tests/test_imputation.pysuite: 128 passed.Security / privacy
Generated with Claude Code