skills/50-brycewang-aer-skills/skills/aer-statspai/SKILL.md
Use when aer-identification has fixed the design, after methodology choice and before aer-robustness or aer-tables-figures, to run an AER-track analysis with StatsPAI — the agent-native Python engine and MCP server for causal inference, robustness, sensitivity, and publication-ready table export.
npx skillsauth add brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research aer-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.
aer-statspai is the implementation engine option for this stack. Where
aer-identification and aer-robustness decide which estimator and which
diagnostics a referee will demand, this skill is about running them — through
StatsPAI, an open-source,
agent-native Python platform that exposes 1,000+ causal-inference and
econometrics functions behind one unified API, plus a machine-readable MCP
server an agent can drive directly.
It is one more choice, not a replacement. The Stata / R / Python templates in
templates/ remain the default for users who want drop-in, version-pinned
scripts. Reach for StatsPAI when you want a single Python surface that covers the
whole AER identification toolkit, self-describes its assumptions to an agent, and
exports publication-ready LaTeX / Word / Excel tables from the estimator object.
This skill does not override the methodology. The modern-default rules in
aer-identification (no TWFE on staggered data, Anderson-Rubin under weak IV,
local-linear RDD, placebo inference for SCM) still bind. StatsPAI executes those
rules; it does not relax them.
fixest, did, rdrobust,
linearmodels, and scdatastatspai) and you can
chain detect_design → recommend → fit → audit_result → sensitivity → bibtex.to_latex(), .to_docx(), .to_excel()) to hand to aer-tables-figures.do files) → use templates/stata/templates/python/, templates/r/, or
templates/stata/aer-identification
first; come back here to execute once the design is fixedTwo ways to use StatsPAI; they share the same estimators.
pip install statspai
import statspai as sp
df = sp.datasets.mpdta() # bundled teaching panel
cs = sp.callaway_santanna(data=df, y="lemp", t="year",
i="countyreal", g="first_treat")
print(sp.aggte(cs, type="simple").summary()) # staggered-robust ATT
Agent-native (MCP) path. When a StatsPAI MCP server is connected, the agent
calls the same methods as tools (statspai namespace) and gets back structured
result handles instead of parsing console output. This is the preferred path
inside an agent loop because every function publishes its assumptions,
preconditions, and failure modes for the agent to read before it runs.
Drive the MCP server as a chain, not as one-shot calls. Pass as_handle=true
(or detail='agent') so each step returns a result_id the next step consumes —
no need to ferry betas, standard errors, or covariance matrices by hand.
detect_design — infer the study shape (DiD / IV / RDD / SCM / panel), or
pass design= explicitly when you already know it.preflight + recommend — surface design problems (no never-treated
group, weak first stage, manipulation at the cutoff) and let the engine
propose the modern-default estimator.as_handle=true — e.g. callaway_santanna, ivreg,
rdrobust, synth. You get a result_id you can chain downstream.audit_result(result_id=...) — enumerate the robustness checks still
missing; for each, call the suggest_function it emits. This is the
referee-anticipation step from aer-robustness, automated.honest_did_from_result / sensitivity_from_result — design-specific
sensitivity (Rambachan-Roth honest bounds, Oster δ, etc.) directly off the
handle.bibtex(keys=[...]) — pull verified citations for every estimator and
diagnostic you used. Never invent references — paper.bib is the single
source of truth.Token economy: pass detail='minimal' on cheap sub-step calls; the default
detail='agent' carries the violations list and next_steps you actually need.
Before handing results to aer-robustness, leave this shape:
DESIGN: staggered DiD; n = 48,212; cohorts = 37
RESULT: ATT = -0.042; SE = 0.011; pretrend p = 0.64
AUDIT: forbidden weight = 0.31; honest-DiD Mbar=1 bound [-0.071, -0.009]
DECISION: advance only if template cross-check agrees within 0.002
Each row keeps the modern default from aer-identification; StatsPAI is the
execution surface.
| Strategy | Modern default (see aer-identification) | StatsPAI entry point |
|---|---|---|
| Staggered DiD | Callaway-Sant'Anna ATT(g,t); never raw TWFE | callaway_santanna, aggte, did_imputation, sun_abraham, did_multiplegt, lp_did |
| Forbidden-comparison check | Goodman-Bacon decomposition | bacon_decomposition, bacon_plot |
| Event study / pre-trends | Joint pre-period test, not just the plot | event_study, pretrends_test, honest_did |
| IV / weak instruments | Anderson-Rubin, not first-stage F > 10 | ivreg, anderson_rubin_ci, effective_f_test, tF_adjustment |
| Shift-share / Bartik | Rotemberg weights or shock-level inference | bartik |
| RDD | Local-linear, MSE-optimal bandwidth, RBC CI | rdrobust, rdbwselect, rdplot, rddensity (McCrary) |
| Synthetic control | Placebo inference; modern variants | synth, gsynth, augsynth, sdid, synth_time_placebo, synth_loo |
| Factor-model counterfactuals | Interactive FE / matrix completion for larger treated blocks | interactive_fe, matrix_completion |
| Bunching / kink designs | Excess mass over a polynomial counterfactual | bunching, notch |
| DML / causal ML | Cross-fit nuisance; honest CIs | dml, causal_forest, metalearner, tmle, aipw |
| Distributional effects | Quantile treatment effects when the mean hides the action | qte |
| Robustness / few-cluster inference | Specification curve; cluster-robust variance; exact randomization tests | spec_curve, wild_cluster_bootstrap, twoway_cluster, conley, ri_test |
| Sensitivity to confounding / multiplicity | Oster δ-R²; Cinelli-Hazlett robustness value; FWER control | oster_delta, oster_bounds, robustness_value, romano_wolf |
| Partial identification under attrition | Lee (2009) trimming bounds when selection is differential | lee_bounds |
When in doubt about whether an estimator is appropriate, that decision belongs
to aer-identification. This table is for how to run the one you've chosen.
audit_result is the bridge to aer-robustness: it reads the fitted handle and
lists the checks a referee will expect — placebo, alternative samples,
heterogeneity by cohort, leave-one-out for SCM — emitting a suggest_function
for each. Drive that list to closure rather than guessing which robustness
checks to add.
For design-specific sensitivity, prefer the *_from_result tools so you never
re-specify the model:
honest_did_from_result — Rambachan-Roth (2023) honest bounds for DiDsensitivity_from_result — Oster (2019) δ / unobserved-confounding boundsrobustness_value — Cinelli-Hazlett (2020) partial-R² robustness value and bias factorlee_bounds — Lee (2009) trimming bounds under differential attritionevalue_from_result — E-value for observational designsaer-tables-figuresStatsPAI result objects export directly, which removes manual table assembly:
res.to_latex("output/tables/table3.tex") # AER booktabs-compatible
res.to_docx("output/tables/table3.docx")
res.to_excel("output/tables/table3.xlsx")
The house-style rules still come from aer-tables-figures — column count,
note structure, significance-star policy, and the booktabs conventions. Use
StatsPAI to emit the table; use aer-tables-figures to decide what the table
should look like before you ship it.
StatsPAI labels every function with a validation_status. Treat these as a
trust tier, not decoration:
templates/) before it becomes a main table in a
top-5 submission.For an AER main result, cross-check at least the headline coefficient and its inference against the language-native template. Convergent numbers across two engines is itself a robustness signal a referee will respect.
validation_status is certified or cross-checking against templates/aer-identification prescribes (e.g. plain TWFE because it is one call)audit_result and hand-picking robustness checks — the whole point
of the agent-native loop is that it enumerates what you missedbibtex — verified keys onlyWhen working from the AER-skills repository or plugin bundle, load only the relevant resource:
docs/methods-reference.mdskills/aer-identification/SKILL.mdaudit_result should reproduce: skills/aer-robustness/SKILL.mdskills/aer-tables-figures/SKILL.mdtemplates/python/main_did.pytemplates/python/requirements.txtUse aer-identification to fix the design before running anything here; use
docs/methods-reference.md to confirm the estimand, diagnostic, and citation
the manuscript must report.
ENGINE: StatsPAI (python-api | mcp)
DESIGN: <DiD | IV | RDD | SCM | DML | ...>
ESTIMATOR FUNCTION: <statspai function used>
VALIDATION STATUS: <certified | api-stable — cross-checked? yes/no>
AUDIT_RESULT CHECKS CLOSED: <list or "none">
SENSITIVITY RUN: <honest_did | oster | evalue | none>
TABLES EXPORTED: <paths or "none">
NEXT SKILL: aer-robustness (close audit) → aer-tables-figures (house style)
aer-statspai as a substitute for aer-identification — it executes
the design, it does not choose itapi-stable result as a main top-5 table with no reference
cross-checkaer-tables-figures — the engine
emits a table, it does not enforce AER house styletools
Recommend AND run open-source AI tools, agents, Claude Code / Codex skills, and MCP servers for any stage of a literature review — searching, reading, extracting, synthesizing, screening, citation-checking, and paper writing. Use when the user asks "what tool should I use to..." OR "install/run/use <tool> to ..." for research/lit-review work: automating a survey or related-work section, PDF→Markdown extraction for LLMs (MinerU/marker/docling), PRISMA / systematic review (ASReview), citation-backed Q&A over PDFs (PaperQA2), wiring papers into Claude/Cursor via MCP (arxiv/paper-search/zotero servers), or chatting with a Zotero library. Ships a launcher (scripts/litrun.py) that installs each tool in an isolated venv and runs it. Curated catalog of 70+ vetted projects. 支持中英文(用于「文献综述工具选型」与「一键安装/运行」)。
development
Route empirical-research requests through the Auto-Empirical Research Skills catalog when this whole repository is installed as one skill in Codex, CodeBuddy, Claude Code, or another IDE. Use to choose and load the right vendored AERS skill for causal inference, econometrics, replication, data acquisition, manuscript writing, peer review and referee responses, citation checking, de-AIGC editing, or full empirical-paper workflows without reading the entire repository at once.
documentation
Use when the project collects primary data or runs a field, lab, or survey experiment, before the intervention begins — write the pre-analysis plan, size the sample from a power calculation, and register with the AEA RCT Registry. Apply after the design is chosen in aer-identification and before any outcome data are seen.
tools
Guide economists to authoritative data sources with explicit, confirmed data specifications before retrieval; interfaces with Playwright MCP to navigate portals and extract real data, not articles about data.