Skip to content

Commit 402b79c

Browse files
igerberclaude
andcommitted
Address P2/P3: method-specific fallback warnings, docstring wording
DR fallback warnings now say propensity model is unconditional while outcome regression still uses covariates, instead of misleading "all covariates dropped" text. IPW warnings unchanged. Update REGISTRY.md fallback description to distinguish IPW vs DR behavior. Fix docstrings to say "predictor variables (excluding intercept)" consistently. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 00635ee commit 402b79c

5 files changed

Lines changed: 21 additions & 14 deletions

File tree

diff_diff/linalg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,8 @@ def solve_logit(
11701170
regression.
11711171
epv_threshold : float, default 10
11721172
Events Per Variable threshold. When the ratio of minority-class
1173-
observations to parameters falls below this value, a warning is
1173+
observations to predictor variables (excluding intercept) falls
1174+
below this value, a warning is
11741175
emitted (or ValueError raised if ``rank_deficient_action="error"``).
11751176
Based on Peduzzi et al. (1996).
11761177
context_label : str, default ""

diff_diff/staggered.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,11 @@ class CallawaySantAnna(
192192
functions.
193193
epv_threshold : float, default=10
194194
Events Per Variable threshold for propensity score logit.
195-
When the ratio of minority-class observations to parameters
196-
falls below this value, a warning is emitted (or ``ValueError``
197-
raised if ``rank_deficient_action="error"``). Based on Peduzzi
198-
et al. (1996). Only applies to IPW and DR estimation methods.
195+
When the ratio of minority-class observations to predictor
196+
variables (excluding intercept) falls below this value, a
197+
warning is emitted (or ``ValueError`` raised if
198+
``rank_deficient_action="error"``). Based on Peduzzi et al.
199+
(1996). Only applies to IPW and DR estimation methods.
199200
Use ``diagnose_propensity()`` for a pre-estimation check across
200201
all cohorts.
201202
pscore_fallback : str, default="error"
@@ -2443,7 +2444,8 @@ def _doubly_robust(
24432444
warnings.warn(
24442445
f"Propensity score estimation failed{ctx}. "
24452446
f"Falling back to unconditional propensity "
2446-
f"(all covariates dropped for this cell). "
2447+
f"(propensity model ignores covariates; outcome "
2448+
f"regression still uses them). "
24472449
f"Consider estimation_method='reg' to avoid "
24482450
f"propensity scores entirely.",
24492451
UserWarning,
@@ -3519,7 +3521,8 @@ def _doubly_robust_rc(
35193521
warnings.warn(
35203522
f"Propensity score estimation failed{ctx} (RCS DR). "
35213523
f"Falling back to unconditional propensity "
3522-
f"(all covariates dropped for this cell). "
3524+
f"(propensity model ignores covariates; outcome "
3525+
f"regression still uses them). "
35233526
f"Consider estimation_method='reg' to avoid "
35243527
f"propensity scores entirely.",
35253528
UserWarning,

diff_diff/triple_diff.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,11 @@ class TripleDifference:
389389
- "silent": Drop columns silently without warning
390390
epv_threshold : float, default=10
391391
Events Per Variable threshold for propensity score logit.
392-
When the ratio of minority-class observations to parameters
393-
falls below this value, a warning is emitted (or ``ValueError``
394-
raised if ``rank_deficient_action="error"``). Based on Peduzzi
395-
et al. (1996). Only applies to IPW and DR estimation methods.
392+
When the ratio of minority-class observations to predictor
393+
variables (excluding intercept) falls below this value, a
394+
warning is emitted (or ``ValueError`` raised if
395+
``rank_deficient_action="error"``). Based on Peduzzi et al.
396+
(1996). Only applies to IPW and DR estimation methods.
396397
pscore_fallback : str, default="error"
397398
Action when propensity score estimation fails:
398399
- "error": Raise the exception (default)

docs/methodology/REGISTRY.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,9 @@ The multiplier bootstrap uses random weights w_i with E[w]=0 and Var(w)=1:
412412
- Fallback: Controlled by `pscore_fallback` parameter (default `"error"`).
413413
If IRLS fails entirely (LinAlgError/ValueError) and `pscore_fallback="error"`,
414414
the error is raised. If `pscore_fallback="unconditional"`, falls back to
415-
unconditional propensity score (all covariates dropped) with warning.
415+
unconditional propensity score with warning. For IPW, this effectively
416+
drops all covariates. For DR, the propensity model is unconditional but
417+
the outcome-regression component still uses covariates.
416418
- **Note:** `pscore_fallback` default changed from unconditional to error.
417419
Set `pscore_fallback="unconditional"` for legacy behavior.
418420
- **Note:** When `pscore_fallback="unconditional"` triggers, the propensity-

tests/test_staggered.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3511,7 +3511,7 @@ def test_dr_fallback_warning(self):
35113511
)
35123512

35133513
fallback_warns = [
3514-
x for x in w if "covariates dropped" in str(x.message)
3514+
x for x in w if "unconditional propensity" in str(x.message)
35153515
]
35163516
assert len(fallback_warns) > 0, "Expected fallback warning in DR path"
35173517
assert results.overall_att is not None
@@ -3708,7 +3708,7 @@ def test_cs_pscore_fallback_unconditional_opt_in(self):
37083708
covariates=["x1"],
37093709
)
37103710
fallback_warns = [
3711-
x for x in w if "covariates dropped" in str(x.message)
3711+
x for x in w if "unconditional propensity" in str(x.message)
37123712
]
37133713
assert len(fallback_warns) > 0
37143714
assert results.overall_att is not None

0 commit comments

Comments
 (0)