Skip to content

Commit bbf75e7

Browse files
igerberclaude
andcommitted
Address PR #392 R7 review (1 P3, docstring polish)
R7 was ✅ Looks good — only 1 P3 docstring nit. The trends_lin parameter docstrings on joint_pretrends_test and joint_homogeneity_test only documented the "base_period - 1 must exist in panel" requirement, but the actual public contract is stricter: direct callers must also pass `base_period == F-1` (the last validated pre-period). The PR #392 R3 P1 guard enforces this in code; the docstring just understated it. Updated both docstrings to state explicitly that base_period must be the canonical F-1 anchor, not just any pre-period — and that non-terminal anchors raise ValueError per Eq 17 / R semantics. Stats: 540 tests pass, 0 regressions. Doc-only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent aae3531 commit bbf75e7

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

diff_diff/had_pretests.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,13 +3428,19 @@ def joint_pretrends_test(
34283428
outcome evolution as ``(t - base) × slope``. Mirrors R
34293429
``DIDHAD::did_had(..., trends_lin=TRUE)`` on its joint Stute
34303430
pre-trends surface (paper Section 5.2 Pierce-Schott
3431-
application). Requires ``base_period - 1`` to exist in the
3432-
panel; raises ``ValueError`` otherwise. The "consumed" placebo
3433-
at ``base_period - 1`` is dropped from ``pre_periods``
3434-
explicitly (its detrended residual is mechanically zero by
3435-
construction); a ``UserWarning`` fires when the filter
3436-
triggers. If ``pre_periods`` becomes empty after the drop,
3437-
raises ``ValueError`` (no testable placebo horizons remain).
3431+
application). **Requires** ``base_period`` to equal the last
3432+
validated pre-period (``t_pre_list[-1]``, i.e. the canonical
3433+
``F-1`` anchor). Direct callers passing a non-terminal base
3434+
get a ``ValueError`` — Eq 17 / R both anchor at ``F-1`` and
3435+
any other anchor would compute a different slope and
3436+
detrending. The previous validated pre-period
3437+
(``t_pre_list[-2]``, ``F-2``) must also be present so the
3438+
slope is identified. The "consumed" placebo at ``F-2`` is
3439+
dropped from ``pre_periods`` explicitly (its detrended
3440+
residual is mechanically zero by construction); a
3441+
``UserWarning`` fires when the filter triggers. If
3442+
``pre_periods`` becomes empty after the drop, raises
3443+
``ValueError`` (no testable placebo horizons remain).
34383444
Mutually exclusive with survey weighting (``survey_design`` /
34393445
``survey`` / ``weights``); raises ``NotImplementedError`` if
34403446
combined. Default ``False`` preserves bit-exact backcompat.
@@ -3872,10 +3878,14 @@ def joint_homogeneity_test(
38723878
slope estimator as :func:`joint_pretrends_test`. Mirrors R
38733879
``DIDHAD::did_had(..., trends_lin=TRUE)`` on its joint
38743880
homogeneity surface (paper Section 4.3, Pierce-Schott p=0.40
3875-
anchor). Requires ``base_period - 1`` to exist in the panel;
3876-
raises ``ValueError`` otherwise. Mutually exclusive with
3877-
survey weighting; raises ``NotImplementedError`` if combined.
3878-
Default ``False`` preserves bit-exact backcompat.
3881+
anchor). **Requires** ``base_period`` to equal the last
3882+
validated pre-period (``t_pre_list[-1]``, the canonical
3883+
``F-1`` anchor) AND ``F-2`` to be present in the panel so
3884+
the slope is identified. Direct callers passing a non-
3885+
terminal base get a ``ValueError`` — Eq 17 / R both anchor
3886+
at ``F-1``. Mutually exclusive with survey weighting; raises
3887+
``NotImplementedError`` if combined. Default ``False``
3888+
preserves bit-exact backcompat.
38793889
38803890
Returns
38813891
-------

0 commit comments

Comments
 (0)