skills/00-brycewang-stanford-StatsPAI/SKILL.md
Agent-native causal inference & econometrics toolkit for Python. 390+ functions, one import, unified API. Covers OLS, IV, DID, staggered DID, RDD, PSM, SCM, DML, Causal Forest, Meta-Learners, TMLE, neural causal models, and more. Every function returns structured result objects with self-describing schemas for LLM-driven workflows.
npx skillsauth add brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research statspaiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
StatsPAI is the agent-native Python package for causal inference and applied econometrics. One import statspai as sp, 390+ functions, covering the complete empirical research workflow.
Source: https://github.com/brycewang-stanford/StatsPAI
PyPI: pip install statspai
Paper: Published in Journal of Open Source Software (JOSS)
StatsPAI is the first econometrics toolkit purpose-built for LLM-driven research workflows:
sp.list_functions(), sp.describe_function("did"), sp.function_schema("rdrobust") — agents can discover and understand functions without documentation lookupCausalResult with .summary(), .plot(), .to_latex(), .to_word(), .to_excel(), .cite()import statspai as sp covers everythingsp.regress(df, "y ~ x1 + x2", cluster="firm_id") # OLS
sp.ivreg(df, "y ~ x1 | z1 + z2", cluster="state") # IV/2SLS
sp.panel(df, "y ~ x1 + x2", entity="firm", time="year", model="fe") # Panel FE
sp.heckman(df, "y ~ x1", "select ~ z1 + z2") # Heckman selection
sp.qreg(df, "y ~ x1 + x2", quantile=0.5) # Quantile regression
sp.did(df, "y", "treated", "post") # Auto-dispatch (2x2 or staggered)
sp.callaway_santanna(df, "y", "group", "time") # Staggered DID (CS 2021)
sp.sun_abraham(df, "y", "cohort", "time") # Interaction-weighted event study
sp.bacon_decomposition(df, "y", "treated", "time") # TWFE diagnostic
sp.honest_did(result, method="smoothness") # Sensitivity to PT violations
sp.continuous_did(df, "y", "dose", "time") # Continuous treatment
sp.rdrobust(df, "y", "running_var", cutoff=0) # Sharp RD (CCT 2014)
sp.rdrobust(df, "y", "running_var", fuzzy="treatment") # Fuzzy RD
sp.rddensity(df, "running_var") # McCrary density test
sp.rdmc(df, "y", "running_var", cutoffs=[0, 5, 10]) # Multi-cutoff RD
sp.rkd(df, "y", "running_var", cutoff=0) # Regression kink design
sp.match(df, "treatment", covariates, method="psm") # Propensity score matching
sp.match(df, "treatment", covariates, method="cem") # Coarsened exact matching
sp.ebalance(df, "treatment", covariates) # Entropy balancing
sp.synth(df, "y", "unit", "time", treated_unit=1, treated_period=2000) # ADH SCM
sp.sdid(df, "y", "unit", "time", treated_units, treated_periods) # Synthetic DID
sp.dml(df, "y", "treatment", controls, model="PLR") # Double/Debiased ML
sp.causal_forest(df, "y", "treatment", controls) # Causal Forest (GRF)
sp.metalearner(df, "y", "treatment", controls, learner="dr") # DR-Learner
sp.tmle(df, "y", "treatment", controls) # Targeted MLE
sp.aipw(df, "y", "treatment", controls) # Augmented IPW
sp.tarnet(df, "y", "treatment", controls) # TARNet
sp.cfrnet(df, "y", "treatment", controls) # CFRNet
sp.dragonnet(df, "y", "treatment", controls) # DragonNet
sp.spec_curve(df, "y", "treatment", controls, specs) # Specification curve
sp.robustness_report(result) # Automated robustness report
sp.subgroup_analysis(df, "y", "treatment", subgroups) # Heterogeneity with Wald test
result.to_latex() # Export to LaTeX
result.to_word("output.docx") # Export to Word
result.cite() # Auto-generate citation
fig = result.plot()
sp.interactive(fig) # Stata Graph Editor-style WYSIWYG editing, 29 academic themes
import statspai as sp
# Step 1: Discover available functions
functions = sp.list_functions()
# Step 2: Understand a specific function
info = sp.describe_function("callaway_santanna")
# Step 3: Get JSON schema for structured calls
schema = sp.function_schema("callaway_santanna")
# Step 4: Execute and get structured results
result = sp.callaway_santanna(df, "y", "group", "time")
print(result.summary())
result.to_latex("tables/did_results.tex")
| Scenario | Use StatsPAI | Alternative | |----------|-------------|-------------| | Agent-driven analysis pipeline | ✅ Best choice — self-describing API | pyfixest (no agent API) | | Full causal inference workflow | ✅ 390+ functions, one import | Assemble 10+ R/Python packages | | Publication-ready output needed | ✅ Word/Excel/LaTeX/HTML built-in | statsmodels (no export) | | Staggered DID with diagnostics | ✅ CS + SA + Bacon + HonestDID | differences (partial) | | Neural causal models | ✅ TARNet/CFRNet/DragonNet | econml (partial) | | Stata users migrating to Python | ✅ Stata-equivalent function names | linearmodels (limited) |
development
Conduct rigorous thematic analysis (TA) of qualitative data following Braun and Clarke's (2006) six-phase framework. Use whenever the user mentions 'thematic analysis', 'TA', 'Braun and Clarke', 'qualitative coding', 'identifying themes', or asks for help analysing interviews, focus groups, open-ended survey responses, or transcripts to identify patterns. Also trigger for questions about inductive vs theoretical coding, semantic vs latent themes, essentialist vs constructionist epistemology, building a thematic map, or writing up a qualitative findings section. Covers all six phases, the four upfront analytic decisions, the 15-point quality checklist, and the five common pitfalls. Produces a Word document write-up and an annotated thematic map. Does NOT cover IPA, grounded theory, discourse analysis, conversation analysis, or narrative analysis — use a different method for those.
development
Guide users through writing a systematic literature review (SLR) following the PRISMA 2020 framework. Use this skill whenever the user mentions 'systematic review', 'systematic literature review', 'SLR', 'PRISMA', 'PRISMA 2020', 'PRISMA flow diagram', 'PRISMA checklist', or asks for help writing, structuring, or auditing a literature review that follows reporting guidelines. Also trigger when the user asks about inclusion/exclusion criteria for a review, search strategies for databases like Scopus/WoS/PubMed, study selection processes, risk of bias assessment, or narrative synthesis for a review paper. This skill covers the full PRISMA 2020 checklist (27 items), produces a Word document manuscript in strict journal article format, generates an annotated PRISMA flow diagram, and enforces APA 7th Edition referencing throughout. It does NOT cover meta-analysis or statistical pooling. By Chuah Kee Man.
testing
Performs placebo-in-time sensitivity analysis with hierarchical null model and optional Bayesian assurance. Use when checking model robustness, verifying lack of pre-intervention effects, or estimating study power.
data-ai
Fit, summarize, plot, and interpret a chosen CausalPy experiment. Use after the causal method has been selected, including when configuring PyMC/sklearn models and scale-aware custom priors.