Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c391595
docs(tutorials): repair and conform the Staggered family tutorials (1…
igerber Nov 27, 2026
e29734f
docs(tutorials): scope the lowest-dose, Proposition 9, time-weight an…
igerber Nov 27, 2026
0b87ca4
docs(tutorials): state own-dose effects under parallel trends (14); c…
igerber Nov 27, 2026
298cb46
docs(tutorials): the lowest-dose comparison rebases effect levels, no…
igerber Nov 27, 2026
91fce07
docs(tutorials): name the fit the pre-trend diagnostics take; say why…
igerber Nov 27, 2026
f6ec8d9
docs(tutorials): the asymmetric stacked window leaves point estimates…
igerber Nov 27, 2026
bb6ea91
test(tutorials): match the diagnostics' rejection messages; pin the s…
igerber Nov 27, 2026
aa4fc6c
docs(tutorials): scope the imputation efficiency guarantee to the unw…
igerber Nov 27, 2026
a413bf1
docs(tutorials): the averaged TROP factor matrix says nothing about t…
igerber Nov 27, 2026
a6124b1
docs(tutorials): say which cohorts each mpdta horizon averages (16); …
igerber Nov 27, 2026
3639e2d
docs(tutorials): the cohort mix changes with the horizon; the two lat…
igerber Nov 27, 2026
714db84
docs(tutorials): the overall ATT is spline-free while the same cells …
igerber Nov 27, 2026
1b6c2b7
docs(tutorials): the binary fit's 4.55 is its overall ATT, not its on…
igerber Nov 27, 2026
672cafc
docs(tutorials): the reference-period reading of ETWFE placebo coeffi…
igerber Nov 27, 2026
879283e
docs(tutorials): state the unbalanced-panel condition for ETWFE as mi…
igerber Nov 27, 2026
9f2f5e5
docs(tutorials): on an unbalanced panel the ETWFE reference-period re…
igerber Nov 27, 2026
2c1d32c
docs(tutorials): keep the ETWFE reference-period statement to the bal…
igerber Nov 27, 2026
1842831
docs(tutorials): ETWFE never-treated reading: the unadjusted balanced…
igerber Nov 27, 2026
1792297
docs(tutorials): qualify the fallback-reference example and its warni…
igerber Nov 27, 2026
3b6b416
docs(tutorials): say when the reference-move warning names the replac…
igerber Nov 27, 2026
7332329
docs(tutorials): time-varying ETWFE covariates must be strictly exoge…
igerber Nov 27, 2026
b9874db
docs(tutorials): time-varying ETWFE covariates need strict exogeneity…
igerber Nov 27, 2026
9384eca
docs(tutorials): a treatment-affected covariate can distort the total…
igerber Nov 27, 2026
f6345a1
docs(tutorials): state the Poisson mpdta result without ranking it ag…
igerber Nov 27, 2026
9eed0da
test(tutorials): run notebook 10's singular-value cell on a zero matr…
igerber Nov 27, 2026
964268e
docs(tutorials): not-yet-treated ContinuousDiD still needs never-trea…
igerber Nov 27, 2026
d6ef093
test(tutorials): keep the ContinuousDiD never-treated check out of th…
igerber Nov 27, 2026
dad1115
docs(tutorials): lowest-dose ContinuousDiD does not take covariates (14)
igerber Nov 27, 2026
84b6c2d
docs(tutorials): leave covariates at None with lowest-dose controls (…
igerber Nov 27, 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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The loader pins this file's SHA-256, and tests feed it to the loader offline:
# keep its bytes identical on every platform (no CRLF conversion on Windows).
benchmarks/data/real/mpdta.csv text eol=lf
25 changes: 23 additions & 2 deletions .github/workflows/rust-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ on:
- 'tools/**'
- 'pyproject.toml'
- '.github/workflows/rust-test.yml'
# The isolated test lanes copy this pinned file and rely on its exact bytes
# (the loader's checksum); a change to it or to its line-ending rule must
# run this suite.
- 'benchmarks/data/real/mpdta.csv'
- '.gitattributes'
# docs-tests.yml / notebooks.yml / ci-gate.yml carry ready-for-ci label
# contracts locked by TestCiWorkflowLabelEventGuard in
# tests/test_openai_review.py; include them so a regression there triggers
Expand Down Expand Up @@ -57,6 +62,11 @@ on:
- 'tools/**'
- 'pyproject.toml'
- '.github/workflows/rust-test.yml'
# The isolated test lanes copy this pinned file and rely on its exact bytes
# (the loader's checksum); a change to it or to its line-ending rule must
# run this suite.
- 'benchmarks/data/real/mpdta.csv'
- '.gitattributes'
# docs-tests.yml / notebooks.yml / ci-gate.yml carry ready-for-ci label
# contracts locked by TestCiWorkflowLabelEventGuard in
# tests/test_openai_review.py; include them so a regression there triggers
Expand Down Expand Up @@ -221,11 +231,22 @@ jobs:

- name: Copy tests to isolated location (Unix)
if: runner.os != 'Windows'
run: cp -r tests /tmp/tests
# The pinned mpdta source file goes along, at the path the tests look for
# it relative to their own root, so the canonical-data tests run offline
# here instead of downloading (or skipping when the download fails).
run: |
cp -r tests /tmp/tests
mkdir -p /tmp/benchmarks/data/real
cp benchmarks/data/real/mpdta.csv /tmp/benchmarks/data/real/mpdta.csv

- name: Copy tests to isolated location (Windows)
if: runner.os == 'Windows'
run: Copy-Item -Recurse tests $env:RUNNER_TEMP\tests
# .gitattributes pins the mpdta file to LF, so the copy has the bytes the
# loader's checksum expects on Windows too.
run: |
Copy-Item -Recurse tests $env:RUNNER_TEMP\tests
New-Item -ItemType Directory -Force -Path $env:RUNNER_TEMP\benchmarks\data\real | Out-Null
Copy-Item benchmarks\data\real\mpdta.csv $env:RUNNER_TEMP\benchmarks\data\real\mpdta.csv
shell: pwsh

- name: Run Rust backend tests (Unix)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Full guide: `diff_diff.get_llm_guide("practitioner")`.
- [CallawaySantAnna](https://diff-diff.readthedocs.io/en/stable/api/staggered.html) - Callaway & Sant'Anna (2021) group-time ATT estimator for staggered adoption
- [ChaisemartinDHaultfoeuille](https://diff-diff.readthedocs.io/en/stable/api/chaisemartin_dhaultfoeuille.html) - de Chaisemartin & D'Haultfœuille (2020/2022) for **reversible (non-absorbing) treatments** with multi-horizon event study, normalized effects, cost-benefit delta, sup-t bands, and dynamic placebos. The most general option for treatments that switch on AND off (see also `LPDiD`/`TROP` `non_absorbing`). Alias `DCDH`.
- [SunAbraham](https://diff-diff.readthedocs.io/en/stable/api/staggered.html) - Sun & Abraham (2021) interaction-weighted estimator for heterogeneity-robust event studies
- [ImputationDiD](https://diff-diff.readthedocs.io/en/stable/api/imputation.html) - Borusyak, Jaravel & Spiess (2024) imputation estimator, most efficient under homogeneous effects
- [ImputationDiD](https://diff-diff.readthedocs.io/en/stable/api/imputation.html) - Borusyak, Jaravel & Spiess (2024) imputation estimator, robust to effect heterogeneity and efficient under spherical errors
- [TwoStageDiD](https://diff-diff.readthedocs.io/en/stable/api/two_stage.html) - Gardner (2022) two-stage estimator with GMM sandwich variance
- [SpilloverDiD](https://diff-diff.readthedocs.io/en/stable/api/spillover.html) - Butts (2021) ring-indicator spillover-aware DiD identifying direct effect on treated + per-ring spillover on near-control units; handles non-staggered and staggered timing; supports survey-design variance under `survey_design=` for HC1 / CR1 (Wave E.1 Binder TSL) and Conley (Wave E.2 panel-aware stratified-Conley sandwich on per-period PSU totals; extended in Wave E.2 follow-up to `conley_lag_cutoff > 0` via panel-block composition with within-PSU serial Bartlett HAC — `lag>0` requires an effective PSU via explicit `survey_design.psu` or injected `cluster=<col>`); `SurveyDesign.subpopulation()` preserves full-design `n_psu` / `df_survey` via zero-padded scores (Wave E.3, R `svyrecvar(subset())` form)
- [SyntheticDiD](https://diff-diff.readthedocs.io/en/stable/api/estimators.html) - Synthetic DiD combining standard DiD and synthetic control for few treated units
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Related tracking surfaces:
| `plot_event_study` rejects the unified `EVENT_STUDY_SCHEMA` frame that every `to_dataframe(level="event_study")` returns (`ValueError: DataFrame must have 'period' column`; the DataFrame branch accepts only `period`/`effect`/`se`). Accepting it needs two decisions first: which level the stored `conf_int_*` are drawn at when the frame carries no `alpha` to compare with the caller's, and how multiple `is_reference` rows map onto the container route's row-aligned marking. Plot the container (`results.aggregate('event_study')`) in the meantime. | `visualization/_event_study.py` | 4.0 tutorial review | Mid | Low |
| `WooldridgeDiDResults.to_dataframe(level="group" / "calendar" / "simple")` names its interval columns `conf_int_lo` / `conf_int_hi`, while its own `level="event_study"` frame and every other results class use `conf_int_lower` / `conf_int_upper`. A public column rename, so it needs a deprecation-ledger row and a transition release. | `wooldridge_results.py` | 4.0 tutorial review | Mid | Low |
| `ChangesInChanges.fit(time=)` takes the 0/1 post indicator, while the 2x2 estimators take that indicator as `post=` and reserve `time=` for the calendar column (the 4.0 TWFE split). Tutorial 27 shows the two side by side. Resolving it is a keyword rename with a ledger row. | `changes_in_changes.py` | 4.0 tutorial review | Mid | Low |
| TROP convergence defaults: on the tutorial-10 panels the default `max_iter=100` leaves most per-observation fits unconverged (the aggregated warning fires on essentially every fit), and the warning text reads "... fits did not converge did not converge in 100 iterations" because the callers pass a method name that already ends in "did not converge" to `warn_if_not_converged`. Fix the wording at the three call sites; separately assess whether the default iteration cap or tolerance should change (needs a convergence study on the paper's designs, not just the tutorial). | `trop.py`, `trop_local.py`, `trop_global.py`, `utils.py` | 4.0 tutorial review | Mid | Low |
| TROP convergence defaults: on the tutorial-10 panels the default `max_iter=100` leaves most per-observation fits unconverged (the aggregated warning fires on essentially every fit), and the warning text reads "... fits did not converge did not converge in 100 iterations" because the callers pass a method name that already ends in "did not converge" to `warn_if_not_converged`. Fix the wording at the three call sites; make the two backends report cross-validation non-convergence alike (on the tutorial-10 panel the pure-Python search warns that 43 of 252 leave-one-out fits at a candidate penalty hit `max_iter=500`, the Rust search reports nothing, and both select the same penalties); separately assess whether the default iteration cap or tolerance should change (needs a convergence study on the paper's designs, not just the tutorial). | `trop.py`, `trop_local.py`, `trop_global.py`, `utils.py` | 4.0 tutorial review | Mid | Low |
| `ImputationDiDResults.pretrend_test()` emits pandas' `Pandas4Warning` ("The inplace keyword in DataFrame.drop is deprecated", PDEP-8) on pandas 3.1: three `drop(..., inplace=True)` calls in the lead-regression path. Rebind instead of dropping in place, and grep the package for the remaining `inplace=True` uses in the same pass. | `imputation_aggregation.py` | 4.0 tutorial review | Quick | Low |
| Conley bandwidth diagnostic: when `conley_cutoff_km` covers the whole treated set (one treated spatial cluster inside the bandwidth), the spatial-HAC meat collapses and the SE falls far below HC1 on data with no spatial correlation (tutorial 23's panel: HC1 0.117; Conley 0.117 at 0.5 km, 0.090 at 25 km, 0.062 at 100 km). This is the usual large-bandwidth HAC degeneracy, not a variance bug, but nothing warns. Candidate: a `UserWarning` when the share of treated-treated pairs inside the cutoff exceeds a threshold; the threshold needs a small simulation to choose. | `conley.py`, `spillover.py` | 4.0 tutorial review | Mid | Low |
| No public idiom for a static staggered TWFE with a time-varying covariate (`Y ~ D_it + X_it` with unit and calendar fixed effects): `TwoWayFixedEffects.fit` is 2x2-shaped in static mode and `decompose()` takes no covariates, so tutorial 33's "include the bad control" benchmark builds it from `within_transform` plus `solve_ols`. Either document that route as the supported one or add a staggered static mode. | `twfe.py`, `docs/tutorials/33_bad_controls.ipynb` | 4.0 tutorial review | Mid | Low |
Expand Down
70 changes: 70 additions & 0 deletions changelog.d/20261125-tutorials-staggered-family.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
### Documentation
- **Staggered-estimator tutorials repaired and brought to the tutorial
conventions** (`10_trop`, `11_imputation_did`, `12_two_stage_did`,
`13_stacked_did`, `14_continuous_did`, `15_efficient_did`,
`16_wooldridge_etwfe`). Each now states what it estimates and assumes before
the first fit, checks estimates against a stated truth, and is committed
with executed outputs and a drift test. Corrections of substance:
- `10`: every fit used the default iteration cap and did not converge on the
tutorial's data; the fits now converge and the cap is explained. The claim
that TROP recovers the effect where Synthetic DiD is biased, which the
notebook's own numbers contradicted, is replaced by a comparison across
simulated panels with TROP cross-validated on each: DiD is unreliable
under factor confounding, and TROP and Synthetic DiD have similar observed
errors in that design. The five-draw Monte Carlo, the duplicated Summary and the
stale plot annotation are gone. The time weights are described as centred on
the period of the observation being predicted, not on the adoption date,
and `effective_rank` and `factor_matrix` as properties of the average of
the per-observation fits.
- `11`, `12`, `13`: the simulated data used the generator's default of
effects that grow over time while every table was labelled "True effect =
2.0" (the true average was about 2.42); the generator is now called with a
constant effect, so the stated truth is the truth.
- `11`: Imputation DiD is no longer described as efficient "under
homogeneous effects". It is unbiased under arbitrary effect heterogeneity,
and efficient under spherical errors (equal variance, uncorrelated across
units and periods). The pre-test result (Proposition 9) is stated for the
pre-treatment coefficients, with independence only under normal errors, and
the Callaway-Sant'Anna alternative for suspect early periods is named as the
never-treated one.
- `12`: the pre-treatment coefficients the prose described are now produced
(`pretrends=True`); the comparison with Imputation DiD separates what is
identical (the overall ATT and the post-treatment point estimates) from
what differs (standard errors, and the pre-treatment coefficients).
- `13`: the overall estimate is stated to be an average over the event
window; the clustering section no longer claims `unit_subexp` gives
narrower standard errors (it gives wider ones in the example); clean
control definitions are no longer ranked by "strength of identification".
- `14`: the removed `overall_att` name is gone; strong parallel trends is
described as an assumption about outcomes under treatment (no selection
into dose on gains), which the old text mis-stated as the standard
assumption. `control_group="lowest_dose"` is described with its
requirements and with what it identifies: effects relative to the
lowest-dose group, causal as a dose effect only under strong parallel
trends.
- `15`: the comparison set under PT-All is described correctly; the
hard-coded "condition number > 100" flag, which marked most of the
tutorial's own cells, is gone; `EfficientDiD.hausman_pretest` is shown.
- `16` (Wooldridge): ETWFE and Callaway-Sant'Anna are compared on the same
control group and the same pre-treatment reference period, where they
coincide at every event time on a balanced panel without covariates; the
comparison cell stops if the two event studies do not cover the same event
times; the `mpdta` section prints the data's provenance, labels its
intervals as county-clustered and adds a state-clustered fit (minimum
wages are set by states: SE 0.019 against 0.013); the Poisson and logit
examples gain a truth check.
- Event studies in `14`, `15` and `16` are drawn with `plot_event_study`.
- Links to the Pre-Trends Power and Honest DiD tutorials now say which fit
those diagnostics take: they reject the event studies of Imputation,
Two-Stage, Continuous, Efficient and Wooldridge fits, so the notebooks name
a `CallawaySantAnna(base_period="universal")` fit of the same data. `13`
explains why its asymmetric window leaves the estimate unchanged.
- **Imputation DiD efficiency condition corrected across the documentation**
(README, the three `llms` guides, the estimator-choice page, references and
the API pages): efficient under spherical errors (equal variance,
uncorrelated across units and periods) and robust to effect heterogeneity, not "efficient under homogeneous
effects". The statement is scoped to the unweighted fit: with survey weights
the first stage is weighted least squares. The Two-Stage API page's comparison table no longer says the
two-stage and imputation estimators are consistent only under homogeneity.
- The `did2s` reference (Butts & Gardner 2022) is cited as *The R Journal*
14(3), not 14(1).
2 changes: 1 addition & 1 deletion diff_diff/guides/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ results.print_summary()

### ImputationDiD

Borusyak-Jaravel-Spiess (2024) imputation DiD estimator. Efficient estimator producing shorter CIs than CS/SA under homogeneous effects.
Borusyak-Jaravel-Spiess (2024) imputation DiD estimator. Unbiased under arbitrary treatment-effect heterogeneity; the minimum-variance linear unbiased estimator under spherical errors: equal variance, uncorrelated across units and periods (Theorem 1, for the unweighted fit; not established with `survey_design=` weights, where the first stage is weighted least squares). Its reported CIs are often, not always, shorter than CS/SA. Assumes parallel trends in all periods.

```python
ImputationDiD(
Expand Down
2 changes: 1 addition & 1 deletion diff_diff/guides/llms-practitioner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Is treatment adoption staggered (multiple cohorts, different timing)?
|-- YES: Do NOT use plain TWFE. Use one of:
| |-- CallawaySantAnna (CS) -- most general, doubly robust, recommended default
| |-- SunAbraham (SA) -- interaction-weighted, good for event studies
| |-- ImputationDiD (BJS) -- most efficient under homogeneous effects
| |-- ImputationDiD (BJS) -- uses all untreated obs; efficient under spherical errors
| |-- TwoStageDiD -- two-stage with GMM variance
| |-- StackedDiD -- sub-experiment approach
| |-- EfficientDiD (EDiD) -- optimal weighting for tighter SEs
Expand Down
2 changes: 1 addition & 1 deletion diff_diff/guides/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The site is organized into 5 sections, each with a landing page:
- [CallawaySantAnna](https://diff-diff.readthedocs.io/en/stable/api/staggered.html): Callaway & Sant'Anna (2021) group-time ATT estimator for staggered adoption with aggregation; `vcov_type="jackknife"` gives cluster-jackknife (CV3) inference for few clusters (Karim, Nielsen, MacKinnon & Webb 2026)
- [ChaisemartinDHaultfoeuille](https://diff-diff.readthedocs.io/en/stable/api/chaisemartin_dhaultfoeuille.html): de Chaisemartin & D'Haultfœuille (2020/2022) estimator for **reversible (non-absorbing) treatments** with multi-horizon event study (`L_max`), normalized effects, cost-benefit delta, sup-t bands, and dynamic placebos. The most general option for treatments that switch on AND off (LPDiD/TROP `non_absorbing` also handle non-absorbing treatment under stronger assumptions). Alias `DCDH`.
- [SunAbraham](https://diff-diff.readthedocs.io/en/stable/api/staggered.html): Sun & Abraham (2021) interaction-weighted estimator for heterogeneity-robust event studies
- [ImputationDiD](https://diff-diff.readthedocs.io/en/stable/api/imputation.html): Borusyak, Jaravel & Spiess (2024) imputation estimator — most efficient under homogeneous effects
- [ImputationDiD](https://diff-diff.readthedocs.io/en/stable/api/imputation.html): Borusyak, Jaravel & Spiess (2024) imputation estimator — robust to effect heterogeneity; efficient under spherical errors
- [TwoStageDiD](https://diff-diff.readthedocs.io/en/stable/api/two_stage.html): Gardner (2022) two-stage estimator with GMM sandwich variance
- [SpilloverDiD](https://diff-diff.readthedocs.io/en/stable/api/spillover.html): Butts (2021) ring-indicator spillover-aware DiD identifying direct effect on treated + per-ring spillover-on-control; reuses `conley_coords` for ring construction; handles non-staggered and staggered timing; supports `SurveyDesign(weights, strata, psu, fpc)` under `vcov_type="hc1"` with optional `cluster=<col>` for CR1 via Gerber (2026) Binder TSL (Wave E.1) and under `vcov_type="conley"` via a panel-aware stratified-Conley sandwich on per-period PSU totals (Wave E.2 cross-sectional `conley_lag_cutoff=0`) extended in Wave E.2 follow-up to `conley_lag_cutoff > 0` via panel-block composition with within-PSU serial Bartlett HAC (Newey-West 1987 separable form; `lag>0` requires an effective PSU via explicit `survey_design.psu` or injected `cluster=<col>`), both composed with the Wave D Gardner GMM correction; `SurveyDesign.subpopulation()` preserves full-design `n_psu` / `df_survey` via zero-padded scores at the meat-helper boundary (Wave E.3, R `svyrecvar(subset())` form) (replicate weights queued as follow-up)
- [SyntheticDiD](https://diff-diff.readthedocs.io/en/stable/api/estimators.html): Synthetic DiD combining standard DiD and synthetic control methods for few treated units
Expand Down
14 changes: 10 additions & 4 deletions diff_diff/imputation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ class ImputationDiD(ImputationDiDBootstrapMixin, _ImputationAggregationMixin, Ba
"""
Borusyak-Jaravel-Spiess (2024) imputation DiD estimator.

This is the efficient estimator for staggered Difference-in-Differences
under parallel trends. It produces shorter confidence intervals than
Callaway-Sant'Anna (~50% shorter) and Sun-Abraham (2-3.5x shorter)
under homogeneous treatment effects.
Unbiased for staggered Difference-in-Differences under parallel trends and
no anticipation, with unrestricted treatment-effect heterogeneity. It is the
efficient linear unbiased estimator under spherical errors (equal variance,
uncorrelated across units and periods; Theorem 1): no other linear unbiased
estimator of the same target has a smaller variance. The theorem is for the
unweighted fit: with ``survey_design=`` weights the untreated model is fitted
by weighted least squares and spherical errors alone do not give that
guarantee. Reported confidence intervals are often shorter than
Callaway-Sant'Anna's or Sun-Abraham's as a result, but their width also
depends on the variance estimator.

The estimation procedure:
1. Run OLS on untreated observations to estimate unit + time fixed effects
Expand Down
Loading
Loading