Skip to content

docs(tutorials): repair and conform the Staggered family tutorials (10-15, 16 Wooldridge), with drift tests - #920

Open
igerber wants to merge 29 commits into
mainfrom
docs/tutorials-staggered-family
Open

igerber wants to merge 29 commits into
mainfrom
docs/tutorials-staggered-family

Conversation

@igerber

@igerber igerber commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fourth PR of the post-4.0 tutorial repair (after #906, #911 and #916). Documentation and tests, plus one CI workflow change (below): the StackedDiD anticipation and survey fixes that were first folded in here landed separately in #923, and this branch is now rebuilt on top of it. Fixes the defects found in the staggered-estimator tutorials and brings each to the tutorial conventions in CONTRIBUTING.md, keeping each notebook's own narrative. Every notebook is committed with executed outputs (Rust backend) and has a drift test that pins the numbers its prose quotes.

  • 10_trop: the bias bound is scoped to a single treated block with fixed weights, no spillovers is stated as an assumption, and on/off treatment states its no-carryover requirement. 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: DiD is unreliable under factor confounding, and TROP and Synthetic DiD have similar observed errors in that design. 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, which says nothing about the rank of any single fit; the singular-value cell handles a factor matrix shrunk to zero.
  • 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: 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_two_stage_did: the pre-treatment coefficients the prose described are now produced (pretrends=True); the comparison with Imputation DiD separates what is identical (the overall and post-treatment estimates) from what differs (standard errors, and the pre-treatment coefficients).
  • 13_stacked_did: 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". The weighting section follows fix(stacked_did): complete event windows and equal cohort shares on both arms (all weightings, survey weights) #914: under "population" and "sample_share" treated rows are reweighted as well as controls, and the two estimates in that table are the corrected ones (1.960 and 1.939, previously 1.948 and 1.915). The population column is described as per-unit, with the implied cohort weights stated (24%, 61%, 15%). The clean-control section gives the rule under anticipation, as implemented in fix(stacked_did): anticipation-aware clean controls and survey-inference fixes #923, and the anticipation section says the event window grows by the anticipation periods and can trim a cohort.
  • 14_continuous_did: the removed overall_att name is gone; strong parallel trends is described as an assumption about outcomes under treatment, which the old text mis-stated as the standard assumption. The claim that a binary Callaway-Sant'Anna fit returns the same overall ATT is limited to one cohort: on the notebook's two-cohort panel the two give 4.707 and 4.674, because they weight cohort-period effects differently, which is now shown. The Honest DiD pointer names a universal-base binary fit, since a ContinuousDiD event study is not accepted there. The identification table gains the own-dose effect ATT(d|d), which parallel trends alone identifies with an untreated comparison group, and control_group="lowest_dose" is described with its requirements and with what it rebases (effect levels, not the slope). The overall ATT is said to be independent of the spline only while the same cohort-period cells are kept (a three-unit cohort is estimated under a linear spline and skipped under a cubic one, moving it from 4.638 to 4.608), and a binary analysis is said to keep its cohort-period and event-study summaries while losing the dose-response curve. The not_yet_treated option is said to still need never-treated units, and lowest_dose to need covariates left at None.
  • 15_efficient_did: 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; each PT-All comparison is described as two changes through a baseline period.
  • 16_wooldridge_etwfe: ETWFE and Callaway-Sant'Anna are compared on the same control group and the same pre-treatment reference period (base_period="universal"), where they coincide at every event time on a balanced panel without covariates (on an unbalanced version of the tutorial panel they differ by 0.004 at one event time); the comparison cell stops if the two event studies do not cover the same event times; the mpdta section prints the data's provenance and skips its fits when the loader returns simulated data, labels its intervals as county-clustered (the jwdid benchmark) and adds a state-clustered fit, since minimum wages are set by states (same estimate, SE 0.019 against 0.013), and says which cohorts each event-study horizon averages (event times 2 and 3 are the 2004 cohort alone, 20 counties in one state); the Poisson and logit examples gain a truth check, and the mpdta Poisson result is stated with its county-clustered interval and no precision ranking against the log fit. Placebo coefficients and the never-treated advice are scoped to the linear model. The reading of a never-treated coefficient as a difference-in-differences against the reference period is stated for a balanced panel without covariates; gaps in the panel or time-varying covariates can let outcomes in other periods move the post-treatment coefficients (on a three-period example an early shock moves the estimate from 2.0 to -0.5 once one row is missing), and with gaps the fit needs missingness to be unrelated to the idiosyncratic outcome shocks. Time-varying covariates are said to need strict exogeneity and to be unaffected by treatment, with parallel trends then conditional on them; Poisson and logit are described with cohort and period effects; the reference period on an unbalanced panel is stated correctly.
  • 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 notebooks 11, 12, 14, 15 and 16 name a CallawaySantAnna(base_period="universal") fit of the same data and say the result describes that fit. 13 explains why its asymmetric window leaves the point estimates unchanged (same treated units, clean controls, weights and reference period).
  • Imputation DiD efficiency condition corrected across the documentation (README, the three llms guides, the estimator-choice page, references, the API pages and the ImputationDiD docstring). The longer statements scope the guarantee to the unweighted fit: with survey weights the first stage is weighted least squares.
  • The did2s reference (Butts & Gardner 2022) is cited as The R Journal 14(3), not 14(1).
  • tests/test_tutorial_conventions.py: the seven notebooks leave the ratchet allowlist.
  • .github/workflows/rust-test.yml copies the pinned benchmarks/data/real/mpdta.csv next to the isolated tests (Unix and Windows), so the canonical-data tests run offline there, and the workflow now also triggers on changes to that file or to .gitattributes (a checksum mismatch on that file now fails the tutorial's drift tests instead of skipping them); a new .gitattributes entry pins that file to LF so its bytes match the loader's checksum on Windows. The Windows leg was not run locally.
  • TODO.md: the TROP convergence row records that the two backends report cross-validation non-convergence differently (the pure-Python search warns about a candidate penalty, the Rust search does not; both select the same penalties).

No library behavior changes: diff_diff/imputation.py and diff_diff/two_stage.py change in docstrings only.

Methodology references (required if estimator / math changes)

  • Method name(s): N/A - no methodology changes. The corrected efficiency statement for Imputation DiD follows Borusyak, Jaravel & Spiess (2024), Theorem 1, as recorded in docs/methodology/papers/borusyak-jaravel-spiess-2024-review.md.
  • Paper / source link(s): Borusyak, K., Jaravel, X., & Spiess, J. (2024). Revisiting Event-Study Designs: Robust and Efficient Estimation. Review of Economic Studies, 91(6).
  • Any intentional deviations from the source (and why): None

Validation

  • Tests added/updated: new drift tests tests/test_t10_trop_drift.py through tests/test_t16_wooldridge_etwfe_drift.py; tests/test_tutorial_conventions.py updated. At the head, the drift tests, the conventions guard and the docs-structure, changelog, tracking, doc-snippet, workflow-guard and dataset tests pass on the Rust backend (905 passed, slow tests excluded) and the drift tests and the guard pass on the pure-Python backend (185 passed). The slow TROP re-derivations last ran on Rust a few prose and test commits earlier (907 passed with them). The mpdta drift tests feed the loader the committed source file, so the canonical numbers are checked offline, and a checksum mismatch fails them.
  • Backtest / simulation / notebook evidence (if applicable): 13_stacked_did was re-executed on the Rust backend against main after fix(stacked_did): anticipation-aware clean controls and survey-inference fixes #923 and its outputs are unchanged; 16_wooldridge_etwfe was re-executed after its comparison and mpdta cells changed, including the new state-clustered cell. 10_trop was re-executed after its singular-value cell changed; every output is identical. Notebooks 11-15 and 16 (Wooldridge) pass pytest --nbmake on the pure-Python backend. 10_trop is excluded from that CI job for runtime and was executed on the Rust backend. The Sphinx -W build and the search-excerpt smoke test pass locally.

Security / privacy

  • Confirm no secrets/PII in this PR: Yes

Changelog

  • changelog.d/ fragment added (or N/A - no user-visible change): Yes (changelog.d/20261125-tutorials-staggered-family.md, ### Documentation)

@github-actions

Copy link
Copy Markdown

Overall assessment

✅ Looks good — no unmitigated P0 or P1 findings. One P3 documentation clarification.

Executive summary

  • Library changes affect docstrings only; estimator calculations and defaults are unchanged.
  • Methodology corrections align with the Registry and checked-in paper reviews, including BJS efficiency conditions, continuous-treatment identification, stacked weights, and ETWFE reference periods.
  • All seven notebooks pass the nine static convention rules without allowlist exemptions.
  • All 37 literal output quotes checked against the new drift tests match committed outputs.
  • Numerical tests could not run: the environment lacks pytest, NumPy, pandas, and SciPy.
  • The required changelog fragment is present.

Methodology

P3 — Qualify the never-treated control advice as OLS-only.

Location: docs/tutorials/16_wooldridge_etwfe.ipynb:L76-L84, docs/tutorials/16_wooldridge_etwfe.ipynb:L812-L815

Impact: The closing advice recommends "never_treated" when early pre-treatment periods are suspect, immediately after discussing nonlinear models. For Poisson and logit, this setting still uses treated units’ pre-treatment observations and produces no placebo cells. Readers could incorrectly infer that switching control groups relaxes those models’ pre-treatment assumptions.

This behavior is explicitly documented in docs/methodology/REGISTRY.md:L2707, so it is informational and does not block approval.

Concrete fix: Label the control-group distinction and closing recommendation as applying to method="ols", and add one sentence explaining the nonlinear behavior.

Code Quality

No findings. No new production inference calculations, parameter propagation, or NaN-handling paths are introduced.

Performance

No findings. Expensive TROP re-derivations carry the slow marker, and the tutorial explains its runtime.

Maintainability

No findings. The drift tests use the shared notebook helpers, and repaired notebooks leave the convention allowlist.

Tech Debt

No new untracked concern identified. Existing TROP convergence-default limitations are tracked in TODO.md:L83.

Security

No findings in the reviewed changes.

Documentation/Tests

No additional findings. Notebook code parses, execution counts are sequential, and committed outputs contain no errors. Static convention checks and output-quote checks passed; numerical re-derivation remains unverified in this environment.

@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 054d32b2de86a6943f86750fd344d14d1e3a69a0


Overall assessment

✅ Looks good. The prior ETWFE finding is resolved in the assumptions and closing guidance. The remaining findings concern documentation accuracy and are P2 or P3.

Executive summary

  • Tutorial 16 now explains that Poisson and logit use treated units’ pre-treatment observations under either control setting. Its summary and comparison table still need the OLS qualifier.
  • The Imputation DiD documentation correctly identifies spherical errors as the efficiency condition. Several passages still turn the point-estimator result into a guarantee of shorter confidence intervals.
  • The library changes are confined to docstrings and references. The revised examples follow the Registry on stacked Q-weights and on the shared control group and reference period used to compare linear ETWFE with Callaway–Sant’Anna.
  • All seven notebooks passed the static convention checks, and all 37 literal output quotes matched the committed outputs. Numerical re-derivations remain unverified in this environment.

Methodology

  • P2 — Distinguish Imputation DiD efficiency from confidence interval width.
    Impact — BJS Theorem 1 minimizes the true variance among linear unbiased estimators of the same target under spherical errors. Reported interval widths also depend on the variance estimator and critical value. The revised docstring and guides can be read as promising shorter intervals whenever errors are spherical.
    Concrete fix — State the minimum-variance result in the docstring and guides. Describe shorter intervals as an observed result in Tutorial 11 or a possible precision gain in the estimator guide.
    diff_diff/imputation.py:L70-L82, diff_diff/guides/llms-full.txt:L445, docs/api/imputation.rst:L18-L25, docs/choosing_estimator.rst:L31-L36, docs/choosing_estimator.rst:L515-L519, docs/methodology/papers/borusyak-jaravel-spiess-2024-review.md:L51-L62

  • P3 — Carry the OLS qualifier into the ETWFE summary and comparison table.
    Impact — Readers consulting those sections can still expect placebo coefficients from Poisson or logit with "never_treated". The assumptions and closing advice now explain the documented behavior correctly.
    Concrete fix — Specify method="ols" in both remaining descriptions of the placebo coefficients.
    docs/tutorials/16_wooldridge_etwfe.ipynb:L83-L88, docs/tutorials/16_wooldridge_etwfe.ipynb:L588-L594, docs/tutorials/16_wooldridge_etwfe.ipynb:L795-L805, docs/methodology/REGISTRY.md:L2707

Code Quality

No findings.

Performance

No findings. The expensive TROP numerical checks are marked slow.

Maintainability

No findings. The drift tests reuse the shared notebook helpers, and the seven notebooks leave the convention allowlist.

Tech Debt

  • P3 — TROP’s default iteration cap is tracked in TODO.md.
    Impact — The default cap can leave these tutorial fits unconverged. The tutorial uses max_iter=500 and explains the warning.
    Concrete fix — Resolve the default-cap behavior through the existing backlog item.
    TODO.md:L83, docs/tutorials/10_trop.ipynb:L194-L199

Security

No findings in the reviewed changes.

Documentation/Tests

  • P3 — Label the Imputation DiD lead standard errors accurately.
    Impact — Tutorial 12 labels the entire Imputation DiD column conservative SE, although the lead rows use cluster-robust standard errors from the separate untreated-only regression. Its summary also implies that the lead point estimates agree, while the comparison correctly shows they differ.
    Concrete fix — Rename the column Imputation SE and scope the summary’s equality claim to the overall ATT and post-treatment coefficients.
    docs/tutorials/12_two_stage_did.ipynb:L364-L390, docs/tutorials/12_two_stage_did.ipynb:L439-L446, docs/methodology/REGISTRY.md:L2302-L2315

  • P3 — Use the observed RMSEs consistently in the TROP recap.
    Impact — The comparison calls the methods equally accurate, while the recap says Synthetic DiD was more accurate. The 12 simulated panels yielded similar observed RMSEs of 0.325 for Synthetic DiD and 0.332 for TROP.
    Concrete fix — Use “similar observed RMSEs” in both places and retain the two values.
    docs/tutorials/10_trop.ipynb:L543-L550, docs/tutorials/10_trop.ipynb:L647-L655

The changelog fragment passed the repository’s fragment check. I used the supplied diff for scope because the checkout is shallow. The environment lacked pytest and the scientific Python dependencies, so verification covered notebook syntax, static conventions, prose assertions, and committed output quotes.

@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 6cb98dd799c2f48147cf171510638ebb190a8fb9


Overall assessment

⛔ Blocker. A newly identified Stacked DiD control-selection bug can silently bias the ATT when anticipation is positive. The issue predates this PR and affects the workflow taught in the revised Tutorial 13.

Executive summary

  • Stacked DiD can use a later cohort as a control after that cohort has begun responding to treatment. In a balanced example with a true ATT of 2.0, the current cutoff gives 1.875.
  • The four prior findings are addressed in the reviewed passages. Imputation DiD separates estimator efficiency from interval width, ETWFE scopes placebo coefficients to OLS, Tutorial 12 scopes its equality claim to treatment effects, and TROP consistently reports similar observed RMSEs.
  • The PR changes library docstrings, tutorial examples, and tests. The Stacked DiD issue is in the existing estimator code.
  • All seven notebooks passed static convention and syntax checks, all 38 pinned output quotes matched, and the changelog fragment passed validation.

Methodology

  • P0 [Newly identified] — Stacked DiD can admit controls that are already affected by anticipation.
    Impact. The eligibility check and stack builder both use the recorded adoption date. With anticipation=1, kappa_pre=2, and kappa_post=2, cohort 6 enters cohort 3’s window as a control through period 5, even though cohort 6 starts responding in period 5. With equal-sized cohorts 3, 6, and never treated, and an effect of 2 starting one period before adoption, Wing et al.’s weighted contrasts give 1.5 at event time 2 and 1.875 overall. The true effect is 2 at every included horizon. The fit has no warning for this contamination, and the tutorial’s no-anticipation simulation leaves it untested.
    Concrete fix. Use first_treat - anticipation for later-control eligibility in both the inclusion check and stack construction. Preserve the additional separation required by "strict". Update Tutorial 13 and add a regression test with genuine anticipatory effects.
    docs/tutorials/13_stacked_did.ipynb:L450-L458, docs/tutorials/13_stacked_did.ipynb:L559-L564, diff_diff/stacked_did.py:L1598-L1606, diff_diff/stacked_did.py:L1666-L1693, docs/methodology/REGISTRY.md:L2499-L2523, tests/test_t13_stacked_did_drift.py:L183-L190

  • P2 — Clarify the PT-All comparisons in Tutorial 15.
    Impact. The assumptions section describes the never-treated group or “another cohort” as the comparison. Chen, Sant’Anna & Xie’s Eq. 3.9 uses never-treated units for the change from the intermediate baseline to the target period. The comparison cohort supplies the earlier change and can be the target cohort itself, as the tutorial’s own ATT(5, 6) example shows.
    Concrete fix. Describe the two changes used to construct the counterfactual trend and explicitly include the target cohort among the eligible comparison cohorts for the earlier change.
    docs/tutorials/15_efficient_did.ipynb:L66-L75, docs/tutorials/15_efficient_did.ipynb:L524-L529, diff_diff/efficient_did_weights.py:L578-L588, docs/methodology/papers/chen-santanna-xie-2025-review.md:L84-L95

Code Quality

No findings.

Performance

No findings. The expensive TROP re-derivations are marked slow.

Maintainability

No findings.

Tech Debt

  • P3 — TROP’s default iteration cap is tracked in TODO.md.
    Impact. The default cap can leave the tutorial fits unconverged. The tutorial uses max_iter=500 and explains the convergence warning.
    Concrete fix. Evaluate the default cap and correct the warning text through the existing backlog item.
    TODO.md:L83, docs/tutorials/10_trop.ipynb:L194-L199

Security

No findings in the reviewed changes.

Documentation/Tests

  • P3 — Scope the Two-Stage DiD equality claim in the changelog.
    Impact. The corrected notebook limits equality with Imputation DiD to the overall ATT and post-treatment coefficients. The changelog still calls the point estimates identical without that qualifier, although the lead coefficients differ.
    Concrete fix. Replace “point estimates” with “overall ATT and post-treatment point estimates” and state that the lead coefficients differ.
    changelog.d/20261125-tutorials-staggered-family.md:L24-L27, docs/tutorials/12_two_stage_did.ipynb:L439-L446

Path to Approval

  1. Apply the same anticipation-aware control rule during cohort inclusion and stack construction, then update Tutorial 13’s clean-control definitions.
  2. Add a balanced periods 0–8 regression test with equal-sized cohorts adopting at 3 and 6 and a never-treated group, with an effect of 2 starting at g - 1. Assert that cohort 6 is excluded from cohort 3’s control pool and that both the event-time-2 ATT and the overall ATT equal 2.

I used the supplied diff for scope because the checkout lacks the prior reviewed commit. The Stacked DiD counterexample was verified from the current selection predicate and the weighted cell contrasts. Full estimator and notebook reruns remained unverified because the environment lacked pytest and the scientific Python dependencies.

@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 011e6479dbc867885a45eec27b2b0d7a65f7a807


Overall assessment

⛔ Blocker. The prior Stacked DiD point-estimate bug is fixed. The new cutoff can also remove sampled primary sampling units (PSUs) from the survey variance calculation, producing incorrect standard errors and confidence intervals.

Executive summary

  • Stacked DiD now excludes controls whose anticipation window overlaps the focal event window. The original regression case gives 2.0 at event time 2 and 2.0 overall.
  • Under the new strict cutoff, a stratified census can be treated as a partial sample. In the case below, this yields a standard error of 0.136 and 9 survey degrees of freedom, versus a design-based standard error of zero and 15 degrees of freedom.
  • The reports distinguish current fits from legacy results. The prior Tutorial 15 comparison-set finding and Tutorial 12 changelog finding are addressed.
  • Static checks passed for all seven tutorials, including 40 pinned output strings. The changelog fragment passed validation.

Methodology

  • P0 [Newly identified] — The anticipation cutoff can invalidate Stacked DiD survey inference.
    Impact. Consider a balanced panel over periods 0–8 with cohorts adopting at 3 and 8 and a never-treated group. Use control_group="strict", kappa_pre=kappa_post=2, and anticipation=1. Cohort 8’s own window ends at 10, so both versions trim it as a treated cohort. The old cutoff admits it as a control for cohort 3, whose window ends at 5. The new cutoff excludes it entirely. With three strata, two single-unit PSUs per cohort per stratum, and an FPC population size of six per stratum, the survey code re-resolves the stack with four of six PSUs per stratum. It applies a sampling fraction of 4/6 to a census. With cohort 3’s effects alternating between 1.5 and 2.5 within each stratum, the resulting overall SE is 0.136 with 9 df. Full-design Taylor linearization gives SE 0 with 15 df. Both versions emit the same cohort-trimming warning. TODO.md tracks the underlying survey-design defect, and this cutoff creates a new case that triggers it.
    Concrete fix. Preserve the original survey design for the variance and inference calculations and assign zero score contributions to PSUs outside the stack. If full-design inference is deferred, raise NotImplementedError before returning inference when the adjusted cutoff removes sampled PSUs entirely.
    diff_diff/stacked_did.py:L1194-L1224, diff_diff/stacked_did.py:L1604-L1622, diff_diff/survey.py:L1507-L1526, docs/methodology/REGISTRY.md:L8416-L8441, TODO.md:L60

  • P3 informational — The anticipation-adjusted control rule is documented.
    Impact. Wing, Freedman & Hollingsworth’s Assumption 1 rules out anticipation. The Registry documents the extension and its effective treatment date, A_s - anticipation. The shared cutoff now governs both cohort inclusion and stack construction.
    Concrete fix. No action required for the cutoff itself.
    docs/methodology/REGISTRY.md:L2497-L2508, docs/methodology/REGISTRY.md:L2636, diff_diff/stacked_did.py:L1604-L1622, diff_diff/stacked_did.py:L1677-L1684

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 informational — TROP’s default iteration cap is tracked in TODO.md.
    Impact. The default cap can leave the tutorial fits unconverged. The tutorial uses max_iter=500 and explains the warning.
    Concrete fix. Evaluate the default cap and correct the warning text through the existing backlog item.
    TODO.md:L83, docs/tutorials/10_trop.ipynb:L194-L199

Security

No findings.

Documentation/Tests

  • P2 — Tutorial 14 confuses the default dose grid with the observed dose range.
    Impact. The notebook says that doses above the 99th percentile lack data support. Its own example observes doses up to 7.08, while the default grid ends at 4.80. Readers can mistake that grid endpoint for the limit of the observed range when choosing dvals.
    Concrete fix. Describe the 99th percentile as the default evaluation endpoint. Explain that observations above it are sparse and that custom evaluation points should stay within the observed dose range.
    docs/tutorials/14_continuous_did.ipynb:L317-L325, diff_diff/continuous_did_bspline.py:L200-L226

  • P3 — The strict-cutoff explanation overstates the separation between windows.
    Impact. The changelog and Registry describe a gap of kappa_pre periods between the windows. The formula allows the later cohort’s expanded window to begin one period after the focal window closes.
    Concrete fix. Say the strict cutoff keeps the two windows disjoint, matching Tutorial 13.
    changelog.d/20261125-tutorials-staggered-family.md:L14-L19, docs/methodology/REGISTRY.md:L2636, docs/tutorials/13_stacked_did.ipynb:L461-L469

Path to Approval

  1. Preserve full-design survey inference when the adjusted cutoff removes PSUs from the stack, or explicitly reject that case before returning inference.
  2. Add the strict-cutoff census regression above. Assert that cohort 8 is excluded from the control pool. For a supported fit, assert 18 design PSUs, 15 survey df, zero SE, and NaN t-statistic, p-value, and CI bounds. If the case is deferred, assert the targeted NotImplementedError.

I used the supplied diff for review scope because the checkout is shallow. I verified both Stacked DiD cases by executing the selection predicates and calculating the weighted contrasts and survey variance independently. The checkout lacked pytest and the scientific Python dependencies, so full estimator and notebook runs remain unverified. The paper cross-check used the repository’s Methodology Registry and source reviews because the external paper host was unreachable.

@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 426b42b37b427efc3bd7d21adfd3111abbdaf320


Overall assessment

⛔ Blocker. The new guard rejects the strict-cutoff census case from the prior review. A related case still returns a zero standard error when StackedDiD uses unit-by-sub-experiment pairs as survey sampling units.

Executive summary

  • The anticipation-adjusted cutoff excludes controls that can respond during the focal event window. The Methodology Registry records the extension to Wing, Freedman & Hollingsworth (2024).
  • The prior census regression is covered by a targeted NotImplementedError test. With cluster="unit_subexp" and an implicit survey PSU, the revised cutoff can turn a finite-population validation error into a zero SE.
  • Tutorial 14 now distinguishes the dose grid from the observed dose range. Tutorial 15 explains both changes that make up each PT-All comparison. The Registry and changelog now describe the strict windows as disjoint.
  • All seven static notebook convention checks passed, all 40 pinned output strings were present, and the changelog fragment passed validation.

Methodology

  • P0 [Newly identified] — The survey guard misses changes to implicit PSUs.
    Impact. Use periods 0–8, cohorts 3 and 6 plus never-treated units, and three strata with two units per cohort in each stratum. Set kappa_pre=kappa_post=2, anticipation=1, cluster="unit_subexp", and supply survey strata and an FPC of eight units per stratum with no explicit psu. Cohort 6 leaves cohort 3’s control pool but stays in its own sub-experiment, so the guard finds zero lost units. The variance code uses the remaining (unit, sub-experiment) pairs as PSUs. The old cutoff produced ten pairs per stratum and raised an FPC error. The new cutoff produces eight, so the fit treats the sample as a census and silently reports SE 0 and 21 survey df. With treatment effects of 1.5 and 2.5 within each cohort and stratum, Taylor linearization on the six original PSUs per stratum gives SE 0.07906 and 15 df.
    Concrete fix. Use fixed original sampling-unit IDs for Taylor linearization, or require an explicit survey_design.psu when cluster="unit_subexp" would supply the PSU IDs. diff_diff/stacked_did.py:L1679 · diff_diff/stacked_did.py:L1233 · diff_diff/survey.py:L1507 · docs/methodology/REGISTRY.md:L8437

  • P3 informational — The anticipation extension is documented.
    Impact. Wing et al.’s Assumption 1 rules out anticipation. The Registry explains why the library uses A_s - anticipation as the earliest response date. The inclusion check and stack builder use the same cutoff.
    Concrete fix. No action required for the cutoff itself. docs/methodology/REGISTRY.md:L2504 · docs/methodology/REGISTRY.md:L2636

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 informational — Full-design inference for units that leave the stack is tracked in TODO.md.
    Impact. The prior strict-census case now raises before returning inference.
    Concrete fix. The backlog item covers retaining the original design and assigning zero scores to out-of-stack PSUs. TODO.md:L60 · tests/test_stacked_did.py:L559

Security

No findings.

Documentation/Tests

The prior documentation findings are resolved. The ImputationDiD efficiency wording also matches Borusyak, Jaravel & Spiess’s Theorems 1–2, which establish minimum variance among linear unbiased estimators under spherical errors and allow unrestricted treatment-effect heterogeneity. docs/tutorials/14_continuous_did.ipynb:L323 · docs/tutorials/15_efficient_did.ipynb:L526 · changelog.d/20261125-tutorials-staggered-family.md:L14 · docs/methodology/papers/borusyak-jaravel-spiess-2024-review.md:L51

I verified the selection predicates and independently calculated the WLS contrast and survey variance. The checkout lacked pytest and the scientific Python dependencies, so the full fits and notebooks remain unverified. The paper cross-check used the Registry and repository source reviews because the external hosts were unreachable.

Path to Approval

  1. Resolve implicit survey PSUs from the original sampled units, or reject Taylor-linearized fits that would use unit-by-sub-experiment pairs as PSUs.
  2. Add the balanced-panel regression above. Assert that cohort 6 is excluded as a control for cohort 3 and remains in the stack as treated. For a supported survey fit, assert 18 PSUs, 15 survey df, and SE approximately 0.07906. For a refusal, assert the targeted error and verify those same values when psu="unit" is supplied.

…0-15, 16 Wooldridge), with drift tests

Imputation DiD efficiency condition corrected across the documentation
(spherical errors, not homogeneous effects).
…d ETWFE parity statements; guard the event-study comparison in 16
…arry the ETWFE parity conditions into its summary and skip the mpdta fits on fallback data (16)
…t the slope (14); the default ETWFE precision gain is the tutorial panel's (16)
@igerber
igerber force-pushed the docs/tutorials-staggered-family branch from 426b42b to 298cb46 Compare November 27, 2026 18:45
@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 298cb467db787d118805666af11fdb6e8f498e87


Overall assessment

✅ Looks good. The current base resolves the prior StackedDiD survey blocker and includes a regression test for the reported panel. The remaining findings concern tutorial guidance.

Executive summary

  • StackedDiD uses original unit IDs as implicit survey PSUs. The regression test covers 18 PSUs, 15 survey degrees of freedom, and an SE of 0.07906.
  • The revised Imputation DiD efficiency statement matches Borusyak, Jaravel & Spiess’s Theorems 1–2. Tutorial 14 distinguishes the evaluation grid from observed dose support, and Tutorial 15 describes both changes that form a PT-All comparison.
  • Two tutorial explanations need clarification. The asymmetric StackedDiD example leaves out why the estimates agree, and several diagnostics links omit which fitted results the APIs accept.
  • All seven notebooks passed the static convention checks. I parsed 98 code cells, matched 41 committed output strings, and validated the changelog fragment.

Methodology

  • P3 informational. StackedDiD’s anticipation extension is documented. Impact. The adjusted cutoff keeps controls untreated throughout the focal window and, under "strict", keeps their own windows disjoint. The survey regression covers the prior case where cohort 6 leaves the control pool but remains in the stack as treated. Concrete fix. No action required. docs/methodology/REGISTRY.md:L2636 · diff_diff/stacked_did.py:L1254 · tests/test_stacked_did.py:L650

  • P2. Tutorial 13 gives an incomplete explanation for the equal asymmetric-window estimates. Impact. Keeping event times 0–2 fixes the horizons being averaged. A longer pre-window can still change the units or controls that supply those estimates. For example, with cohorts 3 and 8, never-treated controls, and kappa_post=2, the strict rule admits cohort 8 as a control for cohort 3 at kappa_pre=2 and excludes it at kappa_pre=3. Concrete fix. Explain that the tutorial’s post-treatment estimates agree because the two fits also share the same treated units, clean controls, Q-weights, and reference period. docs/tutorials/13_stacked_did.ipynb:L387 · diff_diff/stacked_did.py:L1688

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 informational. TROP’s cross-validation reporting difference is tracked in TODO.md. Impact. The tutorial panel’s Python search warns that a candidate penalty hit the iteration cap. The Rust search is silent, and both select the same penalties. Concrete fix. The backlog entry covers aligning the diagnostics. TODO.md:L85

Security

No findings.

Documentation/Tests

I independently calculated the prior survey case’s expected SE as 0.07905694. The checkout lacked pytest and the scientific Python dependencies, so verification was static and by hand calculation. The methodology cross-check used the Registry and repository paper reviews because the external source hosts were unreachable.

… the asymmetric window leaves the stacked estimate unchanged (13)
… unchanged, not the standard errors exactly (13); test the diagnostics guidance in 14 and 16
@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: bb6ea912974b22720d94ae6b196a0522736cdfe4


Overall assessment

✅ Looks good. The prior findings are resolved. The diff changes tutorial examples, documentation, and tests, with no changes to estimator logic. The remaining findings are P2 or P3.

Executive summary

  • Tutorial 13 now explains why widening the pre-treatment window preserves the point estimates. Tutorials 11, 12, 14, 15, and 16 name a supported diagnostic fit and explain which comparisons it diagnoses.
  • The revised Imputation DiD efficiency condition agrees with Borusyak, Jaravel & Spiess’s Theorems 1–2 for the unweighted first stage. The class documentation should state that scope.
  • Tutorial 10 overinterprets the rank of TROP’s averaged factor matrix. Tutorial 16 should state the clustering level used for its minimum-wage benchmark.
  • All seven tutorials passed the static convention checks. I parsed 98 code cells, matched 41 committed output strings, and validated the changelog fragment.

Methodology

  • P2 · Scope the Imputation DiD efficiency guarantee. Impact. The revised class docstring and API page imply that spherical errors suffice for the minimum-variance guarantee on every fit. Theorem 1 derives the guarantee for OLS. With nonuniform survey weights, the implementation fits the untreated model by weighted least squares, so spherical errors alone do not establish that guarantee. Concrete fix. Qualify the efficiency claim with “for the unweighted first-stage fit” in the class docstring, API page, and guides that state the theorem. diff_diff/imputation.py:L70-L76 · docs/api/imputation.rst:L20-L24 · docs/methodology/REGISTRY.md:L2365 · BJS paper review:L46-L66
  • P2 · Describe what TROP’s factor-matrix diagnostic measures. Impact. The local estimator fits a separate factor matrix for each treated observation and returns their average. The singular values and effective rank of that average cannot establish how many factors the individual fits used. Concrete fix. Describe factor_matrix as the average of the local fits and report the penalty table’s values as effective ranks of the returned matrix. docs/tutorials/10_trop.ipynb:L317-L331 · diff_diff/trop.py:L785-L808 · diff_diff/trop.py:L870-L880
  • P2 · Label the clustering used in the mpdta example. Impact. The reported intervals cluster by county, while minimum-wage adoption varies by state. County clustering allows dependence within a county over time and treats counties in the same state as independent. On the committed panel, my independent OLS calculation gives a cluster sandwich SE of 0.0132 by county and 0.0187 by state before finite-sample corrections. Concrete fix. Label the displayed intervals as county-clustered benchmark results. For policy inference, show a fit using cluster="state" with state IDs derived from the county FIPS codes. docs/tutorials/16_wooldridge_etwfe.ipynb:L497-L503 · docs/tutorials/16_wooldridge_etwfe.ipynb:L585-L596 · Wooldridge paper review:L532-L536
  • P3 informational · StackedDiD’s anticipation extension is documented. Impact. The adjusted cutoff excludes later adopters whose response would start inside the focal window. The base regression test also covers the prior survey case with 18 original-unit PSUs and 15 design degrees of freedom. Concrete fix. No action required. docs/methodology/REGISTRY.md:L2636-L2637 · tests/test_stacked_did.py:L650-L678

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 informational · TROP convergence reporting is tracked in TODO.md. Impact. The Python search reports a candidate hitting the iteration cap, while the Rust search selects the same penalties without that warning. Concrete fix. The existing backlog entry covers aligning the diagnostics. TODO.md:L85

Security

No findings.

Documentation/Tests

  • P3 · Use the committed mpdta fixture for the numerical drift test. Impact. A full checkout can skip the canonical estimates when the download fails, even though it contains the checksum-matching source data. Concrete fix. Seed the loader’s temporary cache from the committed fixture or mock the download with those bytes, following the existing loader test. The separate synthetic-fallback test already covers the notebook’s skip behavior. tests/test_t16_wooldridge_etwfe_drift.py:L303-L329 · tests/test_datasets.py:L515-L536

I ran the static checks directly and independently calculated the mpdta OLS comparison above. The environment lacked pytest and the scientific Python dependencies, so I did not rerun the notebooks or numerical drift suite. I used the Registry and in-repository paper reviews for source checks because the external hosts were unreachable.

…eighted fit; describe TROP's factor matrix as an average; cluster the mpdta example by state as well (16)
…he individual fits (10); run the notebook's state-clustering cell in its drift test
@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: a413bf10de2b6f1872d2e1e590a21306dea3c538


Overall assessment

✅ Looks good. No unmitigated P0 or P1 findings. The library changes are limited to docstrings. The remaining findings concern tutorial interpretation and test coverage.

Executive summary

  • The Imputation DiD docstring and API page now scope the efficiency guarantee to the unweighted fit, consistent with Borusyak, Jaravel & Spiess’s Theorems 1–2. diff_diff/imputation.py:L70-L78 · BJS paper review:L46-L66
  • Tutorial 10 now defines effective rank using the averaged TROP factor matrix. One sentence and the drift-test docstring still suggest a conclusion about individual fits.
  • I independently reproduced the mpdta ATT of −0.0477 and the county- and state-clustered SEs of 0.0133 and 0.0190 from the committed data. The revised tutorial labels both clustering levels.
  • All seven tutorials passed the static convention checks. I parsed 99 code cells, matched 43 committed output strings, and validated the changelog fragment.

Methodology

  • P2 · Explain which states contribute to the late mpdta estimates. The prose describes a growing employment effect across horizons. Event time 0 pools all three treated cohorts, while event times 2 and 3 contain only the 2004 cohort, which is a single state. Readers could attribute the whole change to treatment duration. State which cohorts contribute at each horizon and identify the late estimates as specific to the 2004 cohort. docs/tutorials/16_wooldridge_etwfe.ipynb:L549 · docs/tutorials/16_wooldridge_etwfe.ipynb:L613-L624
  • P3 · Keep the TROP rank interpretation at the level of the returned matrix. The phrase “a penalised fit keeps mostly the dominant one” and the test docstring’s “about two factors” can be read as claims about individual local fits. Describe the dominant singular component and effective ranks of the returned average in both places. docs/tutorials/10_trop.ipynb:L259-L267 · tests/test_t10_trop_drift.py:L14-L15
  • P3 informational · The StackedDiD anticipation rule is documented. Moving the clean-control cutoff by the anticipation period keeps later adopters whose responses start inside the focal window out of the comparison group. The tutorial matches the Registry’s extension to Wing et al. No action required. docs/tutorials/13_stacked_did.ipynb:L464-L474 · docs/methodology/REGISTRY.md:L2636

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 informational · TROP convergence reporting is tracked in TODO.md. The Python search reports a candidate that hits the iteration cap, while the Rust search selects the same penalties without that warning. The backlog entry covers aligning those diagnostics. No action required for this PR. TODO.md:L85

Security

No findings.

Documentation/Tests

  • P3 · Require canonical provenance when the committed mpdta fixture is present. The revised drift test feeds the loader the fixture offline. If the loader rejects those bytes, the shared fallback check skips the numerical tests even in a full checkout. Assert canonical provenance in the fixture-present branch and retain the fallback skip for partial checkouts. The existing loader test already uses this pattern. tests/test_t16_wooldridge_etwfe_drift.py:L304-L324 · tests/test_datasets.py:L515-L536

The checkout lacked pytest and the scientific Python dependencies, so I did not rerun the notebooks or numerical drift suite. I used the Registry and in-repository paper reviews for source checks because external paper access was unavailable.

…keep the TROP rank reading at the returned matrix (10); a fallback with the fixture present fails the mpdta drift tests
…e mpdta estimates are the same 20 counties (16)
@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 3639e2db7cea86f7d078c818b8c81b10015baddc


Overall assessment

✅ Looks good. The prior findings are addressed. No unmitigated P0 or P1 findings remain.

Executive summary

Methodology

  • P2 · Qualify spline invariance by which cells enter the aggregate. Tutorial 14 says the overall ATT is independent of the spline “at all.” The ATT formula is independent of the spline within each retained cell, but a three-unit cohort passes the two-function linear basis check and is dropped with a warning under the four-function cubic basis. If that cohort has a different effect, changing the spline can change the overall ATT. State that the estimate stays fixed when the same cohort-period cells are retained. docs/tutorials/14_continuous_did.ipynb:L514-L519 · diff_diff/continuous_did.py:L1755-L1776
  • P3 informational · StackedDiD’s anticipation cutoff matches the Registry. The shifted cutoff excludes later adopters whose anticipation window would invalidate the comparison. The Registry documents this extension to Wing et al. No fix required. docs/tutorials/13_stacked_did.ipynb:L464-L474 · docs/methodology/REGISTRY.md:L2636

Code Quality

No findings.

Performance

Maintainability

No findings.

Tech Debt

  • P3 informational · TROP convergence reporting is tracked in TODO.md. The backends select the same penalties on the tutorial panel but differ in whether they warn about a candidate that reaches the iteration cap. No fix required in this PR. TODO.md:L85

Security

No findings.

Documentation/Tests

  • P3 · Clarify what the binary analysis retains. Tutorial 14 says Callaway–Sant’Anna returns the overall ATT “and nothing else,” although it also produces cohort-period and event-study estimates. Say that binarizing retains those summaries at the doses workers received and loses the dose-response curve and marginal effects. docs/tutorials/14_continuous_did.ipynb:L642-L647 · diff_diff/staggered.py:L674-L680

I parsed all 99 code cells, matched all 43 committed output pins, and checked the changelog fragment. Source checks used the Registry and in-repository paper reviews. The checkout lacked pytest and the scientific Python dependencies, so the notebook and drift suites were not rerun.

…are kept; say what a binary analysis retains (14); load mpdta once per test module
…ly output (14); assert which cells the cubic spline drops
@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 1b6c2b75f416b687d41a248e1df156e6277ff0a1


Overall assessment

✅ Looks good. No unmitigated P0 or P1 findings remain.

Executive summary

  • Tutorial 14 now explains that spline settings can change the overall ATT by dropping cohort-period cells. It also states that the binary analysis retains cohort-period and event-study summaries. Tutorial 14:L514-L520 · Tutorial 14:L645-L652
  • The Imputation DiD efficiency correction matches Borusyak, Jaravel & Spiess’s Theorems 1–2 for the unweighted fit under spherical errors. The library changes are limited to docstrings. ImputationDiD:L70-L80 · BJS paper review:L46-L64
  • I reproduced the mpdta ATT of −0.0477 and clustered SEs of 0.0133 by county and 0.0190 by state from the pinned CSV. Event times 2 and 3 both represent the same 20 counties in one state. Tutorial 16:L613-L631

Methodology

  • P2 · Qualify the ETWFE reference-period claim on unbalanced panels. Impact. Earlier outcomes can affect the estimated post-treatment coefficient through the unit fixed effects. In a connected three-period panel with a true ATT of 2 and one treated unit missing the reference period, changing only that unit’s earlier outcome from 0 to 10 moves the fitted post-treatment coefficient from 2 to −0.5. Fix. Scope the simple reference-period comparison to balanced panels without covariates and explain that the unbalanced fit relies on the unit fixed-effects model and assumptions about missing observations. Tutorial 16:L76-L84 · Wooldridge paper review:L507-L530
  • P3 informational · StackedDiD’s anticipation cutoff follows the documented extension to Wing et al. Impact. The shifted cutoff keeps later adopters out of the control group when their anticipation window overlaps the comparison window. Fix. None required. Tutorial 13:L463-L474 · Registry:L2636

Code Quality

No findings.

Performance

Maintainability

No findings.

Tech Debt

  • P3 informational · TROP convergence reporting is tracked in TODO.md. Impact. The backends differ in whether they warn when a cross-validation candidate reaches the iteration cap. Fix. None required in this PR. TODO.md:L85

Security

No findings.

Documentation/Tests

No additional findings. I parsed 99 notebook code cells, matched all 43 committed output pins, verified the mpdta checksum, and ran changelog_compile.py check successfully. I used the supplied diff for the shallow checkout and repository paper reviews for source verification. The environment lacked pytest and the scientific Python dependencies, so I did not rerun the notebook or drift suites.

…cients is a balanced-panel one (16); copy the pinned mpdta file into the isolated Unix test lane
…ssingness unrelated to time-varying shocks (16); pin the mpdta file to LF and copy it into the Windows test lane
…ading does not hold, wherever the gaps are (16)
…anced, no-covariate case and say only that it does not carry over (16)
… case, what gaps and time-varying covariates change, and the missing-data condition (16)
…ng (16); test that a time-constant covariate keeps the reference-period reading
…ement (16); the drift test docstring says gaps can, not must
@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 3b6b4162b3cf4e9515fee6e9c8297a2101019b35


Overall assessment

✅ Looks good. No unmitigated P0 or P1 findings. The two findings from the prior review are resolved.

Executive summary

  • Tutorial 16 now scopes the simple ETWFE reference-period comparison to balanced panels without covariates and explains the missingness assumption. I independently reproduced the example in which an early shock moves the post-treatment coefficient from 2.0 to −0.5 after a reference-period row is removed. docs/tutorials/16_wooldridge_etwfe.ipynb:L76-L99
  • The Rust workflow now supplies the pinned mpdta CSV to both isolated test jobs. The file matches the loader’s SHA-256 even with Git configured for CRLF checkout conversion. .github/workflows/rust-test.yml:L222-L240 · .gitattributes:L1-L3
  • The Imputation DiD efficiency correction agrees with Borusyak, Jaravel & Spiess’s Theorems 1–2 for the unweighted fit under spherical errors. The library changes are limited to docstrings. diff_diff/imputation.py:L66-L84 · docs/methodology/papers/borusyak-jaravel-spiess-2024-review.md:L41-L64

Methodology

  • P2 · State the strict-exogeneity assumption for time-varying ETWFE covariates. Impact. Tutorial 16 explains how time-varying covariates can change the periods that inform the OLS estimate. Readers extending the example could still interpret the coefficient causally when a covariate responds to a prior outcome shock. Concrete fix. Add that Wooldridge (2025), §10.1 requires the full covariate path to be strictly exogenous with respect to the idiosyncratic outcome shocks in every period. docs/tutorials/16_wooldridge_etwfe.ipynb:L92-L114 · docs/methodology/papers/wooldridge-2025-review.md:L498-L505
  • P3 informational · Stacked DiD’s anticipation cutoff follows the registry. Impact. The shifted cutoff excludes later adopters whose anticipation overlaps the comparison window. Concrete fix. None required. docs/tutorials/13_stacked_did.ipynb:L463-L474 · docs/methodology/REGISTRY.md:L2636

Code Quality

No findings.

Performance

No remaining findings. The committed CSV removes the prior download dependency for canonical-data checks in the isolated Rust jobs. .github/workflows/rust-test.yml:L222-L240

Maintainability

No findings.

Tech Debt

  • P3 informational · TROP convergence reporting is tracked in TODO.md. Impact. The Python backend reports when a cross-validation candidate hits the iteration cap. The Rust backend is silent for the same candidate, and both select the same penalties on the tutorial panel. Concrete fix. None required in this PR. TODO.md:L85

Security

No findings.

Documentation/Tests

  • P3 · Fail the tutorial fixture on a checksum mismatch. Impact. A targeted Tutorial 16 test run can attempt a download and skip the numerical checks when a local CSV exists with the wrong digest. The full suite already catches the mismatch in its dataset test. Concrete fix. Assert the digest whenever the fixture exists, and reserve the download fallback for checkouts where the fixture is absent. tests/test_t16_wooldridge_etwfe_drift.py:L397-L427 · tests/test_datasets.py:L515-L523

I used the supplied diff to scope this re-review because the checkout is shallow. I parsed 99 notebook code cells, matched all 43 committed output pins, and passed the changelog check. I inspected the Windows workflow without running it. The available Python environments lacked pytest and the scientific dependencies, so the notebook and drift suites remain unverified in this review.

…nous (16); the mpdta fixture fails on a checksum mismatch
… and must not respond to treatment; describe the reference-move warning by the cohort's latest observed pre-period (16)
… effect; the two reference warnings can appear together (16)
@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 9384eca8d8be38dd982e5029e633db8d1566c806


Overall assessment

✅ Looks good. The prior blocking findings remain resolved. This re-review found no unmitigated P0 or P1 issues.

Executive summary

  • Tutorial 16 now states the strict-exogeneity requirement for time-varying ETWFE covariates and explains how missing observations can change the comparison. I independently reproduced the post-treatment coefficient moving from 2.0 to −0.5 when a reference-period observation is removed in the early-shock example. docs/tutorials/16_wooldridge_etwfe.ipynb:L76-L108 · tests/test_t16_wooldridge_etwfe_drift.py:L192-L263
  • The mpdta fixture now fails if the local CSV has the wrong checksum. The committed CSV matched the loader’s digest with Git’s CRLF conversion enabled, and both isolated Rust jobs copy it to the expected location. tests/test_t16_wooldridge_etwfe_drift.py:L401-L431 · .gitattributes:L1-L3 · .github/workflows/rust-test.yml:L222-L240
  • The Imputation DiD efficiency statement agrees with Borusyak, Jaravel & Spiess’s Theorems 1–2 for the unweighted fit under spherical errors. The library diff changes docstrings only. diff_diff/imputation.py:L66-L86 · docs/methodology/papers/borusyak-jaravel-spiess-2024-review.md:L41-L68

Methodology

  • P2 · Clarify the Poisson comparison in Tutorial 16. Impact. Calling the Poisson result “far less precise” conflates a county-clustered estimate in jobs with the preceding log-employment estimates, including the state-clustered fit. Concrete fix. Label the Poisson interval as county-clustered, state that it includes zero, and remove the cross-model precision ranking. docs/tutorials/16_wooldridge_etwfe.ipynb:L599-L604 · docs/tutorials/16_wooldridge_etwfe.ipynb:L652-L666
  • P3 informational · Stacked DiD’s anticipation rule follows the registry. Impact. The shifted cutoffs exclude later adopters whose anticipation would contaminate the comparison window. Concrete fix. None required. docs/tutorials/13_stacked_did.ipynb:L463-L474 · docs/methodology/REGISTRY.md:L2636

Code Quality

  • P3 · Handle a zero factor matrix in Tutorial 10. Impact. A reader who uses a penalty that shrinks the factor matrix to zero, as illustrated in the tutorial, gets a runtime warning and nan% from the singular-value share calculation. Concrete fix. Check the sum of squared singular values and print “No factor variation” when it is zero. docs/tutorials/10_trop.ipynb:L321-L326 · docs/tutorials/10_trop.ipynb:L353-L360

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 informational · TROP convergence reporting is tracked in TODO.md. Impact. The Python backend warns when a cross-validation candidate reaches the iteration cap. The Rust backend omits that warning, and both select the same penalties on the tutorial panel. Concrete fix. None required in this PR. TODO.md:L85

Security

No findings.

Documentation/Tests

  • P3 · Trigger the Rust checks when the pinned fixture changes. Impact. A change limited to mpdta.csv or its Git line-ending rule can bypass the CI job that now relies on those bytes. Concrete fix. Add benchmarks/data/real/mpdta.csv and .gitattributes to the Rust workflow’s push and pull-request path filters. .github/workflows/rust-test.yml:L3-L18 · .github/workflows/rust-test.yml:L46-L59

I used the supplied diff to scope the review because the checkout is shallow. I parsed all 99 notebook code cells, matched all 43 committed output pins, and passed the changelog check. The pytest and notebook execution suites and the Windows CI job remain unverified in this review.

…ainst the log fit (16); guard the zero factor matrix in the singular-value cell (10); run the Rust suite when the pinned mpdta file changes
…ix; tie the quoted Poisson interval to the live fit
@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 9eed0dabaf95e61091ea11ff0f90bd2af4b14ac5


Overall assessment

✅ Looks good. All prior actionable findings are resolved at 9eed0da. No unmitigated P0 or P1 findings remain.

Executive summary

  • Tutorial 10 now handles a zero factor matrix before dividing by the sum of squared singular values. The new regression test exercises both zero and nonzero matrices. docs/tutorials/10_trop.ipynb:L353-L365 · tests/test_t10_trop_drift.py:L189-L216
  • Tutorial 16 labels the Poisson interval as county-clustered and removes the precision ranking against the log-employment fit. I independently reproduced the estimate of −28.9138 and the 95% interval of [−75.5258, 17.6981] from the pinned CSV. docs/tutorials/16_wooldridge_etwfe.ipynb:L660-L667
  • Both Rust workflow triggers now include the pinned CSV and .gitattributes. The copied fixture path matches the test lookup on both platforms, and Git’s filtered CSV matched the loader’s checksum with CRLF conversion enabled. .github/workflows/rust-test.yml:L19-L23 · .github/workflows/rust-test.yml:L65-L69 · .github/workflows/rust-test.yml:L232-L250 · .gitattributes:L1-L3
  • The Imputation DiD efficiency correction agrees with Borusyak, Jaravel & Spiess’s Theorems 1–2 for the unweighted fit under spherical errors. The Python library changes are confined to docstrings. diff_diff/imputation.py:L66-L86 · docs/methodology/papers/borusyak-jaravel-spiess-2024-review.md:L41-L68

Methodology

  • P3 informational · Stacked DiD’s anticipation rule follows the registry. Impact. The documented cutoff shifts keep later adopters whose anticipation overlaps the comparison window out of the control group. Concrete fix. None required. docs/tutorials/13_stacked_did.ipynb:L463-L474 · docs/methodology/REGISTRY.md:L2636

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 informational · TROP convergence reporting is tracked in TODO.md. Impact. The Python backend reports a cross-validation candidate hitting the iteration cap. The Rust backend omits that warning, and both select the same penalties on the tutorial panel. Concrete fix. None required in this PR. TODO.md:L85

Security

No findings.

Documentation/Tests

  • P3 · State the never-treated requirement for Continuous DiD. Impact. The new control-group explanation says that not_yet_treated adds later adopters, but leaves implicit that the fit still requires never-treated units. An all-eventually-treated panel raises a ValueError. Concrete fix. Add that requirement to the not_yet_treated bullet. docs/tutorials/14_continuous_did.ipynb:L541-L545 · diff_diff/continuous_did.py:L631-L638 · docs/methodology/REGISTRY.md:L1767
  • P3 · Keep the Poisson endpoint assertion active in isolated Rust CI. Impact. The test fits the pinned data and checks that the interval contains zero, then notebook_markdown() skips the test before it checks the exact rounded endpoints. Concrete fix. Move the ("-76", "18") assertion above the notebook read so it runs in the isolated matrix. tests/test_t16_wooldridge_etwfe_drift.py:L448-L458 · tests/_tutorial_drift.py:L34-L46

I used the supplied diff to scope the review because the checkout is shallow. All 99 notebook code cells parsed, all 43 literal output pins matched, and the changelog check passed. Pytest, notebook execution, and the Windows CI job remain unverified in this review.

…ted units (14); check the Poisson interval endpoints before reading the notebook
@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: d6ef09301e6d606c7ede1aee996dee4935dcfcfe


Overall assessment

✅ Looks good. The prior findings are resolved at d6ef093. No unmitigated P0 or P1 findings remain.

Executive summary

  • Tutorial 14 now states that ContinuousDiD(control_group="not_yet_treated") requires never-treated units. A standalone regression test checks that a panel with only eventually treated units raises. docs/tutorials/14_continuous_did.ipynb:L541-L546 · tests/test_t14_continuous_did_drift.py:L177-L181
  • Tutorial 16 labels the Poisson interval as county-clustered and checks the rounded endpoints of −76 and 18 before reading the notebook. The numerical check therefore runs in isolated Rust CI. docs/tutorials/16_wooldridge_etwfe.ipynb:L660-L664 · tests/test_t16_wooldridge_etwfe_drift.py:L448-L459
  • Tutorial 10 guards the singular-value calculation when the factor matrix is zero. Its regression test covers both zero and nonzero matrices. docs/tutorials/10_trop.ipynb:L353-L365 · tests/test_t10_trop_drift.py:L189-L216
  • The library edits are confined to docstrings. The Imputation DiD efficiency statement matches Borusyak, Jaravel & Spiess’s Theorems 1–2 for the unweighted fit under spherical errors and unrestricted treatment-effect heterogeneity. diff_diff/imputation.py:L66-L86 · docs/methodology/papers/borusyak-jaravel-spiess-2024-review.md:L41-L68
  • Both isolated Rust copy steps include the canonical mpdta fixture. Its bytes matched the loader’s checksum with Git’s CRLF conversion enabled. .github/workflows/rust-test.yml:L232-L250 · .gitattributes:L1-L3 · diff_diff/datasets.py:L56

Methodology

  • P3 informational — Stacked DiD’s anticipation cutoff follows the Registry. Impact — Both later-adopter cutoffs move by the declared anticipation period, preserving the clean-control window under each rule. Concrete fix — None required. docs/tutorials/13_stacked_did.ipynb:L463-L474 · docs/methodology/REGISTRY.md:L2636

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 informational — TROP convergence reporting is tracked in TODO.md. Impact — The Python backend reports an iteration-cap warning for a cross-validation candidate that the Rust backend leaves unreported. Both select the same penalties on the tutorial panel. Concrete fix — None required in this PR. TODO.md:L85

Security

No findings.

Documentation/Tests

  • P3 — Clarify the covariate restriction for lowest_dose. Impact — The tutorial lists the panel and dose requirements, but a reader who also supplies covariates= gets NotImplementedError. The conditional extension is tracked in TODO.md. Concrete fix — Add covariates=None to the option’s requirements. docs/tutorials/14_continuous_did.ipynb:L547-L555 · diff_diff/continuous_did.py:L411-L424 · TODO.md:L70

I used the supplied diff to scope the review because the checkout is shallow. The static convention checks passed for 35 notebooks, all 99 changed notebook code cells compiled, all 43 literal output pins matched, and the changelog check passed. The review environment lacked pytest and the scientific Python dependencies, so runtime tests, notebook execution, and the Windows CI job remain unverified in this review.

@github-actions

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 84b6c2d4cb74944709dd51828fdd71244e607160


Overall assessment

⛔ Blocker at 84b6c2d. The prior findings are resolved. The new Tutorial 15 example exposes a pre-existing covariance error that can produce a miscalibrated Hausman p-value without a warning.

Executive summary

  • Tutorial 15 presents EfficientDiD.hausman_pretest() as a check on PT-All. A three-period panel satisfying PT-All shows that the reported test can use the wrong null variance even when its covariance check passes. docs/tutorials/15_efficient_did.ipynb:L278-L323
  • Tutorial 14 now explains that not_yet_treated requires never-treated units and that lowest_dose requires covariates=None. The new test exercises the valid fit and both rejected covariate inputs. docs/tutorials/14_continuous_did.ipynb:L541-L556 · tests/test_t14_continuous_did_drift.py:L177-L197
  • Tutorial 10 handles a zero factor matrix. Its revised bias-bound discussion matches the paper’s block-assignment and fixed-weight scope. docs/tutorials/10_trop.ipynb:L78-L84 · docs/tutorials/10_trop.ipynb:L353-L365 · docs/methodology/papers/athey-2025-review.md:L147-L165
  • Tutorial 16 labels the Poisson interval as county-clustered and checks the rounded endpoints before reading the notebook. Both isolated Rust lanes copy the canonical mpdta fixture, whose checksum matches the loader’s pin under Git’s CRLF conversion. tests/test_t16_wooldridge_etwfe_drift.py:L448-L459 · .github/workflows/rust-test.yml:L232-L250
  • The library edits are docstring-only. The revised Imputation DiD efficiency claim matches Borusyak, Jaravel & Spiess’s Theorems 1–2 for the unweighted fit under spherical errors and unrestricted treatment-effect heterogeneity. diff_diff/imputation.py:L66-L86 · docs/methodology/papers/borusyak-jaravel-spiess-2024-review.md:L41-L68

Methodology

  • P0 [Newly identified] — The PT-All covariance can silently miscalibrate the Hausman test.
    Impact — When the comparison group is never-treated, both baseline changes use the same units. Their scores add to one long difference, but the covariance used to choose PT-All weights omits the cross-covariances between those changes. The Registry documents duplicate moments and ridge regularization. The missing covariance terms are a separate issue. On a balanced panel with periods 0, 1, and 2, equal-sized treated and never-treated groups, adoption at 2, and independent unit-variance errors, the current weights give (n,\mathrm{Var}(\widehat{ES}{post}-\widehat{ES}{all})\approx1.28). The test uses the difference of marginal variances, approximately (1.92). That denominator is positive, so the eigenvalue check emits no warning and the null statistic converges to (\tfrac23\chi^2_1) while the code reports a (\chi^2_1) p-value.
    Concrete fix — Build the PT-All weight matrix from each group’s complete score, including the shared never-treated terms. Calibrate the pretest using the covariance of the paired event-study influence-function differences. diff_diff/efficient_did_weights.py:L406-L451 · diff_diff/efficient_did_weights.py:L747-L775 · diff_diff/efficient_did.py:L1661-L1720 · docs/methodology/REGISTRY.md:L1952-L1953 · docs/methodology/papers/chen-santanna-xie-2025-review.md:L86-L110 · docs/methodology/papers/chen-santanna-xie-2025-review.md:L146-L148
  • P3 informational — Stacked DiD’s anticipation rule matches the Registry.
    Impact — Both later-adopter cutoffs shift by the declared anticipation period, preserving the clean-control requirements. Concrete fix — None required. docs/tutorials/13_stacked_did.ipynb:L463-L474 · docs/methodology/REGISTRY.md:L2636

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 informational — TROP convergence reporting is tracked in TODO.md.
    Impact — Python reports a cross-validation candidate hitting the iteration cap. Rust leaves that warning unreported and selects the same penalties on the tutorial panel. Concrete fix — None required in this PR. TODO.md:L85

Security

No findings.

Documentation/Tests

No separate findings. The PR includes a documentation changelog fragment. changelog.d/20261125-tutorials-staggered-family.md:L1-L8

Path to Approval

  1. Correct the PT-All weight covariance. Add a regression with periods 0–2, treatment starting at 2, and both cohorts containing all eight three-period ±1 outcome paths. Verify that the two never-treated baseline pairs have identical covariance rows and that the matrix equals the covariance constructed from the full cohort scores.
  2. Test the Hausman denominator with paired influence functions whose covariance of differences differs from the difference of marginal covariances. Assert the statistic and p-value against the paired calculation.
  3. Re-execute Tutorial 15 and refresh its weight and Hausman output pins and interpretation using the corrected implementation.

I scoped the review with the supplied diff because the checkout is shallow. Static checks passed for 35 notebook convention checks, 99 compiled notebook code cells, 43 literal output pins, the changelog, and the fixture checksum. I verified the covariance counterexample algebraically. The environment lacked pytest and the scientific Python dependencies, so runtime tests and Windows execution remain unverified.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant