Commit 816a92c
Add DGP functions to prep.py for all supported DiD designs
Consolidate Data Generating Process functions from tutorials and tests
into diff_diff/prep.py as reusable library utilities:
- generate_staggered_data(): Staggered adoption DiD (CallawaySantAnna, SunAbraham)
- generate_factor_data(): Factor model data (TROP, SyntheticDiD)
- generate_ddd_data(): Triple Difference (DDD) designs
- generate_panel_data(): Panel data with optional parallel trends violations
- generate_event_study_data(): Event study with simultaneous treatment
Changes:
- Add 5 new DGP functions to diff_diff/prep.py with full documentation
- Export new functions from diff_diff/__init__.py
- Add 33 tests covering all new functions in tests/test_prep.py
- Update test files to use library functions where compatible
- Update tutorials 02, 04, 07, 08, 10 to import from library
- Fix pre-existing API bug in tutorial 07 (show_mdv -> mdv parameter)
Users can now generate synthetic data via:
from diff_diff import generate_staggered_data, generate_factor_data, ...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent 859477f commit 816a92c
11 files changed
Lines changed: 1101 additions & 526 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
74 | 79 | | |
75 | 80 | | |
76 | 81 | | |
| |||
190 | 195 | | |
191 | 196 | | |
192 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
193 | 203 | | |
194 | 204 | | |
195 | 205 | | |
| |||
0 commit comments