Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
brycewang-stanford avatar

Causal Inference

  • 17 installs
  • 3.2k repo stars
  • Updated August 4, 2026
  • brycewang-stanford/auto-empirical-research-skills

causal-inference is a skill that runs production-grade Bayesian causal inference with PyMC, CausalPy, and DoWhy, enforcing DAG-first thinking and design-specific refutation.

About

causal-inference is a production-grade Bayesian causal-inference workflow using PyMC, CausalPy, and DoWhy. It enforces DAG-first thinking, mandatory user confirmation of assumptions, a design-selection guide (DiD, synthetic control, RDD, IV, ITS), and design-specific refutation before reporting. A researcher uses it to estimate treatment effects and answer 'does X cause Y' questions defensibly. It depends on the bayesian-workflow skill for all PyMC mechanics.

  • Bayesian causal inference with PyMC, CausalPy, and DoWhy
  • DAG-first thinking with mandatory user checkpoints on assumptions
  • Design-specific refutation before any causal claim

Causal Inference by the numbers

  • 17 all-time installs (skills.sh)
  • Ranked #1,288 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

causal-inference capabilities & compatibility

Capabilities
data analysis · research
Use cases
data analysis · research
Pricing
Free
From the docs

What causal-inference says it does

Production-grade Bayesian causal inference with PyMC, CausalPy, and DoWhy. Enforces DAG-first
SKILL.md
**No estimation without a confirmed DAG.**
SKILL.md
**No causal claims without refutation.** Every design has failure modes.
SKILL.md
npx skills add https://github.com/brycewang-stanford/auto-empirical-research-skills --skill causal-inference

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs17
repo stars3.2k
Last updatedAugust 4, 2026
Repositorybrycewang-stanford/auto-empirical-research-skills

What it does

Estimate a causal effect defensibly with a confirmed DAG, a matched design, and mandatory refutation.

Who is it for?

Bayesian causal effect estimation with quasi-experimental designs and mandatory refutation.

Skip if: Pure prediction, or projects with no hypothesis about the causal structure.

When should I use this skill?

Estimating treatment effects, running difference-in-differences, synthetic control, RDD, IV, or answering 'does X cause Y'.

What you get

A defensible causal estimate with a confirmed DAG, an identification strategy, effect sizes with HDIs, and passed refutation tests.

  • confirmed DAG
  • causal estimate with HDIs
  • refutation / robustness results

By the numbers

  • 8-step workflow
  • 9-design selection guide (DiD, staggered DiD, synthetic control, ITS, RDD, IV, IPSW, structural, counterfactual)

Files

SKILL.mdMarkdownGitHub ↗

Causal Inference

Dependencies

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.

Workflow overview

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.

1. Formulate the causal question — Propose precise estimand (ATE, ATT, LATE, etc.). ⚠️ ASK USER TO CONFIRM. 2. Draw the DAG — Propose causal graph with nodes, edges, and explicit non-edges. ⚠️ ASK USER TO CONFIRM. See references/dags-and-identification.md 3. Identify — Determine identification strategy (backdoor, front-door, IV, RDD, DiD). ⚠️ ASK USER TO CONFIRM untestable assumptions. See references/dags-and-identification.md 4. Choose design — Match problem to method using table below. ⚠️ ASK USER TO CONFIRM. See references/quasi-experiments.md or references/structural-models.md 5. Estimate — Build and fit the model. Delegate all PyMC mechanics to bayesian-workflow skill. 6. Refute — MANDATORY. Run design-specific robustness checks. See references/refutation.md 7. Interpret — Effect size + decision-relevant HDIs + probability of direction. 8. Report — Generate causal analysis report. See references/reporting.md

Design selection guide

DesignUse whenKey assumptionTool
DiDTreatment at known time, control group availableParallel trendsCausalPy
Staggered DiDTreatment rolls out at different timesParallel trends per cohortCausalPy
Synthetic ControlSingle treated unit, donor pool availableWeighted donors approximate counterfactualCausalPy
ITSTime series, intervention at known time, no controlNo confounding event at treatment timeCausalPy
RDDTreatment by threshold on running variableNo manipulation at thresholdCausalPy
IVEndogenous treatment, valid instrumentExclusion restriction, relevanceCausalPy
IPSWObservational data, treatment modeledNo unmeasured confounders, positivityCausalPy
Structural (do/observe)Full causal theory, model mechanismsCorrect DAG specificationPyMC
Counterfactual"What would Y have been if X differed?"Correct structural modelPyMC

Critical rules

  • No estimation without a confirmed DAG. A causal graph is not optional decoration — it makes

assumptions explicit and determines the adjustment set. If the user resists, explain why the DAG is non-negotiable before proceeding.

  • No causal claims without refutation. Every design has failure modes. Run at minimum one

design-specific robustness check (placebo test, sensitivity analysis, falsification test) before reporting results. See references/refutation.md.

  • State assumptions before results. Lead with what must be true for the estimate to be causal.

Bury the estimate after the assumptions, not before. This is not optional politeness — it prevents misuse of results.

  • Adapt HDIs to the decision context. The bayesian-workflow skill's 94% HDI is a sensible

default; adapt it with explicit explanation when the decision stakes warrant it (e.g., 89% for exploratory, 97% for high-stakes policy). Report multiple intervals when the decision threshold matters.

  • Downgrade causal language when warranted. If identification assumptions are unverifiable or

refutation raises flags, soften claims: "consistent with a causal effect" not "causes", "estimated effect" not "true effect". Flag uncertainty loudly in the report.

  • Ask the user when domain knowledge is needed. You cannot know whether an instrument is valid,

whether parallel trends holds, or whether a confounder exists without domain expertise. Ask before assuming.

  • Delegate PyMC mechanics to bayesian-workflow. This skill handles causal structure and design.

The bayesian-workflow skill handles priors, sampling, diagnostics, calibration, and reporting format. Don't duplicate those rules here.

Common gotchas

These are battle-tested lessons that save hours of debugging:

  • CausalPy formula syntax uses `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)".

  • DoWhy requires explicit `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.

  • CausalPy's PyMC models don't auto-store log-likelihood. Same issue as bayesian-workflow:

nutpie silently drops it. Call pm.compute_log_likelihood(idata, model=model) after sampling if you need it for model comparison.

  • Parallel trends is untestable in the post-treatment period. Pre-treatment trend tests are

necessary but not sufficient — passing them doesn't prove the assumption holds after treatment. State this explicitly in every DiD report.

  • Synthetic control requires the treated unit to lie within the convex hull of donors. If the

treated unit is an outlier (highest GDP, largest city), no weighted combination of donors can approximate its counterfactual. Check this before running — if violated, the design is invalid.

  • DiD group variable must be dummy-coded (0/1). CausalPy rejects string labels like "treatment"/"control". Use integers: 1 = treatment, 0 = control. Data also requires a unit column.
  • SyntheticControl expects wide-format data. Index = time, columns = unit names, values = outcome. If your data is long format, pivot first: df.pivot(index="date", columns="unit", values="outcome").

When things go wrong

SymptomLikely causeFix
Refutation failsAssumption violatedDiagnose which assumption, try alternative design or sensitivity bounds
DiD effect at placebo timeParallel trends violatedTry synthetic control or add group-specific time trends
RDD: bunching at thresholdManipulation of running variableDesign is invalid for this threshold — report and stop
SC: poor pre-treatment fitDonors don't span treated unitAdd donors, expand donor pool, or reconsider design
DoWhy says "not identifiable"Insufficient adjustment setRevise DAG, add measured variables, or change design
CausalPy formula errorWrong formula syntaxUse C() for categoricals, check variable names match dataframe columns

Related skills

FAQ

Can it estimate an effect without a DAG?

No. It enforces 'No estimation without a confirmed DAG' because the causal graph determines the adjustment set.

Does it depend on other skills?

Yes. It requires the bayesian-workflow skill for all PyMC modeling steps: priors, sampling, diagnostics, calibration, and reporting.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.