Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
03f4119
docs: input contract for estimator data and objects (IC-01 to IC-16)
igerber Dec 1, 2026
c511d0f
docs(input-contract): scope IC-09 and IC-16, reconcile the label-0 re…
igerber Dec 1, 2026
875506e
docs(input-contract): bound the label span, state the PT-Post baselin…
igerber Dec 1, 2026
cfb0b68
docs(input-contract): leave estimator-specific period requirements to…
igerber Dec 1, 2026
ff2b041
docs(input-contract): keep estimator-specific period requirements out…
igerber Dec 1, 2026
5cb7466
docs(registry): note the EfficientDiD PT-Post baseline under anticipa…
igerber Dec 1, 2026
f1b592f
docs(registry): state the identifying assumptions for the anticipatio…
igerber Dec 1, 2026
67da913
docs(input-contract): exclude the never-treated markers from the IC-1…
igerber Dec 1, 2026
f0a73fb
docs(input-contract): correct the nonlinear exemption, the marker wor…
igerber Dec 1, 2026
a97e9c4
docs(input-contract): describe CallawaySantAnna non-finite outcome ha…
igerber Dec 1, 2026
e68459f
docs(input-contract): state the CallawaySantAnna non-finite gap as a …
igerber Dec 1, 2026
16feb45
docs(input-contract): reduce the CallawaySantAnna non-finite gap to t…
igerber Dec 1, 2026
89ecdb7
docs(input-contract): label the overall ATT separately from the affec…
igerber Dec 1, 2026
72e63da
docs(input-contract): scope the label clauses to fit paths that do la…
igerber Dec 1, 2026
29cf5cb
docs(input-contract): name the calendar label types the event-study p…
igerber Dec 1, 2026
0461899
docs(input-contract): state which estimators the horizon and anticipa…
igerber Dec 1, 2026
b70f3dd
docs(input-contract): define the IC-05 level warning for constant out…
igerber Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ When adding new functionality, the source of truth is:
|------|----------|
| `docs/methodology/REGISTRY.md` | Academic foundations, equations, edge cases — **consult before methodology changes** |
| `docs/v4-design.md` + `docs/v4-deprecations.yaml` | 4.0 program design spec + CI-enforced deprecation ledger — **consult before any 4.0-program PR**; deviations must edit both in the same diff |
| `docs/input-contract.md` | Input contract: which data and objects estimators guarantee, refuse, or leave out of contract (numbered `IC-xx` clauses, with a gap table of where main falls short) — **consult before adding input validation or guards**; engineering boundary, not methodology |
| `docs/doc-deps.yaml` | Source-to-documentation dependency map — **consult when any source file changes** |
| `CONTRIBUTING.md` | Documentation requirements, test writing guidelines, implementation guidelines |
| `.claude/memory.md` | Debugging patterns, tolerances, API conventions (git-tracked) |
Expand Down
8 changes: 8 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ Related tracking surfaces:

| Issue | Location | Origin | Effort | Priority |
|-------|----------|--------|--------|----------|
| Input contract IC-09: duplicate unit-time rows are fitted with no error or warning by `SunAbraham`, `ImputationDiD`, `TwoStageDiD` and `WooldridgeDiD` (`CallawaySantAnna` raises a raw pandas reshape error). Refuse them in the shared input boundary for every fit path whose input grain is one observation per unit and calendar period, not with per-estimator guards. Two kinds of fit path are excluded: the 0/1 post-indicator paths of `DifferenceInDifferences` and static `TwoWayFixedEffects`, where several rows per unit and indicator value are legitimate, and estimators that aggregate several observations per unit-period cell (`ChaisemartinDHaultfoeuille`). See `docs/input-contract.md` "Gaps on main". | `sun_abraham.py`, `imputation.py`, `two_stage.py`, `wooldridge.py`, `staggered.py` | input contract PR | Mid | Medium |
| Input contract IC-01 / IC-02: outcome dtype handling differs by estimator. `CallawaySantAnna` returns a wrong ATT for unsigned-integer outcomes with no warning and raises an unrelated `TypeError` for nullable and `bool` outcomes; `DifferenceInDifferences`, `TwoWayFixedEffects`, `SunAbraham`, `StackedDiD` and `WooldridgeDiD` coerce digit strings and object columns and fit. Convert numeric outcomes to `float64` once at entry with an exactness check and refuse non-numeric ones, in the shared input boundary. | `staggered.py`, `estimators.py`, `twfe.py`, `sun_abraham.py`, `stacked_did.py`, `wooldridge.py` | input contract PR | Mid | Medium |
| Input contract IC-04: tolerances that depend on the outcome's units. `ImputationDiD` and `TwoStageDiD` use an absolute solver tolerance (ATT off by 6e-6 at `y * 1e-6` and by 28% at `y * 1e-12`, no warning); `EfficientDiD` falls back to uniform weights at `y * 1e-6` and `y * 1e12` (SE moves 21%, warned); the shared demeaning routine warns of non-convergence at `y * 1e12` with unchanged results (`TwoWayFixedEffects`, `SunAbraham`, `WooldridgeDiD`). Make each tolerance relative to the outcome's scale and pin unit equivariance with a rescaling test across estimators. | `imputation.py`, `two_stage.py`, `efficient_did_weights.py`, `utils.py` | input contract PR | Mid | Medium |
| Input contract IC-06 / IC-05: a noiseless outcome gives a standard error that is rounding error, and inference is computed from it: p = 7.5e-7 (`ImputationDiD`) and p = 0 (`TwoStageDiD`) on an exact null, and for a constant outcome `DifferenceInDifferences` gives p = 1e-33 on the Rust backend against 0.075 on Python. Define one rule, relative to the outcome's scale, below which every inference field is NaN with a warning, and apply it on every inference path: `safe_inference()`, `safe_inference_batch()`, and the bootstrap statistics (percentile intervals and bootstrap p-values do not pass through `safe_inference()` and today guard an exactly constant draw distribution only). Calibrate it so that genuinely small standard errors are kept, and leave rows that are NaN by construction (a normalized reference period) alone. The rule also governs simultaneous confidence bands: with one rounding-level horizon and one valid horizon, the valid horizon's critical value must equal the one calibrated on that horizon alone and the excluded horizon's band must be NaN (the sup-t code in `staggered_bootstrap.py` checks only that the SE is finite and positive). Also warn when `abs(mean(y)) / sd(y)` exceeds 1e9 (relative error reaches 1e-3 at `y + 1e12`); the ratio is not evaluated for a constant outcome, detected by `min(y) == max(y)` (the computed SD of a repeated `0.1` is about 1.4e-17, not zero), so all-zero and repeated-`0.1` outcomes must give NaN inference and exactly one outcome diagnostic, the NaN-inference warning. | `utils.py`, `bootstrap_utils.py`, `staggered_bootstrap.py` | input contract PR | Mid | Medium |
| Input contract IC-11 to IC-15: time and cohort labels. `ImputationDiD` and `TwoStageDiD` read a `NaN` cohort as never-treated with no warning (`WooldridgeDiD` fills 0 with a warning) and read `NaT` never-treated units in a `datetime64` panel as always-treated; `EfficientDiD` returns a different ATT for labels near `2**62` with no warning; 6 of the 7 cohort-based estimators probed accept string years; none of the 7 cohort-based estimators probed, under default settings, gives a general warning when periods are unevenly spaced (estimator-specific handling of missing periods, such as the complete-window rule of `StackedDiD`, is separate); since horizons and `anticipation` are label differences (observed for horizons in `SunAbraham` and `WooldridgeDiD`, and for `anticipation` in `CallawaySantAnna` and `ImputationDiD`), encoded labels such as `YYYYQ` yield horizons and anticipation windows that are not in periods; a cohort that adopts at label `0` is read as never-treated by `CallawaySantAnna`, `SunAbraham`, `ImputationDiD` and `EfficientDiD` with no warning, also when never-treated units are marked `+inf`; a cohort with a negative label is dropped or misread by `CallawaySantAnna`, `SunAbraham`, `EfficientDiD` and `WooldridgeDiD`. Refuse or warn as the clauses state, in the shared input boundary, on the fit paths that do label arithmetic only: paths that just sort and match calendar labels against `post_periods` / `reference_period` (the event-study mode of `TwoWayFixedEffects`) keep their datetime, `Period` and string label support. Regression case for the label mapping: periods `-3` to `3` with cohorts `-1`, `1` and `+inf` must give the same ATT and event-time horizons, with both treated cohorts contributing, as the same panel with time and treated-cohort labels shifted by `+4`. Further acceptance case: time labels `-2**53 + 1` and `-2**53 + 2` with cohort `2` must be refused (the span exceeds `2**53`, so two horizons would collide). Fixtures for label `0`, which stays reserved: a panel with labels below `0`, a positive adoption cohort and never-treated units marked `0` must raise, and must fit when they are marked `+inf`; and a panel whose known zero adopters were recoded by the caller to `4` (time shifted by `+4`, never-treated units at `+inf`) must treat them as cohort `4` and place none of them in the never-treated pool. | `imputation.py`, `two_stage.py`, `wooldridge.py`, `efficient_did.py`, `staggered.py`, `sun_abraham.py` | input contract PR | Mid | Medium |
| Input contract IC-03: non-finite outcomes. `ImputationDiD` and `TwoStageDiD` return finite estimates for an outcome containing `inf` with only a numpy warning, and an all-NaN result after a solver non-convergence warning for `NaN`; `CallawaySantAnna` has no dedicated upfront check for non-finite outcomes, so they are not refused and the result depends on the estimation route and on the data (an example is in `docs/input-contract.md`, "Gaps on main"). Refuse non-finite outcomes in the shared input boundary; the `CallawaySantAnna` change is user-visible and needs a deprecation path. | `imputation.py`, `two_stage.py`, `staggered.py` | input contract PR | Mid | Medium |
| `EfficientDiD` PT-Post missing-baseline error: the baseline is period `g - 1 - anticipation` in label units (REGISTRY.md, `EfficientDiD` PT-Post Note; adoption at `4` with `anticipation=1`: labels `[1, 3, 4, 5, 6]` fail for want of period `2`, labels `[1, 2, 4, 5, 6]` fit). When every cohort is dropped for a missing baseline the warning names the period but the final `ValueError` is the generic "Could not estimate any group-time effects" (also hit by evenly spaced labels with a step other than 1, such as `2000, 2002, 2004, 2006`, which fit once indexed by wave); name the missing period in the error. | `efficient_did.py` | input contract PR | Quick | Low |
| Input contract IC-10: `uint8` time labels raise misleading errors in `SunAbraham` and `StackedDiD`. Convert integer labels of any width to `int64` in the shared input boundary. | `sun_abraham.py`, `stacked_did.py` | input contract PR | Quick | Low |
| Planned sensitivity power under a violation inside the restriction: `HonestDiD.power_by_M` reports power when parallel trends hold in the placebo draws. The same counting with a trend added to the placebo-treated units (a unit-homogeneous trend also shifts the coefficients exactly) would give power under a stated violation; needs a decision on which violation shapes to offer and a real-injection check like `benchmarks/python/sensitivity_planning_check.py`. | `honest_did.py::HonestDiD.power_by_M`, `honest_did.py::_score_planned_intervals` | sensitivity planning PR | Mid | Low |
| `HonestDiD(method="smoothness")` over-rejects on small panels: at `M = 0` the weights on the pre-period slopes are chosen from the fit's own estimated covariance, and in `benchmarks/data/sensitivity_planning_check.json` the interval excluded zero in 12% to 44% of fresh no-effect draws at 40 units (10 treated) and 5% to 11% at 200 units. `power_by_M` withholds such rows at the design stage; `fit` on a fitted model gives no signal. Decide whether `fit` should warn when the number of clusters is small relative to the number of pre-periods, and on what threshold. | `honest_did.py::_compute_optimal_flci`, `honest_did.py::HonestDiD.fit` | sensitivity planning PR | Mid | Medium |
| Placebo event studies for more `diagnose_design` candidates: `SunAbraham` (its container is not an admitted `PreTrendsPower` input; only the fitted results object is) and the `TwoWayFixedEffects` event-study mode (a different fit from the static one the diagnosis runs). Recorded today for `CallawaySantAnna` and `StackedDiD` only. | `design.py::_EVENT_STUDY_ESTIMATORS`, `pretrends.py::_extract_container_pre_period_params` | pre-trend planning PR | Mid | Low |
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
".DS_Store",
"business-strategy.md",
"dev-status.md",
"input-contract.md",
"performance-plan.md",
"performance-scenarios.md",
"practitioner-guide-evaluation.md",
Expand Down
Loading
Loading