Skip to content

Commit 93f6ae5

Browse files
igerberclaude
andcommitted
docs: utility coverage gaps - profile_panel + local_linear API refs, llms-autonomous.txt
Closes three RTD coverage gaps surfaced during the docs audit: 1. profile_panel and its 4 supporting dataclasses (PanelProfile, OutcomeShape, TreatmentDoseShape, Alert) are public top-level exports but had no API reference. New docs/api/profile.rst covers all 5 symbols under a new "Pre-Fit Profiling" toctree section. 2. The 11 top-level local-linear infrastructure symbols (kernels, kernel_moments, local_linear_fit, mse_optimal_bandwidth, bias_corrected_local_linear, and their result dataclasses) had no API reference. New docs/api/local_linear.rst covers all 11 under a new "Infrastructure" toctree section (sibling to Estimators, not a peer of HAD/EfficientDiD - the symbols are building blocks HAD composes). 3. llms-autonomous.txt (65KB) shipped in the wheel but was not exposed via Sphinx. Added to docs/conf.py html_extra_path; the practitioner-profile prose link in profile.rst now resolves on RTD. doc-deps.yaml: extends existing local_linear.py entry to point at the new api/local_linear.rst; adds new diff_diff/profile.py top-level entry at drift_risk: low (descriptive-only by design, sits with prep.py / datasets.py not the linalg.py / utils.py methodology-stake tier). Drive-by: 1-line RST formatting fix in BaconDecomposition Parameters docstring (blank line before bullet list) noticed during the deferred Sphinx -W investigation. Verification: sphinx make html shows zero warnings on the three new/edited files (pre-existing -W backlog out of scope). Rendered HTML confirms all 16 new symbols render and llms-autonomous.txt is served from html_extra_path. test_doc_snippets.py: 111 passed, 4 skipped (unchanged baseline; new RST files contain no code-blocks). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 33afb6a commit 93f6ae5

6 files changed

Lines changed: 188 additions & 0 deletions

File tree

diff_diff/bacon.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ class BaconDecomposition:
324324
----------
325325
weights : str, default="approximate"
326326
Weight calculation method:
327+
327328
- "approximate": Fast simplified formula using group shares and
328329
treatment variance. Good for diagnostic purposes where relative
329330
weights are sufficient to identify problematic comparisons.

docs/api/index.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ Placebo tests and model diagnostics:
101101
diff_diff.run_all_placebo_tests
102102
diff_diff.PlaceboTestResults
103103

104+
Panel Profiling
105+
---------------
106+
107+
Pre-fit description of panel structure for estimator selection. The
108+
:class:`~diff_diff.PanelProfile` return type and its supporting dataclasses
109+
are documented in :doc:`profile`.
110+
111+
.. autosummary::
112+
:toctree: _autosummary
113+
:nosignatures:
114+
115+
diff_diff.profile_panel
116+
104117
Sensitivity Analysis
105118
--------------------
106119

@@ -246,6 +259,22 @@ Estimators
246259
wooldridge_etwfe
247260
bacon
248261

262+
Infrastructure
263+
~~~~~~~~~~~~~~
264+
265+
.. toctree::
266+
:maxdepth: 2
267+
268+
local_linear
269+
270+
Pre-Fit Profiling
271+
~~~~~~~~~~~~~~~~~
272+
273+
.. toctree::
274+
:maxdepth: 2
275+
276+
profile
277+
249278
Diagnostics & Inference
250279
~~~~~~~~~~~~~~~~~~~~~~~
251280

docs/api/local_linear.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
Local-Linear Infrastructure
2+
===========================
3+
4+
Kernels, kernel-moment constants, univariate local-linear regression at a
5+
boundary, the MSE-optimal bandwidth selector, and the bias-corrected
6+
local-linear fit.
7+
8+
This module ships the nonparametric building blocks that
9+
:class:`~diff_diff.HeterogeneousAdoptionDiD` composes for its continuous-dose
10+
fit paths (``continuous_at_zero`` and ``continuous_near_d_lower``); see
11+
:doc:`had` for the estimator that consumes them. The components are also
12+
usable on their own for any one-sided boundary local-linear regression
13+
problem with a strictly nonnegative running variable.
14+
15+
The selector and bias correction are ports of the Calonico-Cattaneo-Farrell
16+
(2018) plug-in bandwidth and Calonico-Cattaneo-Titiunik (2014) robust-bias
17+
correction from the R ``nprobust`` package; methodology context lives in
18+
:doc:`had` and ``docs/methodology/REGISTRY.md``.
19+
20+
Kernels
21+
-------
22+
23+
Bounded one-sided kernels on ``[0, 1]`` for boundary-point nonparametric
24+
regression. The library normalizes the Epanechnikov and triangular kernels
25+
to ``int_0^1 k(u) du = 1/2``; the uniform kernel uses
26+
``int_0^1 k(u) du = 1``.
27+
28+
.. autofunction:: diff_diff.epanechnikov_kernel
29+
30+
.. autofunction:: diff_diff.triangular_kernel
31+
32+
.. autofunction:: diff_diff.uniform_kernel
33+
34+
.. autodata:: diff_diff.KERNELS
35+
:annotation: : dict[str, Callable[[np.ndarray], np.ndarray]]
36+
:no-value:
37+
38+
Mapping from kernel name (``"epanechnikov"`` / ``"triangular"`` /
39+
``"uniform"``) to its callable evaluator on ``[0, 1]``. Pass the name
40+
string (not the callable) to ``local_linear_fit`` and
41+
``mse_optimal_bandwidth`` via their ``kernel=`` argument.
42+
43+
.. autofunction:: diff_diff.kernel_moments
44+
45+
Boundary local-linear fit
46+
-------------------------
47+
48+
Kernel-weighted OLS estimator of the conditional mean
49+
``m(d0) := E[Y | D = d0]`` at the boundary of ``D``'s support.
50+
51+
.. autofunction:: diff_diff.local_linear_fit
52+
53+
.. autoclass:: diff_diff.LocalLinearFit
54+
:members:
55+
:undoc-members:
56+
:show-inheritance:
57+
58+
MSE-optimal bandwidth selector
59+
------------------------------
60+
61+
Plug-in MSE-optimal bandwidth (Calonico-Cattaneo-Farrell 2018) for the
62+
boundary local-linear fit. Returns ``BandwidthResult`` carrying the final
63+
bandwidth ``h_mse`` plus the per-stage diagnostics needed to audit the
64+
selector against the R ``nprobust`` reference.
65+
66+
.. autofunction:: diff_diff.mse_optimal_bandwidth
67+
68+
.. autoclass:: diff_diff.BandwidthResult
69+
:members:
70+
:undoc-members:
71+
:show-inheritance:
72+
73+
Bias-corrected local-linear fit
74+
-------------------------------
75+
76+
Calonico-Cattaneo-Titiunik (2014) robust-bias-corrected boundary
77+
estimator. Composes the bandwidth selector and the local-linear fit and
78+
returns a ``BiasCorrectedFit`` with point estimate, robust standard error,
79+
and 95% confidence interval.
80+
81+
.. autofunction:: diff_diff.bias_corrected_local_linear
82+
83+
.. autoclass:: diff_diff.BiasCorrectedFit
84+
:members:
85+
:undoc-members:
86+
:show-inheritance:

docs/api/profile.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Panel Profiling
2+
===============
3+
4+
Pre-fit description of a DiD panel's structural facts. ``profile_panel()``
5+
inspects a long-format panel and returns a :class:`PanelProfile` dataclass
6+
covering balance, treatment-type classification, outcome characteristics, and
7+
a list of factual :class:`Alert` observations.
8+
9+
The profile is descriptive, not opinionated: alerts report what is (e.g.
10+
"smallest cohort has 7 units"), never what to do about it. Estimator
11+
selection is the caller's responsibility. For autonomous-agent consumption,
12+
pair the profile output with the
13+
`autonomous-agent reference guide <../llms-autonomous.txt>`_ (also accessible
14+
at runtime via ``diff_diff.get_llm_guide("autonomous")``), which walks
15+
through the estimator-support matrix and the per-design-feature reasoning
16+
keyed off ``PanelProfile`` field values.
17+
18+
.. note::
19+
20+
``PanelProfile`` and its three supporting dataclasses
21+
(:class:`OutcomeShape`, :class:`TreatmentDoseShape`, :class:`Alert`) are
22+
re-exported at the top level of ``diff_diff`` so callers can construct
23+
or pattern-match against them without dotted-module access.
24+
25+
profile_panel
26+
-------------
27+
28+
.. autofunction:: diff_diff.profile_panel
29+
30+
PanelProfile
31+
------------
32+
33+
.. autoclass:: diff_diff.PanelProfile
34+
:members:
35+
:undoc-members:
36+
:show-inheritance:
37+
38+
OutcomeShape
39+
------------
40+
41+
.. autoclass:: diff_diff.OutcomeShape
42+
:members:
43+
:undoc-members:
44+
:show-inheritance:
45+
46+
TreatmentDoseShape
47+
------------------
48+
49+
.. autoclass:: diff_diff.TreatmentDoseShape
50+
:members:
51+
:undoc-members:
52+
:show-inheritance:
53+
54+
Alert
55+
-----
56+
57+
.. autoclass:: diff_diff.Alert
58+
:members:
59+
:undoc-members:
60+
:show-inheritance:

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"../diff_diff/guides/llms.txt",
7676
"../diff_diff/guides/llms-full.txt",
7777
"../diff_diff/guides/llms-practitioner.txt",
78+
"../diff_diff/guides/llms-autonomous.txt",
7879
]
7980
sitemap_url_scheme = "{link}"
8081

docs/doc-deps.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,17 @@ sources:
410410
type: methodology
411411
- path: docs/api/had.rst
412412
type: api_reference
413+
- path: docs/api/local_linear.rst
414+
type: api_reference
415+
416+
diff_diff/profile.py:
417+
drift_risk: low
418+
docs:
419+
- path: docs/api/profile.rst
420+
type: api_reference
421+
- path: diff_diff/guides/llms-autonomous.txt
422+
section: "PanelProfile field reference"
423+
type: user_guide
413424

414425
# ── SyntheticDiD ───────────��───────────────────────────────────────
415426

0 commit comments

Comments
 (0)