Overview
StatsPAI is a single-author Python package developed primarily by a Stanford graduate student. In less than a year, the codebase grew to about 309,709 lines of Python across 658 source files, 81 submodules, and over 1,020 registered functions, all accessible via import statspai as sp. The project frames itself as a unified econometrics API and the first Agent-Native statistics library.
Key Points
Unified API across methods
- A consistent interface is exposed for IV (
sp.ivreg), staggered DiD (sp.callaway_santanna), DML (sp.dml), and many other estimators. - Shared methods such as
.summary(),.to_latex(),.to_docx(), and.cite()produce text summaries, LaTeX tables, Word documents, and BibTeX references in a uniform way. - 64 modules are aligned with R and 61 modules are compared against Stata.
- Closed-form estimators match R and Stata to machine precision; a DML PLR coefficient differs by about 1.1 × 10⁻¹⁶.
- 1,000 Monte Carlo simulations show near-nominal 95% coverage: OLS 95.2%, DiD 95.5%, strong IV 96.2%.
- v1.12.0:
sp.dmlswitched from KFold to StratifiedKFold. - v1.13.1: scaling bug in
sp.callaway_santanna(method='reg')influence function. - v1.16.0:
sp.qregPowell sandwich SE was off by a factor of √n;sp.xtabondArellano-Bond GMM was rebuilt. - v1.18.0:
sp.feolssilently ignoredweights=when no fixed effects were present. - A four-tier label (Certified, Validated, Stable, Experimental) marks trust levels, but a single maintainer cannot yet match decades of community bug-hunting in Stata or CRAN.
tool_manifest()serializes function signatures into OpenAI and Anthropic tool-use JSON schemas.- An MCP Server implements the Model Context Protocol so any compatible AI client can call the estimators.
remediate()returns structured fix suggestions when a call fails.- The article argues this is Agent-Ready, not truly Agent-Native: the package exports schemas but does not encode domain assumptions, automatic alternative recommendations, or executable validation DAGs that an AI agent could reason over.
- DoWhy (≈7,200 stars), EconML (≈3,800), CausalML (≈5,000), linearmodels (≈2,500), and DoubleML each specialize in one slice.
- StatsPAI targets the full workflow from descriptive statistics to publication tables as a broad glue layer.
- Trade-off is explicit: depth is sacrificed for breadth, so specialists still win on edge cases and tuning.
- Teaching: solid fit; one import covers Card 1995, Lee 2008, Callaway-Sant'Anna examples via
sp.datasets. - Exploratory analysis: useful, but pin the version (
pip install statspai==1.18.0) and cross-check key coefficients with R or Stata. - Publication research: risky; the correctness-fix history means a new bug could surface after submission, so independent numerical verification on the locked version is mandatory.
- The package demonstrates that a single coherent econometrics API is feasible, much like scikit-learn's
fit/predict/transformstandardized ML in 2010. - Unlike scikit-learn, which had institutional backing from INRIA and Paris-Saclay, StatsPAI currently relies on one main contributor against Stata, CRAN, DoWhy, and EconML.
- The author's bet: StatsPAI's lasting contribution will be defining what a unified econometrics API looks like, even if a community-driven successor ultimately sets the standard.
Cross-software validation
Correctness fixes recorded in changelog
Agent-Native versus Agent-Ready
Position in the Python ecosystem
Usage recommendations
Long-term outlook
Notable Quote
> The most impressive thing in the repo was not the 309,709 lines of code, but a CHANGELOG full of "⚠️ correctness fix" entries — a graduate student admitting mistakes, labeling them publicly, and patching them in the next release, which is rarer in academic software than it should be.