Skip to content

docs(tutorials): repair and conform the Fundamentals tutorials (01, 02, 03, 08, 09), with drift tests - #911

Open
igerber wants to merge 7 commits into
mainfrom
docs/tutorials-fundamentals
Open

igerber wants to merge 7 commits into
mainfrom
docs/tutorials-fundamentals

Conversation

@igerber

@igerber igerber commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Summary

First of the per-track tutorial repair PRs that follow the tutorial conventions and guard merged in #906. It covers the Fundamentals track: 01_basic_did, 02_staggered_did, 03_synthetic_did, 08_triple_diff, 09_real_world_examples.

Each notebook now opens with the question it answers and what the reader will learn, states its estimand and identifying assumptions before the first fit, checks estimates against a stated truth where the data is simulated, clusters panel fits at the unit, and is committed with executed outputs (Rust backend) and a drift test that pins the numbers its prose quotes. The five notebooks are removed from the convention guard's KNOWN_VIOLATIONS allowlist.

Corrections of substance:

  • 01: the clustering example printed "Cluster-robust SE is 0.26x larger" for a standard error that is smaller. The section now explains why it is smaller in that design and when the opposite holds. Panel fits are clustered at the unit.
  • 02: the true effect path is stated and compared with the estimates (it was mis-described and never compared); aggregate("event"), which raises in 4.0, is gone; pre-treatment estimates are read with simultaneous bands instead of pointwise pass/fail; the Callaway-Sant'Anna vs Sun-Abraham "robustness check", which compared two identical numbers, is replaced by an explanation of why they coincide; the comparison-group assumptions are described as the paper states them; the bootstrap section points to the cluster jackknife for few clusters.
  • 03: time weights are described correctly; the count-based placebo p-value and its resolution are explained; the placebo method's homoskedasticity assumption is stated; shipped diagnostics replace hand-rolled ones. The placebo count is 199 with the runtime reason given.
  • 08: both plain two-way DiDs are shown to miss the truth where the triple difference recovers it; the staggered example states its truth and explains the two overall summaries.
  • 09: the Card-Krueger conclusion no longer rests on unclustered standard errors; the Castle doctrine section explains the TWFE vs Callaway-Sant'Anna gap and reads the pre-treatment estimates as a warning.

One library observation found on the way is logged in TODO.md (Synthetic DiD Frank-Wolfe convergence on an ordinary panel).

Methodology references (required if estimator / math changes)

  • Method name(s): N/A - no methodology changes (documentation and tests only)
  • Paper / source link(s): N/A
  • Any intentional deviations from the source (and why): None

Validation

  • Tests added/updated: tests/test_t01_basic_did_drift.py, tests/test_t02_staggered_did_drift.py, tests/test_t03_synthetic_did_drift.py, tests/test_t08_triple_diff_drift.py, tests/test_t09_real_world_examples_drift.py (new); tests/test_tutorial_conventions.py (five allowlist entries removed).
  • Backtest / simulation / notebook evidence (if applicable): the five notebooks were re-executed on the Rust backend against current main with outputs identical to the committed ones. The drift tests pass on both backends, including the slow placebo tests. pytest --nbmake passes for all five on the pure-Python backend, mirroring CI. The Card-Krueger and Castle doctrine pins skip when the loaders return their synthetic fallback.

Security / privacy

  • Confirm no secrets/PII in this PR: Yes

Changelog

  • changelog.d/ fragment added (or N/A - no user-visible change): Yes

…, with a drift test

States and recovers the true effect path, replaces the removed
aggregate('event') and overall_att references, teaches simultaneous bands
instead of pointwise pass/fail pre-tests, and explains why Callaway-Sant'Anna
and Sun-Abraham coincide in this configuration.
…, with a drift test

Corrects the time-weights explanation (fit on control units; degenerate on the
last pre-period here), uses the shipped diagnostics instead of hand-rolled
ones, explains which p-values are count-based, and logs the Frank-Wolfe
convergence observations in TODO.md.
…ions, with a drift test

Shows both plain DiDs missing the truth while the triple difference recovers
it, states the staggered truth and covers it, explains the skipped-cell
warning and the two overall summaries, and drops the migration notes.
…ntions, with a drift test

Card-Krueger inference is clustered by restaurant (the conclusion about
significance changes), the Castle doctrine TWFE vs Callaway-Sant'Anna gap is
explained by the baseline period, its pre-treatment estimates are read as a
warning, and the divorce panel's skipped cohort is explained. Adds the
track's changelog fragment.
02: describe the never-treated and not-yet-treated comparison-group
assumptions as Callaway and Sant'Anna (2021) do - what each restricts and
when each is suggested - instead of asserting that neither is weaker.

03: state the placebo method's homoskedasticity-across-units assumption
(Arkhangelsky et al. 2021, Section 5), especially for a single treated unit;
describe the floored placebo p-value as a resolution limit; note that the
pre-treatment-fit p-value ranks against only 20 placebo fits and varies with
the seed. Seed the drift-test fixture accordingly.

Also coalesce adjacent output chunks in the committed notebooks (no change to
any output text).
@github-actions

Copy link
Copy Markdown

Overall assessment: ✅ Looks good

No unmitigated P0 or P1 findings identified.

Executive summary

  • Changes are confined to tutorials, tests, release notes, and tracked debt; estimator implementation is unchanged.
  • Methodology explanations were checked against the Registry, estimator docstrings, and available repository paper audits.
  • All five notebooks pass the static convention checks; all 76 literal rendered-text assertions match committed content.
  • Changelog validation passes.
  • Numerical tests could not run because NumPy, pandas, SciPy, and pytest are absent. Network restrictions also prevented independent paper retrieval.

Methodology

  • P3 — Documented implementation choices. Synthetic DiD’s placebo default and method-dependent p-values are explicitly documented in docs/methodology/REGISTRY.md:L3888 and docs/methodology/REGISTRY.md:L3947, and accurately reflected in Tutorial 03.
    Impact: These differences are accepted methodology contracts.
    Concrete fix: None required.

No additional methodology findings identified within the reviewed changes.

Code Quality

No findings. The added tests use public estimator APIs and check both numerical claims and committed notebook text.

Performance

No findings. Expensive Synthetic DiD placebo tests carry the existing slow marker.

Maintainability

No findings. Removing the five convention allowlist entries appropriately prevents regression.

Tech Debt

  • P3 — Solver convergence limitation is tracked. TODO.md:L82 records the Synthetic DiD convergence warnings and backend reporting discrepancy.
    Impact: Follow-up investigation remains visible; this PR introduces no solver changes.
    Concrete fix: None required for this PR; retain the tracked investigation.

Security

No findings in the changed code or notebook content.

Documentation/Tests

No additional findings. Static notebook checks, rendered-quote checks, Python syntax checks, and changelog validation passed. Numerical assertions and notebook re-execution remain unverified in this review environment.

@igerber igerber added the ready-for-ci Triggers CI test workflows label Nov 25, 2026

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

ready-for-ci Triggers CI test workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant