EfficientDiD: cluster-robust SEs, last-cohort control, Hausman pretest, small cohort warning#230
EfficientDiD: cluster-robust SEs, last-cohort control, Hausman pretest, small cohort warning#230
Conversation
|
Overall Assessment Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Path to Approval
|
… cluster validation Address all P1/P2 findings from PR #230 review: P1 fixes: - Fix clustered SE: sum(centered^2)/n^2 instead of mean(centered^2)/n - Fix control_group="last_cohort": always apply reclassification (not just when no never-treated exist) - Fix hausman_pretest n_units: derive from EIF vector length, not n_obs/n_periods (which breaks under last_cohort trimming) - Add cluster input validation: column existence, no NaN, per-unit constancy, n_clusters >= 2 P2 fixes: - Extract shared _validate_and_build_cluster_mapping() used by both fit() and hausman_pretest() - Add 6 new tests: manual Liang-Zeger, cluster validation (4 cases), Hausman+last_cohort, mixed-sample reclassification Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment Executive Summary
Static review only: I could not execute the test suite here because Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Path to Approval
|
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Path to Approval
|
…ohort warning Complete the EfficientDiD roadmap with four features: - Cluster-robust SEs: analytical Liang-Zeger from EIF + cluster-level bootstrap - Last-cohort-as-control: control_group="last_cohort" for all-treated datasets - Hausman pretest: classmethod with full covariance (Theorem A.1) for PT assumption selection - Small cohort warning: warn when cohort < 2 units or < 1% of sample Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Subset the cluster index vector with the row_finite mask before computing clustered covariance matrices in hausman_pretest(). Without this fix, np.bincount would receive mismatched array lengths when non-finite EIF rows are dropped. Add regression test for clustered Hausman pretest. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… covariance, update docstrings - Remove _cluster_indices, _n_clusters, _store_eif instance attributes; pass cluster info explicitly through aggregation methods and store_eif as a fit() parameter - Extract shared _cluster_aggregate() helper used by both _compute_se_from_eif (scalar SE) and hausman_pretest (covariance matrix) - Update class docstring to document cluster, control_group parameters Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… cluster validation Address all P1/P2 findings from PR #230 review: P1 fixes: - Fix clustered SE: sum(centered^2)/n^2 instead of mean(centered^2)/n - Fix control_group="last_cohort": always apply reclassification (not just when no never-treated exist) - Fix hausman_pretest n_units: derive from EIF vector length, not n_obs/n_periods (which breaks under last_cohort trimming) - Add cluster input validation: column existence, no NaN, per-unit constancy, n_clusters >= 2 P2 fixes: - Extract shared _validate_and_build_cluster_mapping() used by both fit() and hausman_pretest() - Add 6 new tests: manual Liang-Zeger, cluster validation (4 cases), Hausman+last_cohort, mixed-sample reclassification Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… n_obs Address rerun review findings: - Guard against empty treatment_groups before max() in last_cohort branch - Fix n_obs to report effective sample size (n_units * n_periods) after trimming - Add last_cohort tests for aggregate=event_study/all and bootstrap - Add all-never-treated + last_cohort regression test - Update influence_functions docstring to match dict contract Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Address rerun review findings: - Filter common (g,t) cells with non-finite effect estimates before building Hausman delta/covariance (prevents NaN poisoning from no-valid-pairs cells) - Make _nan_result return recommendation="inconclusive" for consistency (reject=False + "pt_post" was misleading) - Add clustered SE tests for aggregate=event_study and aggregate=all (exercises cluster path through aggregation methods) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment Executive Summary
Methodology
Code Quality No findings. Performance No findings. Maintainability No findings. Tech Debt No new untracked findings. Security No findings. Documentation/Tests
Static review only; I could not run the suite because Path to Approval
|
Address rerun-3 review findings: P1 fixes: - Hausman pretest now aggregates to post-treatment event-study ES(e) before computing test statistic, matching Theorem A.1 (was using raw (g,t) cells including pre-treatment placebos) - Raise NotImplementedError when both cluster and survey_design are set (cluster was silently ignored under survey TSL dispatch) - Add clustered bootstrap+aggregate='all' test covering bootstrap-updated event-study and group effect SEs P2: Update REGISTRY.md Hausman note to describe ES(e) aggregation. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment Executive Summary
Methodology
Code Quality No findings. Performance No findings. Maintainability No findings. Tech Debt No new untracked findings. Security No findings. Documentation/Tests
Path to Approval
Static review only: I could not run the targeted suite here because |
P1: hausman_pretest ES(e) EIF now includes the weight influence function correction matching _aggregate_event_study's WIF pattern. Without this, the Hausman covariance was underestimated when multiple cohorts load into the same post-treatment horizon. P3 doc fixes: - Document store_eif parameter in fit() docstring - Document "inconclusive" return state in HausmanPretestResult - Fix REGISTRY.md last-cohort wording to say "from treatment onset onward" instead of "last time period" Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment ✅ Looks good Executive Summary
Methodology
Code Quality No findings. Performance No findings. Maintainability No findings. Tech Debt No new untracked findings. Security No findings. Documentation/Tests
|
…e-existing Hausman bug, add inference tests - Add REGISTRY.md deviation note: CS per-cell ATT(g,t) SEs use influence-function variance (matching R's did), not full TSL with strata/PSU/FPC - Add TODO entries: CS per-cell TSL SE (Medium), Hausman stale n_cl from #230 (Medium) - Add 3 CS survey inference validation tests (scale invariance, per-cell ATT change, survey df effect) - Remove unused survey_weight_type in ImputationDiD Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…e-existing Hausman bug, add inference tests - Add REGISTRY.md deviation note: CS per-cell ATT(g,t) SEs use influence-function variance (matching R's did), not full TSL with strata/PSU/FPC - Add TODO entries: CS per-cell TSL SE (Medium), Hausman stale n_cl from #230 (Medium) - Add 3 CS survey inference validation tests (scale invariance, per-cell ATT change, survey df effect) - Remove unused survey_weight_type in ImputationDiD Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The clustered SE formula fix shipped in PR #230 (v2.7.4). The remaining stale-indices issue is still tracked in TODO.md and not fixed in this release. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Summary
control_group="last_cohort"fallback for datasets with no never-treated unitshausman_pretest()classmethod for PT-All vs PT-Post assumption selection (Theorem A.1, full covariance)_cluster_aggregate()/_compute_se_from_eif()helpers; pass cluster info explicitly (no mutable instance state)Methodology references (required if estimator / math changes)
Validation
tests/test_efficient_did.py(+355 lines, 21 new tests across TestHausmanPretest, TestClusterRobustSE, TestLastCohortControl, TestSmallCohortWarning)tests/test_efficient_did_validation.py(HRS replication still passes)Security / privacy
Generated with Claude Code