Skip to main content

Casual Inference

Project description

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

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

import numpy as np

from azcausal.core.error import Placebo
from azcausal.core.panel import Panel
from azcausal.core.parallelize import Pool
from azcausal.data import CaliforniaProp99
from azcausal.estimators.panel.sdid import SDID
from azcausal.util import to_matrices

# load an example data set with the columns Year, State, PacksPerCapita, treated.
df = CaliforniaProp99().load()

# convert to matrices where the index represents each Year (time) and each column a state (unit)
data = to_matrices(df, "Year", "State", "PacksPerCapita", "treated")

# create a panel object to access observations conveniently
panel = Panel(outcome="PacksPerCapita", intervention="treated", data=data)

# initialize an estimator object, here synthetic difference in difference (sdid)
estimator = SDID()

# run the estimator
result = estimator.fit(panel)

# create a process pool for parallelization
pool = Pool(mode="thread", progress=True)

# run the error validation method
method = Placebo(n_samples=11)
estimator.error(result, method, parallelize=pool)

# print out information about the estimate
print(result.summary(title="CaliforniaProp99"))
docs/source/images/sdid.png

Estimators

Contact

Feel free to contact me if you have any questions:

Julian Blank (blankjul [at] amazon.com)
Amazon.com
Applied Scientist, Amazon
410 Terry Ave N, Seattle 98109, WA.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azcausal-0.2.0.tar.gz (403.7 kB view details)

Uploaded Source

File details

Details for the file azcausal-0.2.0.tar.gz.

File metadata

  • Download URL: azcausal-0.2.0.tar.gz
  • Upload date:
  • Size: 403.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for azcausal-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0de9df5900bc0191ee754873efd8d009b5bf70f1bd1a206f8ebc46c9d7afa358
MD5 63d09d9632151901f2d0b400bf20c58c
BLAKE2b-256 65a7d2493dd7c37ba17fb98ea1eef5430fea3b2a8039b04e118259a22beb29f0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page