https://github.com/leo-ware/pqp
A high-performance implementation of Shpitser's ID algorithm for causal identification in Rust
https://github.com/leo-ware/pqp
causal-identification causal-inference causal-models
Last synced: 7 months ago
JSON representation
A high-performance implementation of Shpitser's ID algorithm for causal identification in Rust
- Host: GitHub
- URL: https://github.com/leo-ware/pqp
- Owner: leo-ware
- License: mit
- Created: 2022-09-08T20:51:13.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-15T21:50:08.000Z (over 2 years ago)
- Last Synced: 2025-04-09T07:48:21.073Z (9 months ago)
- Topics: causal-identification, causal-inference, causal-models
- Language: Jupyter Notebook
- Homepage: https://leo-ware.github.io/pqp/
- Size: 9.05 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# PQP
The name `pqp` is short for *Pourquoi pas?*. This phrase is French for *why not?*, because "Why not?" was the question we asked ourselves when we found there was no maintained, open-source package for structural causal modeling in Python. The package provides a convenient interface for causal modeling along with routines for identification, estimation, and visualization.
## Installation
The package can be installed from PyPi using `pip`:
```bash
pip install pqp
```
## Basic Usage
```python
from pqp.graph import Graph
from pqp.variable import make_vars
# create variables
x, y, z = make_vars("xyz")
# the backdoor model
g = Graph([
x <= z,
y <= z,
y <= x,
])
# identification
causal_estimand = ATE(y, {x: 1}, {x: 0})
estimator = g.identify(causal_estimand)
print(estimator)
# >>> E_(y) [ Σ_(z) [ [P(x = 1, y, z) * P(z) / P(x = 1, z)] ] ] - E_(y) [ Σ_(z) [ [P(x = 0, y, z) * P(z) / P(x = 0, z)] ] ]
```
## Further Reading
For more information, see the documentation at [https://leo-ware.github.io/pqp/](https://leo-ware.github.io/pqp/).
The source code is available at [https://github.com/leo-ware/pqp](https://github.com/leo-ware/pqp).
## About
This package was created by Leo Ware as part of his undergraduate capstone project at Minerva University.