Skip to content

Commit 6fb44e6

Browse files
igerberclaude
andcommitted
Address PR #376 R11 P3 (HAD.fit weights= deprecation message)
R11 P3 (informational): HAD.fit's `weights=` deprecation message used the shared HAD_DEPRECATION_MSG_WEIGHTS_KWARG_DATA_IN constant, which suggests migrating to `survey_design=SurveyDesign(weights='col_name')`. On the workflow + joint data-in wrappers that migration is inference-equivalent (both go through _resolve_pretest_unit_weights to per-unit weights, then through the shared Stute / Yatchew kernels). On HAD.fit it is NOT inference-equivalent today: the deprecated `weights=arr` shortcut keeps `variance_formula="pweight"` / `"pweight_2sls"` (CCT-2014 weighted-robust / 2SLS pweight-sandwich), while `survey_design=SurveyDesign(weights=col)` composes Binder-TSL (`"survey_binder_tsl"` / `"survey_binder_tsl_2sls"`). Following the migration changes the SE family — the long-term unification is tracked in TODO row 102 for the next minor. Fix: add a HAD.fit-specific HAD_DEPRECATION_MSG_WEIGHTS_KWARG_HAD_FIT constant that says the long-term API is still survey_design= but explicitly notes the SE-family caveat applies in the current release. HAD.fit consumes this new constant; the workflow + joint wrappers keep the original HAD_DEPRECATION_MSG_WEIGHTS_KWARG_DATA_IN (no SE-family divergence on those surfaces). 561 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 236bdce commit 6fb44e6

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

diff_diff/had.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
)
7979
from diff_diff.survey import (
8080
HAD_DEPRECATION_MSG_SURVEY_KWARG,
81-
HAD_DEPRECATION_MSG_WEIGHTS_KWARG_DATA_IN,
81+
HAD_DEPRECATION_MSG_WEIGHTS_KWARG_HAD_FIT,
8282
HAD_DUAL_KNOB_MUTEX_MSG_DATA_IN,
8383
SurveyMetadata,
8484
compute_survey_metadata,
@@ -2927,7 +2927,7 @@ def fit(
29272927
survey_design = survey
29282928
elif weights is not None:
29292929
warnings.warn(
2930-
HAD_DEPRECATION_MSG_WEIGHTS_KWARG_DATA_IN,
2930+
HAD_DEPRECATION_MSG_WEIGHTS_KWARG_HAD_FIT,
29312931
DeprecationWarning,
29322932
stacklevel=2,
29332933
)

diff_diff/survey.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,28 @@ def make_pweight_design(weights: np.ndarray) -> "ResolvedSurveyDesign":
785785
"`data` and pass `survey_design=SurveyDesign(weights='col_name')` "
786786
"instead. Will be removed in the next minor release."
787787
)
788+
# PR #376 R11 P3: HAD.fit-specific weights= deprecation message — the
789+
# generic data-in suggestion above (use `survey_design=SurveyDesign(...)`)
790+
# is the long-term API target, but on `HeterogeneousAdoptionDiD.fit` the
791+
# two paths currently produce different SE families: the deprecated
792+
# `weights=np.ndarray` shortcut yields `variance_formula="pweight"` /
793+
# `"pweight_2sls"` (CCT-2014 weighted-robust / 2SLS pweight-sandwich)
794+
# while `survey_design=SurveyDesign(...)` yields `"survey_binder_tsl"` /
795+
# `"survey_binder_tsl_2sls"`. The next-minor cleanup (TODO row 102) will
796+
# unify the two; until then, document the SE-family caveat explicitly so
797+
# users know what changes when they migrate.
798+
HAD_DEPRECATION_MSG_WEIGHTS_KWARG_HAD_FIT = (
799+
"`weights=np.ndarray` is deprecated on HeterogeneousAdoptionDiD.fit; "
800+
"the long-term API is to add the weights as a column on `data` and "
801+
"pass `survey_design=SurveyDesign(weights='col_name')`. Will be "
802+
"removed in the next minor release. NOTE: in the current release the "
803+
"two paths produce different SE families on this surface — the "
804+
"`weights=` shortcut keeps the analytical CCT-2014 / 2SLS pweight-"
805+
"sandwich (`variance_formula='pweight'` or `'pweight_2sls'`), while "
806+
"`survey_design=SurveyDesign(...)` composes Binder-TSL "
807+
"(`'survey_binder_tsl'` or `'survey_binder_tsl_2sls'`). The "
808+
"long-term unification is tracked for the next minor release."
809+
)
788810
HAD_DEPRECATION_MSG_WEIGHTS_KWARG_ARRAY_IN = (
789811
"`weights=np.ndarray` is deprecated on array-in pretest helpers; use "
790812
"`survey_design=make_pweight_design(weights)` instead "

0 commit comments

Comments
 (0)