Phase 4: Survey support for ImputationDiD, TwoStageDiD, CallawaySantAnna#233
Phase 4: Survey support for ImputationDiD, TwoStageDiD, CallawaySantAnna#233
Conversation
…, CallawaySantAnna) - Weighted solve_logit(): survey weights enter IRLS as w_survey * mu*(1-mu) - ImputationDiD: weighted iterative FE, survey-weighted ATT aggregation, weighted conservative variance (Theorem 3), survey df for inference - TwoStageDiD: weighted iterative FE, weighted Stage 2 OLS, weighted GMM sandwich variance with survey weights in both stages - CallawaySantAnna: survey-weighted regression, IPW (via weighted solve_logit), and DR methods with explicit influence functions; survey-weighted WIF in aggregation; Cholesky cache bypassed under survey weights - Unblock TripleDifference IPW/DR with survey (weighted solve_logit now available) - 38 new tests in test_survey_phase4.py covering all estimators + scale invariance - Update survey-roadmap.md, REGISTRY.md with Phase 4 status and deviation notes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…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) <noreply@anthropic.com>
|
Overall Assessment ⛔ Blocker Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Path to Approval
|
…, CS SE formula - P0: Thread survey_weights through TripleDifference IPW and DR call chains (_ipw_estimation, _doubly_robust, _compute_did_rc_ipw, _compute_did_rc_dr). Survey weights now enter Riesz representers for weighted Hajek averages. - P1: Fix CallawaySantAnna no-covariate survey SE to derive from sum(IF^2) instead of sum(w_norm * (y-mean)^2). All 4 locations now consistent with stored influence functions. - P1: Update REGISTRY.md TripleDifference entry to reflect full survey support (was still marked as "IPW/DR deferred"). - P2: Add behavioral tests for TripleDiff IPW/DR survey: non-uniform weights change ATT, uniform weights match unweighted. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment This re-review clears two of the prior blockers: Executive Summary
Methodology The touched paths are all source-sensitive: Borusyak-Jaravel-Spiess place ImputationDiD uncertainty on the Theorem 3 conservative variance, Gardner/did2s treats two-stage inference as a generated-regressor/GMM problem, Callaway-Sant’Anna support OR/IPW/DR staggered DiD with covariates, and the current DDD source paper explicitly emphasizes covariate-adjusted RA/IPW/DR inference. (economics-static.uchicago.edu)
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Static-review note: I could not execute the test suite in this environment because Path to Approval
|
… always-treated survey - ImputationDiD: use survey-weighted untreated sums (not raw counts) in Theorem 3 v_it FE-only path, and weighted normal equations (A_0'W_0 A_0) in covariate path - TripleDifference: weight PS Hessian, score correction, and DR OLS linear representations with survey weights for covariate-adjusted IPW/DR IF corrections; update fit() docstring to reflect full survey support - TwoStageDiD: subset survey_weights and resolved_survey arrays after always-treated unit exclusion to prevent length mismatch - Add tests: TwoStageDiD always-treated + survey, DDD covariate IPW/DR + survey Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment The previous Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Path to Approval
Static-review note: I could not run the targeted tests in this environment because |
…riate nuisance IF - TripleDifference: remove double-weighting in IPW/DR moment corrections — since Riesz representers already incorporate survey weights, moment means use np.mean() not np.average(weights=). Removed _wmean_ax0 helper. - CallawaySantAnna WIF: apply s_i symmetrically to both indicator and pg terms in the weighted share estimator IF. Normalize by total_weight (sum of survey weights) instead of n_units. - CallawaySantAnna outcome regression covariate IF: add weighted regression nuisance IF correction (asymptotic linear representation of beta from WLS, projected onto weighted treated covariate mean). IPW and DR IFs unchanged (IPW matches unweighted structure; DR is self-correcting per Theorem 3.1). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment Unmitigated P1s remain in the new survey inference paths. The earlier ImputationDiD variance-weighting gap and the obvious TripleDifference survey double-weighting problem look resolved in this diff, but Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Review note: Path to Approval
|
…ge n_psu - CallawaySantAnna WIF: remove inner /total_weight from indicator_diff — the final psi_wif/total_weight handles normalization once, matching R's did::wif() - CallawaySantAnna IPW covariate: add propensity score nuisance IF correction (survey-weighted Hessian, score, M2 gradient) so per-cell and aggregated SEs account for PS estimation uncertainty - TwoStageDiD: recompute n_psu/n_strata after always-treated filtering via np.unique() on subsetted arrays, then recompute survey_metadata Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall Assessment This re-review leaves two unmitigated P1s in the new survey Executive Summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
Path to Approval
|
Summary
weightsparameter tosolve_logit()— survey weights enter IRLS asw_survey * mu*(1-mu), enabling survey-weighted propensity score estimationsolve_logit()), and DR methods with explicit influence functions; survey-weighted WIF in aggregation; Cholesky cache bypassed under survey weightssolve_logit()now available, removing Phase 3 deferral)did, not full TSL)n_clbug from PR EfficientDiD: cluster-robust SEs, last-cohort control, Hausman pretest, small cohort warning #230 in TODO.mdMethodology references (required if estimator / math changes)
did::att_gt()analytical pathsvyglm(family=binomial)— working weights = survey_w × mu × (1−mu)Validation
tests/test_survey_phase4.py(41 tests),tests/test_survey_phase3.py(2 tests updated)Security / privacy
Generated with Claude Code
🤖 Generated with Claude Code