Metadata-Version: 2.4
Name: dagwise
Version: 0.1.0
Summary: A full-stack Python causal inference engine — DAGs, identification, estimation, and refutation
Author-email: Your Name <your@email.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/yourusername/dagwise
Project-URL: Documentation, https://dagwise.readthedocs.io
Project-URL: Repository, https://github.com/yourusername/dagwise
Project-URL: Issues, https://github.com/yourusername/dagwise/issues
Keywords: causal-inference,statistics,machine-learning,do-calculus,DAG
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21
Requires-Dist: scipy>=1.7
Requires-Dist: pandas>=1.3
Requires-Dist: scikit-learn>=1.0
Requires-Dist: statsmodels>=0.13
Provides-Extra: plot
Requires-Dist: matplotlib>=3.4; extra == "plot"
Provides-Extra: viz
Requires-Dist: networkx>=2.6; extra == "viz"
Requires-Dist: matplotlib>=3.4; extra == "viz"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: pandas-stubs; extra == "dev"
Requires-Dist: types-scipy; extra == "dev"
Provides-Extra: all
Requires-Dist: dagwise[dev,plot,viz]; extra == "all"
Dynamic: license-file

<div align="center">

# 🔷 dagwise

**A full-stack DAG-based causal inference engine for Python**

*Answer "does X cause Y?" — not just "are X and Y correlated?"*

[![PyPI version](https://badge.fury.io/py/dagwise.svg)](https://badge.fury.io/py/dagwise)
[![Python](https://img.shields.io/pypi/pyversions/dagwise.svg)](https://pypi.org/project/dagwise)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Tests](https://github.com/keyreyla/dagwise/actions/workflows/ci.yml/badge.svg)](https://github.com/keyreyla/dagwise/actions)
[![Coverage](https://codecov.io/gh/keyreyla/dagwise/branch/main/graph/badge.svg)](https://codecov.io/gh/keyreyla/dagwise)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Downloads](https://pepy.tech/badge/dagwise)](https://pepy.tech/project/dagwise)
[![GitHub Discussions](https://img.shields.io/github/discussions/keyreyla/dagwise)](https://github.com/keyreyla/dagwise/discussions)

</div>

---

## 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

```bash
pip install dagwise

# With plotting support
pip install dagwise[plot]

# With DAG visualization
pip install dagwise[viz]

# Everything
pip install dagwise[all]
```

## ⚡ Quickstart

```python
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

- [Quickstart Guide](docs/quickstart.md)
- [API Reference](docs/api_reference.md)
- [DAG & Identification Concepts](docs/concepts/dag_and_identification.md)
- [Estimators Guide](docs/concepts/estimators.md)
- [Examples](docs/examples/)

## 🤝 Contributing

Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) first.

```bash
git clone https://github.com/keyreyla/dagwise.git
cd dagwise
pip install -e ".[dev]"
pytest
```

## 📄 License

MIT — see [LICENSE](LICENSE)

## 📚 References

- Shpitser & Pearl (2006) — [ID Algorithm](https://arxiv.org/abs/cs/0603037)
- Chernozhukov et al. (2018) — [Double ML](https://arxiv.org/abs/1608.00060)
- Callaway & Sant'Anna (2021) — [Staggered DiD](https://arxiv.org/abs/1803.09015)
- Pearl (2009) — Causality: Models, Reasoning, and Inference

## Citation

```bibtex
@software{dagwise2025,
  title  = {dagwise: A full-stack DAG-based causal inference engine},
  author = {Your Name},
  year   = {2025},
  url    = {https://github.com/keyreyla/dagwise}
}
```
