Skip to content

Commit f6785ae

Browse files
Add Phase 9-14 modules: e-value, dose-response, bounds, spillover, DTR, multi-treatment
New modules: - bounds: Lee and Manski partial identification bounds - diagnostics/evalue: E-value sensitivity analysis - dose_response: Generalized propensity score for continuous treatments - dtr: Dynamic treatment regimes via G-estimation - interference: Spillover effect estimation - multi_treatment: Multi-valued treatment IPW estimation Also adds tests for phases 9-14 and conformal/BCF/bunching/matrix completion, updates README and pyproject.toml, removes outdated Chinese fonts guide. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 17d7cee commit f6785ae

17 files changed

Lines changed: 2721 additions & 383 deletions

File tree

README.md

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Tests](https://github.com/brycewang-stanford/statspai/workflows/CI%2FCD%20Pipeline/badge.svg)](https://github.com/brycewang-stanford/statspai/actions)
77
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/statspai?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/statspai)
88

9-
StatsPAI is a unified Python package for causal inference and applied econometrics. One `import`, 120+ functions, covering the complete empirical research workflow — from estimation to publication-ready tables in Word, Excel, and LaTeX.
9+
StatsPAI is a unified Python package for causal inference and applied econometrics. One `import`, 150+ functions, covering the complete empirical research workflow — from classical econometrics to cutting-edge ML/AI causal methods to publication-ready tables in Word, Excel, and LaTeX.
1010

1111
It brings R's [Causal Inference Task View](https://cran.r-project.org/web/views/CausalInference.html) (fixest, did, rdrobust, gsynth, DoubleML, MatchIt, CausalImpact, ...) and Stata's core econometrics commands into a single, consistent Python API.
1212

@@ -111,6 +111,51 @@ It brings R's [Causal Inference Task View](https://cran.r-project.org/web/views/
111111
| `policy_tree()` | Optimal treatment assignment rules | Athey & Wager (2021) |
112112
| `policy_value()` | Policy value evaluation ||
113113

114+
### Conformal & Bayesian Causal Inference
115+
116+
| Function | Description | Reference |
117+
| --- | --- | --- |
118+
| `conformal_cate()` | Distribution-free prediction intervals for ITE | Lei & Candes (2021) |
119+
| `bcf()` | Bayesian Causal Forest (separate mu/tau) | Hahn, Murray & Carvalho (2020) |
120+
121+
### Dose-Response & Multi-valued Treatment
122+
123+
| Function | Description | Reference |
124+
| --- | --- | --- |
125+
| `dose_response()` | Continuous treatment dose-response curve (GPS) | Hirano & Imbens (2004) |
126+
| `multi_treatment()` | Multi-valued treatment AIPW | Cattaneo (2010) |
127+
128+
### Bounds & Partial Identification
129+
130+
| Function | Description | Reference |
131+
| --- | --- | --- |
132+
| `lee_bounds()` | Sharp bounds under sample selection | Lee (2009) |
133+
| `manski_bounds()` | Worst-case bounds (no assumption / MTR / MTS) | Manski (1990) |
134+
135+
### Interference & Spillover
136+
137+
| Function | Description | Reference |
138+
| --- | --- | --- |
139+
| `spillover()` | Direct + spillover + total effect decomposition | Hudgens & Halloran (2008) |
140+
141+
### Dynamic Treatment Regimes
142+
143+
| Function | Description | Reference |
144+
| --- | --- | --- |
145+
| `g_estimation()` | Multi-stage optimal DTR via G-estimation | Robins (2004) |
146+
147+
### Bunching & Tax Policy
148+
149+
| Function | Description | Reference |
150+
| --- | --- | --- |
151+
| `bunching()` | Kink/notch bunching estimator with elasticity | Kleven & Waseem (2013) |
152+
153+
### Matrix Completion (Panel)
154+
155+
| Function | Description | Reference |
156+
| --- | --- | --- |
157+
| `mc_panel()` | Causal panel data via nuclear-norm matrix completion | Athey et al. (2021) |
158+
114159
### Other Causal Methods
115160

116161
| Function | Description | Stata/R equivalent |
@@ -137,6 +182,7 @@ It brings R's [Causal Inference Task View](https://cran.r-project.org/web/views/
137182
| `mccrary_test()` | Density discontinuity test | McCrary (2008) |
138183
| `hausman_test()` | FE vs RE specification test | Hausman (1978) |
139184
| `anderson_rubin_test()` | Weak instrument robust inference | Anderson & Rubin (1949) |
185+
| `evalue()` | E-value sensitivity to unmeasured confounding | VanderWeele & Ding (2017) |
140186
| `het_test()` | Breusch-Pagan / White heteroskedasticity ||
141187
| `reset_test()` | Ramsey RESET specification test ||
142188
| `vif()` | Variance Inflation Factor ||
@@ -298,7 +344,7 @@ sp.subgroup_analysis(df, formula="wage ~ education + experience",
298344
## API at a Glance
299345

300346
```text
301-
120 public functions/classes
347+
150+ public functions/classes
302348
303349
Regression: regress, ivreg, panel, heckman, qreg, sqreg, tobit, xtabond
304350
DID: did, did_2x2, callaway_santanna, sun_abraham, bacon_decomposition, honest_did
@@ -309,9 +355,17 @@ ML Causal: dml, causal_forest, deepiv, metalearner, tmle, aipw
309355
Neural: tarnet, cfrnet, dragonnet
310356
Discovery: notears, pc_algorithm
311357
Policy: policy_tree, policy_value
358+
Conformal/Bayes:conformal_cate, bcf
359+
Dose-Response: dose_response
360+
Multi-Treat: multi_treatment
361+
Bounds: lee_bounds, manski_bounds
362+
Interference: spillover
363+
DTR: g_estimation
364+
Bunching: bunching
365+
Panel MC: mc_panel
312366
Other: causal_impact, mediate, bartik
313367
Post-est: margins, marginsplot, test, lincom
314-
Diagnostics: oster_bounds, sensemakr, mccrary_test, hausman_test, het_test, reset_test, vif
368+
Diagnostics: oster_bounds, sensemakr, evalue, mccrary_test, hausman_test, het_test, reset_test, vif
315369
Robustness: spec_curve, robustness_report, subgroup_analysis
316370
Inference: wild_cluster_bootstrap, ri_test
317371
Output: modelsummary, outreg2, sumstats, balance_table, tab, coefplot, binscatter
@@ -351,7 +405,7 @@ pytest
351405
author={Wang, Bryce},
352406
year={2025},
353407
url={https://github.com/brycewang-stanford/statspai},
354-
version={0.2.0}
408+
version={0.3.0}
355409
}
356410
```
357411

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "StatsPAI"
7-
version = "0.2.0"
7+
version = "0.3.0"
88
description = "The Causal Inference & Econometrics Toolkit for Python"
99
readme = "README.md"
1010
license = {text = "MIT"}
@@ -33,6 +33,8 @@ keywords = [
3333
"synthetic-control", "matching", "propensity-score",
3434
"instrumental-variables", "panel-data", "double-ml",
3535
"stata", "R", "machine-learning",
36+
"tmle", "dragonnet", "causal-discovery", "policy-learning",
37+
"conformal-inference", "bayesian-causal-forest",
3638
]
3739
requires-python = ">=3.9"
3840
dependencies = [
@@ -68,6 +70,9 @@ performance = [
6870
deepiv = [
6971
"torch>=2.0.0",
7072
]
73+
neural = [
74+
"torch>=2.0.0",
75+
]
7176
fixest = [
7277
"pyfixest>=0.25.0",
7378
]

src/statspai/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
>>> sp.outreg2(result, filename="results.xlsx")
2323
"""
2424

25-
__version__ = "0.2.0"
25+
__version__ = "0.3.0"
2626
__author__ = "Bryce Wang"
2727
__email__ = "bryce@copaper.ai"
2828

src/statspai/bounds/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
Bounds and Partial Identification for causal effects.
3+
4+
When point identification is not possible (e.g., due to sample selection,
5+
non-compliance, or missing data), bounds provide informative intervals
6+
for the treatment effect.
7+
8+
Methods
9+
-------
10+
- **Lee Bounds** : Bounds on ATE under sample selection (Lee 2009)
11+
- **Manski Bounds** : Worst-case bounds with minimal assumptions (Manski 1990)
12+
13+
References
14+
----------
15+
Lee, D. S. (2009).
16+
Training, Wages, and Sample Selection: Estimating Sharp Bounds on
17+
Treatment Effects. RES, 76(3), 1071-1102.
18+
19+
Manski, C. F. (1990).
20+
Nonparametric Bounds on Treatment Effects.
21+
AER P&P, 80(2), 319-323.
22+
"""
23+
24+
from .lee_manski import lee_bounds, manski_bounds
25+
26+
__all__ = ['lee_bounds', 'manski_bounds']

0 commit comments

Comments
 (0)