Skip to content

Commit ba37aaa

Browse files
authored
new Difference In Differences notebook (#424)
* initial commit of DiD notebook * add most of the modelling and inference content * add the counterfactual inference stuff * god damn pre-commit checks * fix spelling in myst.md * more spelling changes * why is this so difficult? * still?! * fixes to model description * fix typo in code block * remove unused imports + better data plot * data plot just right now * fix typo: region -> reason * addressing feedback * "differences in differences" -> "difference in differences" * add "panel data" to tags * proper use of rng according to style guide * add link to the PR in the authors section * add example, more links, more references to papers * fix missing reference and malformed link * minor changes in explanation of DiD schematic
1 parent b84c42e commit ba37aaa

File tree

5 files changed

+1763
-0
lines changed

5 files changed

+1763
-0
lines changed
Loading

examples/causal_inference/difference_in_differences.ipynb

+1,257
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import daft
2+
import matplotlib.pyplot as plt
3+
4+
plt.rcParams.update({"text.usetex": True})
5+
6+
pgm = daft.PGM()
7+
pgm.add_node("treat", "treatment", 0, 0.5, aspect=1.8)
8+
pgm.add_node("y", "outcome", 0, -0.5, aspect=1.5)
9+
pgm.add_node("t", "time", -1, 0, aspect=1.2)
10+
pgm.add_node("g", "group", 1, 0, aspect=1.2)
11+
pgm.add_edge("t", "y")
12+
pgm.add_edge("g", "y")
13+
pgm.add_edge("t", "treat")
14+
pgm.add_edge("g", "treat")
15+
pgm.add_edge("treat", "y")
16+
pgm.render()
17+
pgm.savefig("DAG_difference_in_differences.png", dpi=500)

examples/references.bib

+37
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ @book{berry1996statistics
4747
year = {1996},
4848
publisher = {Duxbury Press}
4949
}
50+
@article{bertrand2004much,
51+
title = {How much should we trust differences-in-differences estimates?},
52+
author = {Bertrand, Marianne and Duflo, Esther and Mullainathan, Sendhil},
53+
journal = {The Quarterly journal of economics},
54+
volume = {119},
55+
number = {1},
56+
pages = {249--275},
57+
year = {2004},
58+
publisher = {MIT Press}
59+
}
5060
@book{breen1996regression,
5161
title = {Regression models: Censored, sample selected, or truncated data},
5262
author = {Breen, Richard and others},
@@ -78,6 +88,12 @@ @article{caprani2010gev
7888
url = {https://www.sciencedirect.com/science/article/pii/S016747300900071X},
7989
author = {Colin C. Caprani and Eugene J. OBrien}
8090
}
91+
@misc{card1993minimum,
92+
title = {Minimum wages and employment: A case study of the fast food industry in New Jersey and Pennsylvania},
93+
author = {Card, David and Krueger, Alan B},
94+
year = {1993},
95+
publisher = {National Bureau of Economic Research Cambridge, Mass., USA}
96+
}
8197
@misc{carpenter2016hierarchical,
8298
title = {Hierarchical partial pooling for repeated binary trials},
8399
author = {Carpenter, Bob and Gabry, J and Goodrich, B},
@@ -114,6 +130,12 @@ @article{collinswilson2019
114130
issn = {2050-084X},
115131
publisher = {eLife Sciences Publications, Ltd}
116132
}
133+
@book{cunningham2021causal,
134+
title = {Causal inference: The Mixtape},
135+
author = {Cunningham, Scott},
136+
year = {2021},
137+
publisher = {Yale University Press}
138+
}
117139
@article{efron1975data,
118140
title = {Data analysis using Stein's estimator and its generalizations},
119141
author = {Efron, Bradley and Morris, Carl},
@@ -240,6 +262,12 @@ @misc{hogg2010data
240262
archiveprefix = {arXiv},
241263
primaryclass = {astro-ph.IM}
242264
}
265+
@book{huntington2021effect,
266+
title = {The effect: An introduction to research design and causality},
267+
author = {Huntington-Klein, Nick},
268+
year = {2021},
269+
publisher = {Chapman and Hall/CRC}
270+
}
243271
@article{iacobucci2016mean,
244272
title = {Mean centering helps alleviate ``micro'' but not ``macro'' multicollinearity},
245273
author = {Iacobucci, Dawn and Schneider, Matthew J and Popovich, Deidre L and Bakamitsos, Georgios A},
@@ -530,6 +558,15 @@ @book{wilkinson2005grammar
530558
issn = {1431-8784},
531559
isbn = {978-0-387-24544-7}
532560
}
561+
@article{wing2018designing,
562+
title = {Designing difference in difference studies: best practices for public health policy research},
563+
author = {Wing, Coady and Simon, Kosali and Bello-Gomez, Ricardo A},
564+
journal = {Annu Rev Public Health},
565+
volume = {39},
566+
number = {1},
567+
pages = {453--469},
568+
year = {2018}
569+
}
533570
@article{Yao_2018,
534571
doi = {10.1214/17-ba1091},
535572
url = {https://doi.org/10.1214\%2F17-ba1091},

0 commit comments

Comments
 (0)