Skip to content

Commit 7672f8d

Browse files
igerberclaude
andcommitted
Clarify auto-bandwidth docstring: direct selector + rho=1
Docstring note from AI review. The wrapper's docstring still said auto mode chooses both h and b via `mse_optimal_bandwidth`, but the implementation now calls `_nprobust_port.lpbwselect_mse_dpi` directly (to forward cluster / vce / nnmatch) and then sets `b = h` per nprobust's rho=1 default. Update the docstrings to reflect that. Behavior is unchanged; this is a comment-only clarification. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent bee6805 commit 7672f8d

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

diff_diff/local_linear.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,13 +889,17 @@ class applies the beta-scale ``(1/G) * sum(D_{g,2})`` rescaling.
889889
Main and bias-correction bandwidths actually used (post-``bwcheck``
890890
floor).
891891
bandwidth_source : {"auto", "user"}
892-
``"auto"`` when the selector chose ``h`` and ``b`` via
893-
:func:`mse_optimal_bandwidth`; ``"user"`` when the caller passed
894-
explicit bandwidths.
892+
``"auto"`` when the wrapper called the Phase 1b DPI selector
893+
(``_nprobust_port.lpbwselect_mse_dpi``) internally with the
894+
caller's ``cluster`` / ``vce`` / ``nnmatch``; ``"user"`` when the
895+
caller passed explicit bandwidths. Auto mode then enforces
896+
nprobust's ``rho=1`` default by setting ``b = h``; the
897+
selector's distinct ``b_mse`` is surfaced via
898+
``bandwidth_diagnostics`` but not applied.
895899
bandwidth_diagnostics : BandwidthResult or None
896900
Full Phase 1b selector output when ``bandwidth_source == "auto"``;
897901
``None`` when the user supplied bandwidths (to avoid a redundant
898-
Phase 1b computation).
902+
selector call).
899903
n_used : int
900904
Observations retained in the active kernel window (``sum(ind.b)``
901905
when ``h <= b`` and ``sum(ind.h)`` when ``h > b``; with the
@@ -972,9 +976,15 @@ def bias_corrected_local_linear(
972976
see Phase 1b's input contract.
973977
kernel : {"epanechnikov", "triangular", "uniform"}, default="epanechnikov"
974978
h : float or None, default=None
975-
Main bandwidth. ``None`` auto-selects both ``h`` and ``b`` via
976-
:func:`mse_optimal_bandwidth`. If ``h`` is provided and ``b`` is
977-
``None``, ``b = h`` (nprobust ``rho=1`` default).
979+
Main bandwidth. ``None`` auto-selects ``h`` by calling
980+
``diff_diff._nprobust_port.lpbwselect_mse_dpi`` directly with the
981+
supplied ``cluster``, ``vce``, and ``nnmatch`` so the selector
982+
and the final fit use the same estimator. ``b`` is then set to
983+
``h`` per nprobust's ``rho=1`` default; the selector's distinct
984+
``b_mse`` is surfaced through
985+
``BiasCorrectedFit.bandwidth_diagnostics`` for inspection but
986+
not applied. If ``h`` is provided and ``b`` is ``None``,
987+
``b = h`` likewise.
978988
b : float or None, default=None
979989
Bias-correction bandwidth. Pairs with ``h`` (see above). ``b``
980990
provided without ``h`` raises ``ValueError``.

0 commit comments

Comments
 (0)