A library for estimates of causal effects.
Project description
CausalEstimate
CausalEstimate is a Python tool designed to produce causal estimates from propensity scores. It provides functionalities for matching, weighting, and other causal inference techniques, helping researchers and data scientists derive meaningful insights from observational data.
Features
- Propensity score matching and weighting
- Tools for average treatment effect (ATE) estimation
- Easy integration with pandas DataFrames
- Bootstrap standard error estimation
Installation
To install the required dependencies, run:
pip install -r requirements.txt
Usage
Example: Matching
Here is an example of how to use the matching functionality in a Jupyter notebook:
import numpy as np
import pandas as pd
from CausalEstimate.matching import match_optimal
# Simulate data
ps = np.array([0.3, 0.90, 0.5, 0.34, 0.351, 0.32, 0.35, 0.81, 0.79, 0.77, 0.90, 0.6, 0.52, 0.55])
treated = np.array([1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
ids = np.array([101, 102, 103, 103, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211])
df = pd.DataFrame({
'PID': ids,
'treatment': treated,
'ps': ps
})
# Perform matching
result = match_optimal(df, n_controls=3, caliper=0.1)
print(result)
Development
Running Tests
To run the unit tests, use the following command:
python -m unittest
Linting
To lint the code using flake8, run:
pip install flake8
flake8 CausalEstimate tests
Formatting
To format the code using black, run:
pip install black
black CausalEstimate tests
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file causalestimate-0.2.2.tar.gz.
File metadata
- Download URL: causalestimate-0.2.2.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2aeda52e8021036457d5dae245daf89700fbee2ee1d802c60b53cb52a2f509c9
|
|
| MD5 |
6ae5aba4278f00391870f6741323615c
|
|
| BLAKE2b-256 |
003c0b2e6dc103d681f057554b1e948f98f46a0bcc039c641fec5b38dc7cb371
|
File details
Details for the file CausalEstimate-0.2.2-py3-none-any.whl.
File metadata
- Download URL: CausalEstimate-0.2.2-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90107914bc3ed2a02505cc5a13ba31a1f95c88406165062b67ace4854af16d1b
|
|
| MD5 |
35287432cec398bfc23402b5ffee5274
|
|
| BLAKE2b-256 |
469e65f293891dd043a0a0eef19fb2320ac1359ebf1b30c4f3b91a60e6a1216c
|