A full-stack Python causal inference engine — DAGs, identification, estimation, and refutation
Project description
🔷 dagwise
A full-stack DAG-based causal inference engine for Python
Answer "does X cause Y?" — not just "are X and Y correlated?"
What is dagwise?
dagwise is a Python library for causal inference — the science of determining whether X truly causes Y, not just correlates with it.
Unlike machine learning which predicts outcomes, dagwise answers "what if" questions:
- Would this drug have worked if given to a different patient?
- Did this marketing campaign actually drive sales?
- What's the true effect of this policy?
✨ Features
| Feature | dagwise |
|---|---|
| DAG (no networkx dependency) | ✅ |
| Full ID Algorithm (Shpitser-Pearl) | ✅ |
| Double ML | ✅ |
| Staggered DiD (Callaway-Sant'Anna) | ✅ |
| Refutation Tests | ✅ |
| Sensitivity Analysis | ✅ |
| Clean Pythonic API | ✅ |
📦 Installation
pip install dagwise
# With plotting support
pip install dagwise[plot]
# With DAG visualization
pip install dagwise[viz]
# Everything
pip install dagwise[all]
⚡ Quickstart
import pandas as pd
from dagwise import CausalModel
from dagwise.core import CausalDAG
# 1. Define your causal structure
dag = CausalDAG()
dag.add_edge("Age", "Smoking")
dag.add_edge("Age", "LungCancer")
dag.add_edge("Smoking", "LungCancer")
# 2. Create causal model
model = CausalModel(dag=dag, treatment="Smoking", outcome="LungCancer")
# 3. Identify the causal effect
result = model.identify()
print(result.estimand)
# P(LungCancer|do(Smoking)) = Σ_Age P(LungCancer|Smoking,Age)·P(Age)
# 4. Estimate the effect
data = pd.read_csv("smoking_data.csv")
ate = model.estimate(data=data, method="double_ml", covariates=["Age"])
print(ate.summary())
# 5. Validate with refutation tests
from dagwise.inference import RefutationTest
refutation = RefutationTest.placebo_treatment(estimator=ate, data=data,
treatment="Smoking", outcome="LungCancer")
print(f"Refutation passed: {refutation.passed}")
🧠 Supported Methods
Identification
- Backdoor Criterion & Adjustment Sets
- Frontdoor Criterion
- ID Algorithm (Shpitser & Pearl, 2006) — full general identification
- Instrumental Variables
Estimation
- Inverse Probability Weighting (IPW)
- Outcome Regression (G-computation)
- Doubly Robust / AIPW
- Double ML (Chernozhukov et al., 2018)
- Propensity Score Matching
- Instrumental Variables (2SLS)
- Difference-in-Differences (2x2 + Staggered/Callaway-Sant'Anna)
- Regression Discontinuity Design
Inference & Validation
- Bootstrap Confidence Intervals
- Sensitivity Analysis (E-values, Rosenbaum Bounds)
- Refutation Tests (Placebo, Random Common Cause, Data Subset)
📖 Documentation
🤝 Contributing
Contributions are welcome! Please read CONTRIBUTING.md first.
git clone https://github.com/keyreyla/dagwise.git
cd dagwise
pip install -e ".[dev]"
pytest
📄 License
MIT — see LICENSE
📚 References
- Shpitser & Pearl (2006) — ID Algorithm
- Chernozhukov et al. (2018) — Double ML
- Callaway & Sant'Anna (2021) — Staggered DiD
- Pearl (2009) — Causality: Models, Reasoning, and Inference
Citation
@software{dagwise2025,
title = {dagwise: A full-stack DAG-based causal inference engine},
author = {Your Name},
year = {2025},
url = {https://github.com/keyreyla/dagwise}
}
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 dagwise-0.1.0.tar.gz.
File metadata
- Download URL: dagwise-0.1.0.tar.gz
- Upload date:
- Size: 47.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e965b1e9a19f50bb4ad7d1ba5453c0ce68c8fa16b26343175314ce348f88d047
|
|
| MD5 |
b50a6ec0b7409ea668c841c242616223
|
|
| BLAKE2b-256 |
b09c41161c3e1987899436fc0def71b79b10390b404c669434a1b3fc55c5d7eb
|
File details
Details for the file dagwise-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dagwise-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81e4d2427b359d0e73cf0a1966062d9f88142e0a22fb1770038c069c95399012
|
|
| MD5 |
69ea982477a7e180ed18b1bc26a0d969
|
|
| BLAKE2b-256 |
58253b43e2569c7dfa24b5792306960097b166f6c697b5237098d64e03d046b0
|