Examples¶
Each page shows a script from the repository’s examples/ directory and its
output. Run the scripts from the repository’s root:
python examples/quickstart.py
python docs/examples/refresh.py reruns them all and updates these pages.
Page |
|
|---|---|
Callaway-Sant’Anna, Sun-Abraham and BJS on a simulated panel of 2,000 units over 8 periods, whose effects grow with time since treatment and differ by cohort. |
|
Outcome regression, inverse probability weighting and the doubly robust estimator, with two covariates. |
|
Cohort and calendar aggregates of a Callaway-Sant’Anna fit on an unbalanced panel, with the cells and weights behind each estimate, then an event study restricted to the cohorts observed at event times 0 and 1. |
|
Units may respond two periods before treatment ( |
|
The three estimators with a sampling weight per unit. |
|
Time-varying weights on an unbalanced panel; covariates in Callaway-Sant’Anna; covariates and region-by-time fixed effects in Sun-Abraham and BJS, with BJS’s pre-trend test. |
|
No unit is never treated, so the last-treated cohort serves as the comparison until it is treated ( |
|
|
|
Callaway-Sant’Anna’s multiplier bootstrap: a simultaneous 95% band over the event study, then a pre-trend test of the event-time averages. |
|
Gardner’s estimator on Cheng and Hoekstra’s state panel of homicide rates, with treatment starting the year after a state’s castle doctrine law: the overall ATT, an event-study window and a test of two leads. |
|
Wooldridge’s estimator with not-yet-treated controls and a covariate (log county population) on R did’s minimum-wage example. |
|
The event study, the overall ATT, a pre-trend test of three event-time averages, and the composition of an event study balanced over event times 0 to 2. |
|
The decomposition of a two-way fixed effects estimate on a simulated panel, the same with sampling weights, and the covariate-adjusted decomposition on the Castle Doctrine panel. |
|
The weights behind the union wage premium in the authors’ wage panel, where union membership switches on and off: their sums, the sensitivity measures, and the cells with negative weights. |
The simulated panels come from diff_stream.simulate: simulate_panel (no
covariates) and simulate_conditional_panel (two covariates that shift both
treatment timing and trends). The public data sets are frozen in
tests/data/: the Castle Doctrine panel (Cheng and Hoekstra 2013, as
distributed with R’s did2s), mpdta (a subset of Callaway and Sant’Anna’s
2021 county data, built from the Census Bureau’s Quarterly Workforce
Indicators, as distributed with R’s did), and the Vella and Verbeek (1998)
wage panel (as distributed with TwoWayFEWeights). Full citations are in
tests/data/DATA_SOURCES.md.