Skip to content

Commit 888eb11

Browse files
igerberclaude
andcommitted
Fix llms-full.txt accuracy and dynamic canonical URLs
Address AI review P1/P2 findings: remove fabricated covariates param from ContinuousDiD.fit(), fix aggregate enum values to match source (None/dose/eventstudy), document TROP treatment as absorbing-state indicator, fix lambda_nn_grid default, give ContinuousDiDResults its own results section with correct ATT/ACRT schema, and use RTD's READTHEDOCS_CANONICAL_URL for version-aware html_baseurl/ogp_site_url. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1013266 commit 888eb11

2 files changed

Lines changed: 49 additions & 7 deletions

File tree

docs/conf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@
6565
html_theme = "pydata_sphinx_theme"
6666
html_static_path = ["_static"]
6767
html_title = "diff-diff: Difference-in-Differences Causal Inference for Python"
68-
html_baseurl = "https://diff-diff.readthedocs.io/en/stable/"
68+
# Use RTD's canonical URL when available; fall back to stable for local builds.
69+
_canonical_url = os.environ.get(
70+
"READTHEDOCS_CANONICAL_URL",
71+
"https://diff-diff.readthedocs.io/en/stable/",
72+
)
73+
html_baseurl = _canonical_url
6974
html_extra_path = ["llms.txt", "llms-full.txt"]
7075
sitemap_url_scheme = "{link}"
7176

@@ -95,7 +100,7 @@
95100
}
96101

97102
# -- Options for sphinxext-opengraph -----------------------------------------
98-
ogp_site_url = "https://diff-diff.readthedocs.io/en/stable/"
103+
ogp_site_url = _canonical_url
99104
ogp_site_name = "diff-diff"
100105
ogp_description_length = 200
101106
ogp_type = "website"

docs/llms-full.txt

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,7 @@ cdid.fit(
465465
time: str,
466466
first_treat: str,
467467
dose: str, # Column with continuous treatment dose
468-
covariates: list[str] = None,
469-
aggregate: str = None, # None, "simple", "dose", "event_study"
468+
aggregate: str = None, # None, "dose", "eventstudy"
470469
) -> ContinuousDiDResults
471470
```
472471

@@ -580,7 +579,7 @@ TROP(
580579
method: str = "twostep", # "twostep" or "global" (or deprecated "joint")
581580
lambda_time_grid: list[float] = None, # Time weight decay grid [0, 0.1, 0.5, 1, 2, 5]
582581
lambda_unit_grid: list[float] = None, # Unit weight decay grid [0, 0.1, 0.5, 1, 2, 5]
583-
lambda_nn_grid: list[float] = None, # Nuclear norm grid [0, 0.01, 0.1, 1]
582+
lambda_nn_grid: list[float] = None, # Nuclear norm grid [0, 0.01, 0.1, 1, 10]
584583
max_iter: int = 100,
585584
tol: float = 1e-6,
586585
alpha: float = 0.05,
@@ -595,7 +594,7 @@ TROP(
595594
trop.fit(
596595
data: pd.DataFrame,
597596
outcome: str,
598-
treatment: str, # Treatment indicator (0/1, can vary over time)
597+
treatment: str, # Absorbing-state treatment indicator (0/1). Must be 0 for all pre-treatment periods and 1 for treatment and post-treatment periods.
599598
unit: str,
600599
time: str,
601600
) -> TROPResults
@@ -865,7 +864,7 @@ Individual 2x2 DiD comparison (used in BaconDecompositionResults).
865864

866865
### Common Results Pattern for Staggered Estimators
867866

868-
ImputationDiDResults, TwoStageDiDResults, StackedDiDResults, EfficientDiDResults, and ContinuousDiDResults all share a similar structure:
867+
ImputationDiDResults, TwoStageDiDResults, StackedDiDResults, and EfficientDiDResults share a similar structure:
869868

870869
| Attribute | Type | Description |
871870
|-----------|------|-------------|
@@ -886,6 +885,44 @@ Each event study effect dict contains: `effect`, `se`, `t_stat`, `p_value`, `con
886885

887886
**Methods:** `summary()`, `print_summary()`, `to_dataframe()`
888887

888+
### ContinuousDiDResults
889+
890+
| Attribute | Type | Description |
891+
|-----------|------|-------------|
892+
| `dose_response_att` | `DoseResponseCurve` | Dose-response curve for ATT |
893+
| `dose_response_acrt` | `DoseResponseCurve` | Dose-response curve for ACRT |
894+
| `overall_att` | `float` | Overall ATT |
895+
| `overall_att_se` | `float` | SE of overall ATT |
896+
| `overall_att_t_stat` | `float` | T-statistic for ATT |
897+
| `overall_att_p_value` | `float` | P-value for ATT |
898+
| `overall_att_conf_int` | `tuple[float, float]` | CI for ATT |
899+
| `overall_acrt` | `float` | Overall ACRT |
900+
| `overall_acrt_se` | `float` | SE of overall ACRT |
901+
| `overall_acrt_t_stat` | `float` | T-statistic for ACRT |
902+
| `overall_acrt_p_value` | `float` | P-value for ACRT |
903+
| `overall_acrt_conf_int` | `tuple[float, float]` | CI for ACRT |
904+
| `group_time_effects` | `dict[tuple, dict]` | Group-time level effects |
905+
| `dose_grid` | `np.ndarray` | Evaluation grid for dose-response |
906+
| `groups` | `list` | Treatment cohorts |
907+
| `time_periods` | `list` | All time periods |
908+
| `n_obs` | `int` | Number of observations |
909+
| `n_treated_units` | `int` | Treated units |
910+
| `n_control_units` | `int` | Control units |
911+
| `event_study_effects` | `dict[int, dict] or None` | Event study effects (if `aggregate="eventstudy"`) |
912+
913+
**DoseResponseCurve** sub-dataclass:
914+
915+
| Attribute | Type | Description |
916+
|-----------|------|-------------|
917+
| `dose_grid` | `np.ndarray` | Dose values |
918+
| `effects` | `np.ndarray` | Estimated effects at each dose |
919+
| `se` | `np.ndarray` | Standard errors |
920+
| `conf_int_lower` | `np.ndarray` | Lower CI bound |
921+
| `conf_int_upper` | `np.ndarray` | Upper CI bound |
922+
| `target` | `str` | `"att"` or `"acrt"` |
923+
924+
**Methods:** `summary()`, `print_summary()`, `to_dataframe()`
925+
889926
### TROPResults
890927

891928
| Attribute | Type | Description |

0 commit comments

Comments
 (0)