Skip to content

Commit 816a92c

Browse files
igerberclaude
andcommitted
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

diff_diff/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@
7171
balance_panel,
7272
create_event_time,
7373
generate_did_data,
74+
generate_ddd_data,
75+
generate_event_study_data,
76+
generate_factor_data,
77+
generate_panel_data,
78+
generate_staggered_data,
7479
make_post_indicator,
7580
make_treatment_indicator,
7681
rank_control_units,
@@ -190,6 +195,11 @@
190195
"validate_did_data",
191196
"summarize_did_data",
192197
"generate_did_data",
198+
"generate_staggered_data",
199+
"generate_factor_data",
200+
"generate_ddd_data",
201+
"generate_panel_data",
202+
"generate_event_study_data",
193203
"create_event_time",
194204
"aggregate_to_cohorts",
195205
"rank_control_units",

0 commit comments

Comments
 (0)