Repository navigation
fix(survey): per-cell ATT(g,t) SEs honor replicate and PSU designs (CallawaySantAnna, staggered TripleDifference) - #890
Conversation
…allawaySantAnna, staggered TripleDifference) Per-cell SEs ignored the survey design in three lanes while the aggregate SEs on the same fit were design-based: CallawaySantAnna under replicate weights, and staggered TripleDifference under replicate weights and under SurveyDesign(psu=...). One dispatch helper (staggered._design_se_for_cell) now routes every CS-family per-cell producer: replicate designs use IF reweighting with a cell-local df min(df_survey, n_valid - 1) (survey.cap_replicate_df), PSU designs use CR1 on the cell IF. Degenerate cells and non-finite influence functions fail closed to NaN. Measured on one-cell panels (cell == overall ATT): CS + JK1 cell SE 0.156789 -> 0.342755; staggered DDD 0.217289 -> 0.325258 under both JK1 and psu=. Point estimates and aggregate results are unchanged.
Overall assessment: ✅ Looks goodNo unmitigated P0/P1 findings identified in the supplied diff. Runtime validation remains incomplete because this environment lacks NumPy and pytest. Executive summary
MethodologyP3 — Informational: documented survey extensions. The dispatch in Impact: These extensions differ from the original papers’ sampling frameworks, but are explicitly documented at Cross-checking used the registry, docstrings, survey-theory derivations, and the repository’s version-pinned Ortiz-Villavicencio–Sant’Anna paper review. External primary-paper retrieval was unavailable because network DNS failed. Code QualityNo actionable findings. New inference calls use the shared safe-inference functions. Non-finite IF guards precede replicate computation and PSU aggregation, avoiding NaN-skipping variance results ( PerformanceNo actionable findings. Additional per-cell design-variance computation is necessary for the corrected outputs; no demonstrated performance regression was identified. MaintainabilityNo actionable findings. The shared dispatch centralizes the survey contract across the changed producers, while the batch wrapper keeps inference grouped by cell df. Tech DebtNo new untracked debt identified. The unchanged aggregate replicate-df relays remain separate follow-up work in SecurityNo findings. The diff introduces no apparent secrets, external execution, or sensitive-data handling. Documentation/TestsNo actionable findings. The changelog fragment follows the repository convention, and the new tests cover variance agreement, JK1/CR1 equivalence, cell-local df, degeneracy, and unchanged lanes. All six changed Python files parsed successfully, and eight isolated |
Summary
CallawaySantAnnawithSurveyDesign(replicate_weights=...)TripleDifferencewithSurveyDesign(replicate_weights=...)TripleDifferencewithSurveyDesign(psu=...)staggered._design_se_for_cell, now carries the per-cell contract for every CS-family producer (the three CS survey-reachable producers, the unreachable-under-survey covariate-reg producer, and the staggered DDD engine): replicate designs use IF reweighting on the cell influence function with a cell-local dfmin(df_survey, n_valid - 1)(newsurvey.cap_replicate_df); a PSU uses CR1 on the PSU totals of the cell influence function; every other lane is unchanged.CallawaySantAnnaandDMLDiDPSU per-cell lane (the PSU variance routine sums per PSU with NaN-skipping and could otherwise report a finite SE).Measured before / after
One-cell panels, where the cell is the overall ATT and the two SEs must agree:
psu=For the CS case the cell p-value moves from 4.9e-06 to 0.016. On the multi-cohort test panels (strong cluster shocks by construction) cell SEs grow 1.75x to 2.15x for CS and 1.34x to 1.78x for staggered DDD.
Methodology references (required if estimator / math changes)
docs/methodology/REGISTRY.md, the CallawaySantAnna per-cell survey Note and the StaggeredTripleDifference survey Note.didandtriplediffhave no replicate-weight or (fortriplediff) survey support, so the design-based per-cell SE is a documented library extension. Weights-only / strata-only / FPC-only designs keep the IF sqrt-sum per cell (documented convention). A degenerate cell reports a NaN SE where the aggregate path clamps a zero or negative variance to 0.0 (documented asymmetry; inference is NaN either way). All recorded with REGISTRY Note labels.Validation
tests/test_per_cell_design_se.py(55 tests, both backends); a comment-only pointer update intests/test_survey_dml.py.compute_replicate_if_variance/compute_survey_if_varianceon the cell influence function rebuilt from the aggregation kit, per reachable producer.psu=design's per-cell SEs (rtol 1e-10), CS panel and RCS and staggered DDD including GMM-combined cells.n_valid - 1otherwise,survey_metadata.df_surveyuntouched, NaN inference on a rank-1 design.Follow-ups recorded in TODO.md
survey_design=is honored analytically, so what remains is wiring the barecluster=parameter onto that lane.Security / privacy
Changelog
changelog.d/20261122-per-cell-design-se.md)