Skip to content

Commit

Permalink
new Difference In Differences notebook (pymc-devs#424)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
drbenvincent authored Oct 6, 2022
1 parent b84c42e commit ba37aaa
Show file tree
Hide file tree
Showing 5 changed files with 1,763 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,257 changes: 1,257 additions & 0 deletions examples/causal_inference/difference_in_differences.ipynb

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions examples/causal_inference/make_DAG_difference_in_differences.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import daft
import matplotlib.pyplot as plt

plt.rcParams.update({"text.usetex": True})

pgm = daft.PGM()
pgm.add_node("treat", "treatment", 0, 0.5, aspect=1.8)
pgm.add_node("y", "outcome", 0, -0.5, aspect=1.5)
pgm.add_node("t", "time", -1, 0, aspect=1.2)
pgm.add_node("g", "group", 1, 0, aspect=1.2)
pgm.add_edge("t", "y")
pgm.add_edge("g", "y")
pgm.add_edge("t", "treat")
pgm.add_edge("g", "treat")
pgm.add_edge("treat", "y")
pgm.render()
pgm.savefig("DAG_difference_in_differences.png", dpi=500)
37 changes: 37 additions & 0 deletions examples/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ @book{berry1996statistics
year = {1996},
publisher = {Duxbury Press}
}
@article{bertrand2004much,
title = {How much should we trust differences-in-differences estimates?},
author = {Bertrand, Marianne and Duflo, Esther and Mullainathan, Sendhil},
journal = {The Quarterly journal of economics},
volume = {119},
number = {1},
pages = {249--275},
year = {2004},
publisher = {MIT Press}
}
@book{breen1996regression,
title = {Regression models: Censored, sample selected, or truncated data},
author = {Breen, Richard and others},
Expand Down Expand Up @@ -78,6 +88,12 @@ @article{caprani2010gev
url = {https://www.sciencedirect.com/science/article/pii/S016747300900071X},
author = {Colin C. Caprani and Eugene J. OBrien}
}
@misc{card1993minimum,
title = {Minimum wages and employment: A case study of the fast food industry in New Jersey and Pennsylvania},
author = {Card, David and Krueger, Alan B},
year = {1993},
publisher = {National Bureau of Economic Research Cambridge, Mass., USA}
}
@misc{carpenter2016hierarchical,
title = {Hierarchical partial pooling for repeated binary trials},
author = {Carpenter, Bob and Gabry, J and Goodrich, B},
Expand Down Expand Up @@ -114,6 +130,12 @@ @article{collinswilson2019
issn = {2050-084X},
publisher = {eLife Sciences Publications, Ltd}
}
@book{cunningham2021causal,
title = {Causal inference: The Mixtape},
author = {Cunningham, Scott},
year = {2021},
publisher = {Yale University Press}
}
@article{efron1975data,
title = {Data analysis using Stein's estimator and its generalizations},
author = {Efron, Bradley and Morris, Carl},
Expand Down Expand Up @@ -240,6 +262,12 @@ @misc{hogg2010data
archiveprefix = {arXiv},
primaryclass = {astro-ph.IM}
}
@book{huntington2021effect,
title = {The effect: An introduction to research design and causality},
author = {Huntington-Klein, Nick},
year = {2021},
publisher = {Chapman and Hall/CRC}
}
@article{iacobucci2016mean,
title = {Mean centering helps alleviate ``micro'' but not ``macro'' multicollinearity},
author = {Iacobucci, Dawn and Schneider, Matthew J and Popovich, Deidre L and Bakamitsos, Georgios A},
Expand Down Expand Up @@ -530,6 +558,15 @@ @book{wilkinson2005grammar
issn = {1431-8784},
isbn = {978-0-387-24544-7}
}
@article{wing2018designing,
title = {Designing difference in difference studies: best practices for public health policy research},
author = {Wing, Coady and Simon, Kosali and Bello-Gomez, Ricardo A},
journal = {Annu Rev Public Health},
volume = {39},
number = {1},
pages = {453--469},
year = {2018}
}
@article{Yao_2018,
doi = {10.1214/17-ba1091},
url = {https://doi.org/10.1214\%2F17-ba1091},
Expand Down
Loading

0 comments on commit ba37aaa

Please sign in to comment.