Causal inference is an important component of the experiment evaluation. We highly recommend to have a look at the open-source book: Causal Inference for The Brave and True
Please find the software documentation here: https://amazon-science.github.io/azcausal/latest/
Currently, azcausal provides two well-known and widely used causal inference methods: Difference-in-Difference (DID) and Synthetic Difference-in-Difference (SDID). Moreover, error estimates via Placebo, Boostrap, or JackKnife are available.
Installation
To install the current release, please execute:
pip install git+https://github.com/amazon-science/azcausal.git
Usage
from azcausal.core.error import JackKnife
from azcausal.core.panel import CausalPanel
from azcausal.data import CaliforniaProp99
from azcausal.estimators.panel.sdid import SDID
from azcausal.util import to_panels
# load an example data set with the columns Year, State, PacksPerCapita, treated.
df = CaliforniaProp99().df()
# create the panel data from the frame and define the causal types
data = to_panels(df, 'Year', 'State', ['PacksPerCapita', 'treated'])
ctypes = dict(outcome='PacksPerCapita', time='Year', unit='State', intervention='treated')
# initialize the panel
panel = CausalPanel(data).setup(**ctypes)
# initialize an estimator object, here synthetic difference in difference (sdid)
estimator = SDID()
# run the estimator
result = estimator.fit(panel)
# run the error validation method
estimator.error(result, JackKnife())
# plot the results
estimator.plot(result)
# print out information about the estimate
print(result.summary(title="CaliforniaProp99"))
╭──────────────────────────────────────────────────────────────────────────────╮
| CaliforniaProp99 |
├──────────────────────────────────────────────────────────────────────────────┤
| Panel |
| Time Periods: 31 (19/12) total (pre/post) |
| Units: 39 (38/1) total (contr/treat) |
├──────────────────────────────────────────────────────────────────────────────┤
| ATT |
| Effect (±SE): -15.60 (±2.9161) |
| Confidence Interval (95%): [-21.32 , -9.8884] (-) |
| Observed: 60.35 |
| Counter Factual: 75.95 |
├──────────────────────────────────────────────────────────────────────────────┤
| Percentage |
| Effect (±SE): -20.54 (±3.8393) |
| Confidence Interval (95%): [-28.07 , -13.02] (-) |
| Observed: 79.46 |
| Counter Factual: 100.00 |
├──────────────────────────────────────────────────────────────────────────────┤
| Cumulative |
| Effect (±SE): -187.25 (±34.99) |
| Confidence Interval (95%): [-255.83 , -118.66] (-) |
| Observed: 724.20 |
| Counter Factual: 911.45 |
╰──────────────────────────────────────────────────────────────────────────────╯
Estimators
Difference-in-Difference (DID): Simple implementation of the well-known Difference-in-Difference estimator.
Synthetic Difference-in-Difference (SDID): Arkhangelsky, Dmitry Athey, Susan Hirshberg, David A. Imbens, Guido W. Wager, Stefan Synthetic Difference-in-Differences American Economic Review 111 12 4088-4118 2021 10.1257/aer.20190159 https://www.aeaweb.org/articles?id=10.1257/aer.20190159. Implementation based on https://synth-inference.github.io/synthdid/
Contact
Feel free to contact me if you have any questions:
Metadata
Release files for azcausal 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| azcausal-0.2.5.tar.gz | 550.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| azcausal-0.2.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 622.9 kB
Release files / azcausal-0.2.5.tar.gz
| Download URL | azcausal-0.2.5.tar.gz |
|---|---|
| Size | 550.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db7f4d1c691bd356b824a457527adb2bb24202db1afe0e277f48d87de8e2cef4
|
|
BLAKE2b-256 checksum How to use checksums |
687807e67493a196a39a31128de6a871205a909443b12376b5066b77e0e97390
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / azcausal-0.2.5-py3-none-any.whl
| Download URL | azcausal-0.2.5-py3-none-any.whl |
|---|---|
| Size | 72.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43fb5a516d780001fb7b36e29afe537cb45c704c574190ca2e295b42251c00af
|
|
BLAKE2b-256 checksum How to use checksums |
fa6a4b34dff7d2871113b7829882a92d7e9fdb6919473169e3aa4242d34f6c73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|