skills/23-Learning-Bayesian-Statistics-baygent-skills/causal-inference/SKILL.md
Production-grade Bayesian causal inference with PyMC, CausalPy, and DoWhy. Enforces DAG-first thinking, mandatory user checkpoints for assumptions, design-specific refutation, and defensible reporting with causal language guardrails. Trigger on: causal inference, causal effect estimation, treatment effects, counterfactuals, difference-in-differences (DiD), synthetic control, regression discontinuity (RDD), interrupted time series (ITS), instrumental variables (IV), propensity scores, DAGs, causal graphs, confounders, backdoor criterion, do-calculus, interventional distributions, pm.do(), pm.observe(), CausalPy, DoWhy, mediation analysis, refutation, sensitivity analysis, parallel trends, placebo tests, or any question of the form "does X cause Y" or "what is the effect of X on Y."
npx skillsauth add brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research causal-inferenceInstall 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.
This skill requires the bayesian-workflow skill for all PyMC modeling steps (priors, sampling, diagnostics, calibration, reporting).
Detect it:
ls ~/.claude/skills/bayesian-workflow/SKILL.md 2>/dev/null || ls .claude/skills/bayesian-workflow/SKILL.md 2>/dev/null
If not found, install it:
git clone https://github.com/Learning-Bayesian-Statistics/baygent-skills.git /tmp/baygent-skills
cp -r /tmp/baygent-skills/bayesian-workflow ~/.claude/skills/
For all PyMC modeling steps (priors, sampling, diagnostics, calibration, reporting), follow the bayesian-workflow skill.
Every causal analysis follows this sequence. Steps 1-4 are the thinking phase (no code). Steps 5-8 are the doing phase. Think before you do.
| Design | Use when | Key assumption | Tool | |---|---|---|---| | DiD | Treatment at known time, control group available | Parallel trends | CausalPy | | Staggered DiD | Treatment rolls out at different times | Parallel trends per cohort | CausalPy | | Synthetic Control | Single treated unit, donor pool available | Weighted donors approximate counterfactual | CausalPy | | ITS | Time series, intervention at known time, no control | No confounding event at treatment time | CausalPy | | RDD | Treatment by threshold on running variable | No manipulation at threshold | CausalPy | | IV | Endogenous treatment, valid instrument | Exclusion restriction, relevance | CausalPy | | IPSW | Observational data, treatment modeled | No unmeasured confounders, positivity | CausalPy | | Structural (do/observe) | Full causal theory, model mechanisms | Correct DAG specification | PyMC | | Counterfactual | "What would Y have been if X differed?" | Correct structural model | PyMC |
These are battle-tested lessons that save hours of debugging:
C() for categoricals. Passing a string column directly without
C() will silently produce wrong dummy coding. Always wrap categorical treatment and group
variables: "y ~ C(treatment) + C(group)".U nodes for unobserved confounders. Omitting them from the graph
will make DoWhy treat your model as fully identified when it isn't. Add latent nodes explicitly
and mark them as unobserved.pm.compute_log_likelihood(idata, model=model) after sampling if
you need it for model comparison.unit column.df.pivot(index="date", columns="unit", values="outcome").| Symptom | Likely cause | Fix |
|---|---|---|
| Refutation fails | Assumption violated | Diagnose which assumption, try alternative design or sensitivity bounds |
| DiD effect at placebo time | Parallel trends violated | Try synthetic control or add group-specific time trends |
| RDD: bunching at threshold | Manipulation of running variable | Design is invalid for this threshold — report and stop |
| SC: poor pre-treatment fit | Donors don't span treated unit | Add donors, expand donor pool, or reconsider design |
| DoWhy says "not identifiable" | Insufficient adjustment set | Revise DAG, add measured variables, or change design |
| CausalPy formula error | Wrong formula syntax | Use C() for categoricals, check variable names match dataframe columns |
tools
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.