Skip to content

Commit 118e3d7

Browse files
authored
Merge pull request #68 from igerber/claude/add-real-world-examples-Ut7pi
Add real-world data examples to documentation
2 parents 35c725f + 335029a commit 118e3d7

6 files changed

Lines changed: 1878 additions & 1 deletion

File tree

CLAUDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ pytest tests/test_rust_backend.py -v
148148
- `run_all_placebo_tests()` - Comprehensive suite of diagnostics
149149
- `PlaceboTestResults` - Dataclass for test results
150150

151+
- **`diff_diff/datasets.py`** - Real-world datasets for teaching and examples:
152+
- `load_card_krueger()` - Card & Krueger (1994) minimum wage dataset (classic 2x2 DiD)
153+
- `load_castle_doctrine()` - Castle Doctrine / Stand Your Ground laws (staggered adoption)
154+
- `load_divorce_laws()` - Unilateral divorce laws (staggered adoption, Stevenson-Wolfers)
155+
- `load_mpdta()` - Minimum wage panel data from R `did` package (Callaway-Sant'Anna example)
156+
- `list_datasets()` - List available datasets with descriptions
157+
- `load_dataset(name)` - Load dataset by name
158+
- `clear_cache()` - Clear locally cached datasets
159+
- Datasets are downloaded from public sources and cached locally
160+
151161
- **`diff_diff/honest_did.py`** - Honest DiD sensitivity analysis (Rambachan & Roth 2023):
152162
- `HonestDiD` - Main class for computing bounds under parallel trends violations
153163
- `DeltaSD`, `DeltaRM`, `DeltaSDRM` - Restriction classes for smoothness and relative magnitudes
@@ -239,6 +249,7 @@ See `docs/performance-plan.md` for full optimization details and `docs/benchmark
239249
- `06_power_analysis.ipynb` - Power analysis for study design, MDE, simulation-based power
240250
- `07_pretrends_power.ipynb` - Pre-trends power analysis (Roth 2022), MDV, power curves
241251
- `08_triple_diff.ipynb` - Triple Difference (DDD) estimation with proper covariate handling
252+
- `09_real_world_examples.ipynb` - Real-world data examples (Card-Krueger, Castle Doctrine, Divorce Laws)
242253

243254
### Benchmarks
244255

@@ -281,6 +292,7 @@ Tests mirror the source modules:
281292
- `tests/test_honest_did.py` - Tests for Honest DiD sensitivity analysis
282293
- `tests/test_power.py` - Tests for power analysis
283294
- `tests/test_pretrends.py` - Tests for pre-trends power analysis
295+
- `tests/test_datasets.py` - Tests for dataset loading functions
284296

285297
### Dependencies
286298

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Different estimators compute SEs differently. Consider unified interface.
6666
## Documentation Improvements
6767

6868
- [x] ~~Comparison of estimator outputs on same data~~ ✅ Done in `02_staggered_did.ipynb` (Section 13: Comparing CS and SA)
69-
- [ ] Real-world data examples (currently synthetic only)
69+
- [x] ~~Real-world data examples (currently synthetic only)~~ ✅ Added `datasets.py` module and `09_real_world_examples.ipynb` with Card-Krueger, Castle Doctrine, and Divorce Laws datasets
7070

7171
---
7272

diff_diff/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@
116116
plot_pretrends_power,
117117
plot_sensitivity,
118118
)
119+
from diff_diff.datasets import (
120+
clear_cache,
121+
list_datasets,
122+
load_card_krueger,
123+
load_castle_doctrine,
124+
load_dataset,
125+
load_divorce_laws,
126+
load_mpdta,
127+
)
119128

120129
__version__ = "2.0.3"
121130
__all__ = [
@@ -206,4 +215,12 @@
206215
# Linear algebra helpers
207216
"LinearRegression",
208217
"InferenceResult",
218+
# Datasets
219+
"load_card_krueger",
220+
"load_castle_doctrine",
221+
"load_divorce_laws",
222+
"load_mpdta",
223+
"load_dataset",
224+
"list_datasets",
225+
"clear_cache",
209226
]

0 commit comments

Comments
 (0)