Skip to content

Commit 41d7d45

Browse files
igerberclaude
andcommitted
Address PR #376 R7 P3 + proactive doc-drift sweep
R7 P3: HAD.fit()'s `survey_design` parameter docstring still scoped to "the two continuous-dose paths" even though Phase 4.5 B added mass-point support and Phase 4.5 B added event-study survey composition (both with test coverage in TestHADFitMassPointSurveyDesign and TestHADFitEventStudySurveyDesign). Widened the description to cover the full dispatch matrix: continuous × {overall, event_study} + mass_point × {overall, event_study}. Notes mass-point's vcov_type='hc1' requirement, event-study's cband=True simultaneous CI, and points readers to REGISTRY.md for the full matrix. Proactive sweep (per user request): also updated HeterogeneousAdoptionDiDEventStudyResults.variance_formula's class docstring to clarify that the "weights= shortcut" / "survey= path" labels refer to internal variance-source families (still accurate internally) — added explicit "including via the deprecated weights= alias" / "via survey_design= or the deprecated survey= alias" so the field-level help text agrees with the consolidation. Other surfaces audited (no drift found): did_had_pretest_workflow, joint_pretrends_test, joint_homogeneity_test, qug_test, stute_test, yatchew_hr_test, stute_joint_pretest survey_design= docstrings; all already align with the canonical kwarg + 3-way mutex contract. Internal back-end comments using "weights= shortcut" / "survey= path" describe the (unchanged) routing mechanism; left as-is. 551 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 83329a2 commit 41d7d45

1 file changed

Lines changed: 29 additions & 16 deletions

File tree

diff_diff/had.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,13 @@ class HeterogeneousAdoptionDiDEventStudyResults:
701701
# fits stay unchanged; all None on unweighted fits).
702702
variance_formula: Optional[str] = None
703703
"""Per-horizon variance family label (applied uniformly across all
704-
horizons in the fit). One of ``"pweight"`` / ``"pweight_2sls"``
705-
(weights= shortcut; continuous / mass-point), ``"survey_binder_tsl"``
706-
/ ``"survey_binder_tsl_2sls"`` (survey= path), or ``None`` on
707-
unweighted fits. Mirrors the static-path ``variance_formula`` field."""
704+
horizons in the fit). One of ``"pweight"`` / ``"pweight_2sls"`` (when
705+
a per-row weight array was supplied, including via the deprecated
706+
``weights=`` alias; continuous / mass-point), ``"survey_binder_tsl"``
707+
/ ``"survey_binder_tsl_2sls"`` (when a SurveyDesign was supplied via
708+
``survey_design=`` or the deprecated ``survey=`` alias), or ``None``
709+
on unweighted fits. Mirrors the static-path ``variance_formula``
710+
field."""
708711
effective_dose_mean: Optional[float] = None
709712
"""Weighted denominator used by the β̂-scale rescaling. For continuous
710713
designs: weighted ``sum(w · d)/sum(w)`` (continuous_at_zero) or
@@ -2849,18 +2852,28 @@ def fit(
28492852
to the last-treatment cohort with a ``UserWarning``.
28502853
survey_design : SurveyDesign or None, keyword-only
28512854
Survey design (sampling weights + optional strata / PSU / FPC)
2852-
for design-based inference on the two continuous-dose paths
2853-
(``continuous_at_zero``, ``continuous_near_d_lower``). Passes
2854-
through :func:`compute_survey_if_variance` (Binder 1983 TSL)
2855-
for the SE; weights propagate pointwise into the lprobust
2856-
kernel composition. Only ``weight_type="pweight"`` is
2857-
supported in Phase 4.5 A — ``aweight`` / ``fweight`` raise
2858-
``NotImplementedError``. Survey design columns (strata / PSU /
2859-
FPC) must be constant within unit (sampling-unit-level
2860-
assignment); within-unit variance raises ``ValueError``.
2861-
Replicate-weight designs raise ``NotImplementedError``
2862-
(Phase 4.5 C). Mutually exclusive with the deprecated
2863-
``survey=`` and ``weights=`` aliases.
2855+
for design-based inference. Supported on ALL design × aggregate
2856+
combinations after Phase 4.5 B: continuous paths
2857+
(``continuous_at_zero``, ``continuous_near_d_lower``) on both
2858+
``aggregate="overall"`` and ``aggregate="event_study"``, AND
2859+
the ``mass_point`` design on both aggregates. Continuous paths
2860+
compose the SE via :func:`compute_survey_if_variance` (Binder
2861+
1983 TSL); weights propagate pointwise into the lprobust
2862+
kernel. Mass-point composes the per-unit 2SLS IF on the
2863+
HC1-scale and Binder-TSL-aggregates that — requires
2864+
``vcov_type='hc1'`` (the classical default raises
2865+
``NotImplementedError`` on the survey path). Event-study fits
2866+
with ``cband=True`` add a multiplier-bootstrap simultaneous
2867+
confidence band. Only ``weight_type="pweight"`` is supported
2868+
(``aweight`` / ``fweight`` raise ``NotImplementedError``).
2869+
Survey design columns (strata / PSU / FPC) must be constant
2870+
within unit (sampling-unit-level assignment); within-unit
2871+
variance raises ``ValueError``. Replicate-weight designs raise
2872+
``NotImplementedError``. Mutually exclusive with the deprecated
2873+
``survey=`` and ``weights=`` aliases. See
2874+
``docs/methodology/REGISTRY.md`` § HeterogeneousAdoptionDiD —
2875+
"Note (HAD survey-design API consolidation)" for the full
2876+
dispatch matrix.
28642877
survey : SurveyDesign or None
28652878
DEPRECATED alias of ``survey_design=``. Remains positional-or-
28662879
keyword for one minor cycle to preserve pre-PR call shapes;

0 commit comments

Comments
 (0)