Commit bd2f5e5
committed
feat(dml): DMLDiD survey-design and cluster support on both lanes (DML survey PR)
survey_design= (pweight full-design TSL: weights/strata/PSU/FPC) on
fit() and cluster= on the constructor, on the panel AND declared-RCS
lanes. Declared designs weight the moment kernels (Hajek p-hat /
lambda-hat / theta, weighted G_2lambda) and pass sample_weight into the
nuisance learners (user learner objects must accept it by keyword -
TypeError up front otherwise); cross-fitting switches to PSU-cohesive
folds when the PSU is strictly coarser than the sampling unit, with the
explicit Chang I_kz^c fold-composition guard on the RCS lane, an
effective-fold-count reduction to n_psu (warned, provenance on
DMLDiDResults.effective_n_folds / summary / to_dict / repr) when
2 <= n_psu < n_folds, and a stratified-fold fallback only for the
single-PSU design (whose clustered variance is NaN either way).
Per-cell SEs are PSU-gated exactly like CallawaySantAnna
(_cluster_robust_se_from_per_gt_if; NaN propagates as the deliberate
unidentified-variance signal on a RETAINED cell); analytical inference
uses df = n_PSU - n_strata t-statistics; the survey multiplier
bootstrap and <2-PSU NaN contracts activate through the inherited CS
machinery, and aggregation kits now carry the producer's bootstrap
label so post-fit replays brand warnings with the fitting estimator
(the _BOOTSTRAP_LABEL ClassVar becomes a plain annotation across its
five hosts). Bare cluster= keeps the kernels unweighted - it drives
folds, variance, and df_inference only. zero_weight_mass joins the
DMLDiD skip vocabulary; universal-base reference cells gate on the
weighted cohort mass; aggregate('total') fails closed on
declared-survey fits (is_survey_fit kit gate).
A documented LIBRARY EXTENSION of Chang (2020)'s i.i.d. theory
(REGISTRY DMLDiD survey Notes; Theorem 2's coverage claim does not
carry over on the weighted-lambda RCS lane). Replicate-weight designs
fail closed (TODO.md Actionable row). No v4 ledger row: additive
kwargs, no behavior change on existing calls (precedent check
recorded). Downstream consumer surfaces synced: reporting helpers'
target-parameter description, MMM scale hint, practitioner
learner-sensitivity template, BusinessReport narratives,
DiagnosticReport design_effect roster comment, variance-conventions
inventory (CI-pinned doc/test pair), survey-theory rosters, guides
(llms/full/autonomous/practitioner incl. the signature-parity blocks),
choosing_estimator + practitioner_decision_tree + survey-roadmap +
migration-4.0 + v4-design prose, api/dml_did.rst, doc-deps.yaml
mappings.
Tests: new tests/test_survey_dml.py (62 tests - invariant battery,
per-cell SE == compute_survey_if_variance cross-checks, cluster-wiring
branches, fold cohesion/reduction/boundary pins, spy-learner
weight-threading, zero_weight_mass skips, survey bootstrap + replay
label + legacy-kit fallback, rejections, df threading/rendering,
aggregation masses incl. the >2^53 cohort-key regression);
weighted-slope tests in test_dr_scores.py (uniform == unweighted,
finite-difference identity, validation rejections on the public AND
internal entries); guide signature pins extended; existing DMLDiD/CS
suites pass unchanged (no-survey fits bit-identical).1 parent b58abde commit bd2f5e5
38 files changed
Lines changed: 1935 additions & 210 deletions
File tree
- diff_diff
- guides
- docs
- api
- methodology
- papers
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
11 | 30 | | |
12 | 31 | | |
13 | 32 | | |
| |||
28 | 47 | | |
29 | 48 | | |
30 | 49 | | |
31 | | - | |
32 | | - | |
| 50 | + | |
33 | 51 | | |
34 | 52 | | |
35 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
0 commit comments