StatsPAI 是 AI Skill Hub 本期精选MCP工具之一。综合评分 8.0 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。
StatsPAI 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
StatsPAI 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/brycewang-stanford/StatsPAI
# 方式二:手动配置 claude_desktop_config.json
{
"mcpServers": {
"statspai": {
"command": "npx",
"args": ["-y", "statspai"]
}
}
}
# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
# 安装后在 Claude 对话中直接使用 # 示例: 用户: 请帮我用 StatsPAI 执行以下任务... Claude: [自动调用 StatsPAI MCP 工具处理请求] # 查看可用工具列表 # 在 Claude 中输入:"列出所有可用的 MCP 工具"
// claude_desktop_config.json 配置示例
{
"mcpServers": {
"statspai": {
"command": "npx",
"args": ["-y", "statspai"],
"env": {
// "API_KEY": "your-api-key-here"
}
}
}
}
// 保存后重启 Claude Desktop 生效
简体中文 | English
<p align="center"> <img src="https://raw.githubusercontent.com/brycewang-stanford/StatsPAI/main/docs/logo/readme-1.png" alt="StatsPAI - Python-native Stata and R replacement for applied causal inference" width="780"> </p>
pip install statspai
Python 3.10 – 3.13 on Linux and macOS. The core install covers estimation, diagnostics, the bundled datasets, .xlsx / .docx / LaTeX export, and matplotlib figures (.plot(), sp.ggdid() and the rest). seaborn / plotly styles and heavier backends are optional extras:
| Extra | Adds | Needed for |
|---|---|---|
statspai[plotting] | seaborn, plotly (matplotlib is a core dependency) | seaborn-styled and interactive plotly figures |
statspai[fixest] | pyfixest (Python ≥ 3.10) | sp.fixest.* wrappers and the pyfixest cross-validation engine |
statspai[bayes] | PyMC, ArviZ | Bayesian estimators |
statspai[neural] / statspai[deepiv] | PyTorch | neural causal models, DeepIV |
statspai[performance] | JAX | accelerated backends |
statspai[rust] (until the next release: pip install statspai-hdfe) | [statspai-hdfe](https://pypi.org/project/statspai-hdfe/) | Rust kernels for HDFE demeaning, Poisson IRLS and cluster SEs in sp.fast.*, sp.hdfe_ols, sp.ppmlhdfe, sp.regress(cluster=); sp.fast.backend_info() reports whether they are used ([guide](docs/guides/rust_kernels.md)) |
statspai[spatial] | geopandas, libpysal, shapely | shapefile / geometry-based spatial weights |
The interactive figure editor additionally needs ipywidgets inside Jupyter.
import statspai as sp
print(sp.datasets.list_datasets()[["name", "design", "source"]])
sp is the convention used throughout these docs, but the alias is your choice. If sp is already taken in your code (for example by import scipy as sp), import statspai as si works just as well.
StatsPAI bundles 14 datasets that load offline. Most are real published extracts (source == "bundled CSV"): Card (1995) NLSYM schooling data, LaLonde/NSW with a PSID comparison group, the U.S. Senate RD data distributed with R's rdrobust, California Proposition 99, the castle-doctrine panel, and NHEFS, among others. A few are deterministic simulated replicas calibrated to a published design (source == "simulated"), including the Callaway–Sant'Anna mpdta panel used below; their numbers are not the numbers from the original data.
At a glance: 1,627 registered functions across 90 submodules; 729k LOC (core) + 496k LOC (tests). Run python scripts/registry_stats.py to reproduce these numbers.
---
The outputs below were produced with StatsPAI 1.29.0 on the bundled datasets and are pinned by tests/test_readme_examples.py, so they cannot drift from the code silently. Example 6 uses the Stata vce() grammar and post-estimation commands introduced in 1.29.0; on an older release install from source with pip install "statspai @ git+https://github.com/brycewang-stanford/StatsPAI". Long summaries are abridged (... marks omitted lines); the numbers are pinned by tests/test_readme_examples.py and tests/test_synth_placebo_pvalue.py, so they cannot silently drift from the code again.
import statspai as sp
card = sp.datasets.card_1995()
r1 = sp.regress(
"lwage ~ educ + exper + expersq + black + south + smsa",
data=card,
robust="hc1",
)
r2 = sp.ivreg("lwage ~ (educ ~ nearc4) + exper + expersq + black + south + smsa", data=card)
print(r1.summary()) # human-readable table
print(r1.tidy().head()) # broom-style dataframe
print(r1.test("black = south")) # Wald test, like Stata's `test`
print(r1.lincom("black - south")) # like Stata's `lincom`
tbl = sp.regtable(r1, r2, model_labels=["OLS", "2SLS"])
tbl.to_word("table.docx") # Word table
tbl.to_excel("results.xlsx") # Excel table
Useful docs:
- Getting started and Cookbook - Choosing an estimator: DiD, IV, RD, matching, synthetic control - Migrating: from R, Stata/R command translators, shared argument grammar - Exporting regression tables - Agents: agent API, MCP workflow for economists - Evidence: stability and validation tiers, parity matrix, tier census
---
StatsPAI aims to be one broad Stata/R-style workbench. Several focused Python packages do one part of that job, often with a longer track record; if you only need that part, they are good choices.
| Package | What it focuses on | How StatsPAI relates |
|---|---|---|
[pyfixest](https://github.com/py-econometrics/pyfixest) | fixest-style OLS / IV / GLM with high-dimensional fixed effects, event-study DiD, wild bootstrap, tables | StatsPAI has its own sp.feols (checked against R fixest) and uses pyfixest as an optional wrapper and cross-validation engine. |
[linearmodels](https://github.com/bashtage/linearmodels) | panel models, IV / GMM, system estimation | A core StatsPAI dependency for parts of the panel module, and an independent engine in sp.cross_validate. |
[DoubleML](https://github.com/DoubleML/doubleml-for-py) | double/debiased ML (PLR, PLIV, IRM, IIVM), with an R twin | sp.dml is checked against DoubleML on identical learners and folds. |
[EconML](https://github.com/py-why/EconML) | heterogeneous treatment effects: DML, causal forests, DR learners, IV, policy learning | sp.metalearner is checked against EconML's S/T/X learners. |
[DoWhy](https://github.com/py-why/dowhy) | graph-based model → identify → estimate → refute workflow; graphical causal models | StatsPAI has DAG and causal-discovery tools, but is estimator-first rather than graph-first. |
[CausalPy](https://github.com/pymc-labs/CausalPy) | Bayesian-first quasi-experiments in PyMC (plus OLS via scikit-learn): DiD, synthetic control, RD, ITS, IV | StatsPAI centres frequentist econometric conventions (clustered / robust SEs, bias-corrected RD, CS-DiD aggregation) and cross-language parity evidence. |
[causallib](https://github.com/BiomedSciAI/causallib) | scikit-learn-style IPW, standardization, doubly robust estimation, and causal evaluation | StatsPAI covers these alongside regression, panel, DiD, RD, and synthetic-control workflows in one API. |
Use StatsPAI when you want one package, one function registry, and one agent interface across the everyday Stata/R empirical workflow.
---
s["reference_versions"] # {'R': 'R version 4.5.2 (2025-10-31)', 'fixest': '0.14.0'}
sp.parity_summary() # coverage counts, including the unverified gap sp.parity_matrix(status="bit-exact")
Grades: `bit-exact` (headline relative error ≤ 1e-6 against a named R/Stata
reference), `aligned` (a documented, pre-registered looser tolerance),
`analytical-only` (recovers a known DGP truth or closed-form identity),
`external-replication` (reproduces published-paper numbers), and `unverified`
(registered but no parity evidence attached **yet** — the honest gap). The full,
auto-generated matrix is published at
[docs/parity.md](https://brycewang-stanford.github.io/StatsPAI/parity/).
For your own data, `sp.cross_validate` re-runs one estimand through every
independent engine installed locally and reports whether they agree:
python card = sp.datasets.card_1995() cv = sp.cross_validate(card, "iv", y="lwage", endog=["educ"], instruments=["nearc4"], covariates=["exper", "expersq", "black", "south", "smsa"]) print(cv.summary()) text
高质量的开源MCP工具,适用于因果推断和数据科学应用
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,StatsPAI 在MCP工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。
| 原始名称 | StatsPAI |
| 原始描述 | 开源MCP工具:StatsPAI is the first agent-native Python platform for causal inference and appl。⭐216 · Python |
| Topics | mcpagent-nativeai-agentscausal-discoverycausal-inferencedata-sciencepython |
| GitHub | https://github.com/brycewang-stanford/StatsPAI |
| License | MIT |
| 语言 | Python |
收录时间:2026-06-04 · 更新时间:2026-06-05 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端