MasaAsami / pysynthdid

Synthetic difference in differences for Python
Apache License 2.0
66 stars 22 forks source link
causal-inference causality difference-in-differences econometrics evidence evidence-based-policy policy-evaluation program-evaluation python synthetic-control

pysynthdid : Synthetic difference in differences for Python

What is Synthetic difference in differences:

original paper:

Arkhangelsky, Dmitry, et al. Synthetic difference in differences. No. w25532. National Bureau of Economic Research, 2019. https://www.nber.org/papers/w25532

R pkg:

https://github.com/synth-inference/synthdid

Blog:

https://medium.com/@masa_asami/causal-inference-using-synthetic-difference-in-differences-with-python-5758e5a76909

Installation:

$ pip install git+https://github.com/MasaAsami/pysynthdid

This package is still under development. I plan to register with pypi after the following specifications are met.

How to use:

Here's a simple example :

df = fetch_CaliforniaSmoking()

PRE_TEREM = [1970, 1988] POST_TEREM = [1989, 2000]

TREATMENT = ["California"]

- estimation & plot
```python
sdid = SynthDID(df, PRE_TEREM, POST_TEREM, TREATMENT)
sdid.fit(zeta_type="base")
sdid.plot(model="sdid")

Discussions and PR: