🔷 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}
}
Metadata
Release files for dagwise 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dagwise-0.1.0.tar.gz | 47.8 kB | Without provenance | Details for dagwise-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dagwise-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for dagwise-0.1.0-py3-none-any.whl |
Total release size: 88.7 kB
Release files / dagwise-0.1.0.tar.gz
| Download URL | dagwise-0.1.0.tar.gz |
|---|---|
| Size | 47.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e965b1e9a19f50bb4ad7d1ba5453c0ce68c8fa16b26343175314ce348f88d047
|
|
BLAKE2b-256 checksum How to use checksums |
b09c41161c3e1987899436fc0def71b79b10390b404c669434a1b3fc55c5d7eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / dagwise-0.1.0-py3-none-any.whl
| Download URL | dagwise-0.1.0-py3-none-any.whl |
|---|---|
| Size | 40.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81e4d2427b359d0e73cf0a1966062d9f88142e0a22fb1770038c069c95399012
|
|
BLAKE2b-256 checksum How to use checksums |
58253b43e2569c7dfa24b5792306960097b166f6c697b5237098d64e03d046b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for dagwise 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.