You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes two P1 issues flagged by the CI reviewer on the initial submission
of PR #352.
P1 Methodology — `compute_time_weights_survey` was documented as solving
the WLS-style weighted λ objective
min Σ_u rw_u·(Σ_t λ_t·Y_u,pre[t] - Y_u,post_mean)² + ζ²·||λ||²
but row-scaled Y by sqrt(rw) and then handed the scaled matrix to
`_sc_weight_fw(intercept=True)`, whose column-centering uses an
UNWEIGHTED mean across controls. That is not the weighted objective
once rw varies, so non-uniform survey bootstrap draws were refitting λ
on the wrong objective and could bias the reported SE.
Fix: weighted-center `Y_time` BEFORE the sqrt(rw) row-scaling, using
`col_weighted_mean = (Y_time * rw).sum(0) / rw.sum()`, and pass
`intercept=False` to the kernel so no additional unweighted centering
happens on the scaled matrix. Both two-pass calls updated.
`compute_sdid_unit_weights_survey` is unchanged — its column-centering
is PER-UNIT (time means within each control column), which is
independent of rw.
P1 Code Quality — `SurveyDesign(weights=None, strata=..., psu=...)` is
a valid configuration (`SurveyDesign.resolve()` synthesizes ones when
weights is None), but `_extract_unit_survey_weights` indexed
`survey_design.weights` as if it were always a column name, so the
groupby would fail with a KeyError before the bootstrap branch could
run. Fix: `_extract_unit_survey_weights` now short-circuits to a vector
of ones of length `len(unit_order)` when `survey_design.weights is
None`, matching `SurveyDesign.resolve()`'s semantics.
Regression tests:
- `test_non_uniform_rw_beats_unweighted_centering_variant`
(test_weighted_fw.py): reproduces the pre-fix buggy variant (row-
scale Y by sqrt(rw), then call `_sc_weight_fw(intercept=True)`) and
asserts the fixed path's weighted SSR is strictly ≤ the buggy
variant's weighted SSR. If a future revert reintroduces
intercept=True after the row-scaling, this test fails.
- `test_bootstrap_full_design_without_explicit_weights`
(test_methodology_sdid.py): `SurveyDesign(strata=..., psu=...)` with
no explicit `weights` column now succeeds on the bootstrap path;
survey_metadata populated with n_strata / n_psu.
P3 Documentation:
- `SyntheticDiD.fit()` docstring (survey_design parameter + Raises
block): replace "bootstrap rejects all survey designs" language with
the PR #352 support-matrix truth-table (bootstrap ✓ for both pweight-
only and full design; placebo/jackknife ✓ pweight-only, ✗ full
design).
- `_placebo_variance_se` fallback-guidance messages (two sites): drop
the "strata/PSU/FPC not yet supported by any SDID variance method"
framing; recommend bootstrap for full-design survey fallback,
jackknife for pweight-only, adding controls as the universal
fallback.
- `docs/survey-roadmap.md` Current Limitations table: collapse the two
SDID bootstrap-rejection rows into a single row for placebo/
jackknife + full design (the bootstrap + full design row no longer
applies).
Verified: 75 targeted tests pass (test_weighted_fw + TestBootstrapSE +
TestScaleEquivariance + TestCoverageMCArtifact + test_survey_phase5).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/survey-roadmap.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -223,8 +223,7 @@ the limitation and suggested alternative.
223
223
224
224
| Estimator | Limitation | Alternative |
225
225
|-----------|-----------|-------------|
226
-
| SyntheticDiD | Strata/PSU/FPC (any variance method) | No SDID variance option in this release. Pweight-only works with `variance_method='placebo'` or `'jackknife'`. Strata/PSU/FPC + SDID requires composing Rao-Wu rescaled weights with paper-faithful Frank-Wolfe re-estimation; sketch in REGISTRY.md §SyntheticDiD. |
227
-
| SyntheticDiD |`variance_method='bootstrap'` + any survey design (including pweight-only) | Use `variance_method='placebo'` or `'jackknife'` for pweight-only surveys. Refit bootstrap composed with survey weights requires the same weighted-FW derivation noted above. |
226
+
| SyntheticDiD |`variance_method='placebo'` or `'jackknife'` + strata/PSU/FPC | Use `variance_method='bootstrap'` for full-design surveys (PR #352 weighted-FW + Rao-Wu composition). Placebo's control-index permutation and jackknife's LOO allocator need their own weighted derivations on top of the weighted-FW kernel; tracked in TODO.md as a follow-up. |
228
227
| SyntheticDiD | Replicate weights | Pre-existing limitation: no replicate-weight survey support on SDID. |
229
228
| TROP | Replicate weights | Use strata/PSU/FPC design with Rao-Wu rescaled bootstrap |
0 commit comments