Logo: Aer Statspai

Aer Statspai

Communautéit
brycewang-stanford
aer-statspai

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.

Iwwersiicht

Editeurbrycewang-stanford
RepositoryAER-Skills
Skill-Nummaer-statspai
Stären
62
Forks
11
Matgeliwwert Dateien
1
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 1 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    brycewang-stanford huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Aer Statspai an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/brycewang-stanford/AER-Skills/tree/main/skills/aer-statspai
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/brycewang-stanford/AER-Skills.git /tmp/AER-Skills
mkdir -p .claude/skills
cp -r /tmp/AER-Skills/skills/aer-statspai .claude/skills/aer-statspai
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Aer Statspai an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Aer Statspai automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Aer Statspai net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

AER StatsPAI

Overview

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.

When to Use

  • You want to run the empirical analysis interactively from the agent, not just receive template code to run later by hand
  • You want one Python dependency covering DiD, IV, RDD, SCM, matching, DML, and causal forests instead of stitching together fixest, did, rdrobust, linearmodels, and scdata
  • A StatsPAI MCP server is connected (tools prefixed statspai) and you can chain detect_design → recommend → fit → audit_result → sensitivity → bibtex
  • You need publication-ready tables straight from the estimator object (.to_latex(), .to_docx(), .to_excel()) to hand to aer-tables-figures

When NOT to Use

  • The deposited replication package must be Stata-only (some coauthors / Data Editor workflows assume .do files) → use templates/stata/
  • You want exact, pinned, language-native scripts to commit verbatim into an openICPSR deposit → use templates/python/, templates/r/, or templates/stata/
  • The methodological choice is the open question — go to aer-identification first; come back here to execute once the design is fixed

Install and Connect

Two ways to use StatsPAI; they share the same estimators.

bash
pip install statspai
python
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.

Recommended Agent-Native Workflow

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.

  1. detect_design — infer the study shape (DiD / IV / RDD / SCM / panel), or pass design= explicitly when you already know it.
  2. 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.
  3. Fit with as_handle=true — e.g. callaway_santanna, ivreg, rdrobust, synth. You get a result_id you can chain downstream.
  4. 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.
  5. honest_did_from_result / sensitivity_from_result — design-specific sensitivity (Rambachan-Roth honest bounds, Oster δ, etc.) directly off the handle.
  6. 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.

Worked Execution Snapshot

Before handing results to aer-robustness, leave this shape:

text
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

Mapping AER Identification Strategies to StatsPAI

Each row keeps the modern default from aer-identification; StatsPAI is the execution surface.

StrategyModern default (see aer-identification)StatsPAI entry point
Staggered DiDCallaway-Sant'Anna ATT(g,t); never raw TWFEcallaway_santanna, aggte, did_imputation, sun_abraham, did_multiplegt, lp_did
Forbidden-comparison checkGoodman-Bacon decompositionbacon_decomposition, bacon_plot
Event study / pre-trendsJoint pre-period test, not just the plotevent_study, pretrends_test, honest_did
IV / weak instrumentsAnderson-Rubin, not first-stage F > 10ivreg, anderson_rubin_ci, effective_f_test, tF_adjustment
Shift-share / BartikRotemberg weights or shock-level inferencebartik
RDDLocal-linear, MSE-optimal bandwidth, RBC CIrdrobust, rdbwselect, rdplot, rddensity (McCrary)
Synthetic controlPlacebo inference; modern variantssynth, gsynth, augsynth, sdid, synth_time_placebo, synth_loo
Factor-model counterfactualsInteractive FE / matrix completion for larger treated blocksinteractive_fe, matrix_completion
Bunching / kink designsExcess mass over a polynomial counterfactualbunching, notch
DML / causal MLCross-fit nuisance; honest CIsdml, causal_forest, metalearner, tmle, aipw
Distributional effectsQuantile treatment effects when the mean hides the actionqte
Robustness / few-cluster inferenceSpecification curve; cluster-robust variance; exact randomization testsspec_curve, wild_cluster_bootstrap, twoway_cluster, conley, ri_test
Sensitivity to confounding / multiplicityOster δ-R²; Cinelli-Hazlett robustness value; FWER controloster_delta, oster_bounds, robustness_value, romano_wolf
Partial identification under attritionLee (2009) trimming bounds when selection is differentiallee_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.

Robustness, Heterogeneity, Sensitivity

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 DiD
  • sensitivity_from_result — Oster (2019) δ / unobserved-confounding bounds
  • robustness_value — Cinelli-Hazlett (2020) partial-R² robustness value and bias factor
  • lee_bounds — Lee (2009) trimming bounds under differential attrition
  • evalue_from_result — E-value for observational designs

Publication Export — Hand Off to aer-tables-figures

StatsPAI result objects export directly, which removes manual table assembly:

python
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.

Validation Status — Read It Before Trusting a Number

StatsPAI labels every function with a validation_status. Treat these as a trust tier, not decoration:

  • Certified numerical evidence (benchmarked against Stata / R reference implementations) → safe for a main specification.
  • API-stable breadth (broad coverage, not yet numerically certified end-to-end) → fine for exploration; re-run the headline result against a reference implementation (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.

Red Flags

  • Reporting a StatsPAI estimate as a main AER specification without confirming its validation_status is certified or cross-checking against templates/
  • Letting the unified API tempt you into a worse estimator than aer-identification prescribes (e.g. plain TWFE because it is one call)
  • Skipping audit_result and hand-picking robustness checks — the whole point of the agent-native loop is that it enumerates what you missed
  • Pasting a citation StatsPAI did not return from bibtex — verified keys only

Repository Resources

When working from the AER-skills repository or plugin bundle, load only the relevant resource:

  • Estimator defaults, diagnostics, and primary citations: docs/methods-reference.md
  • The methodological decision that precedes execution: skills/aer-identification/SKILL.md
  • Referee-anticipating checks audit_result should reproduce: skills/aer-robustness/SKILL.md
  • House-style rules for the tables StatsPAI emits: skills/aer-tables-figures/SKILL.md
  • Reference Python implementation to cross-check headline numbers: templates/python/main_did.py
  • Pinned reference-engine dependencies: templates/python/requirements.txt

Use 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.

Handoff

text
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)

Anti-Patterns

  • Treating aer-statspai as a substitute for aer-identification — it executes the design, it does not choose it
  • Shipping an api-stable result as a main top-5 table with no reference cross-check
  • Using the unified API to add a fifth "robustness" estimator that shares the same identifying variation as the main result and calling it confirmation
  • Exporting a table from StatsPAI and skipping aer-tables-figures — the engine emits a table, it does not enforce AER house style

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Aer Statspai?

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.

Firwat Aer Statspai op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Aer Statspai besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Aer Statspai an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/brycewang-stanford/AER-Skills/tree/main/skills/aer-statspai an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Aer Statspai benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Aer Statspai benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Aer Statspai domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Aer Statspai gratis?

Jo. brycewang-stanford huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇