# Causal Inference Mixtape

Should be used when the user asks to "implement a DiD regression", "write a causal...

- Repository: https://github.com/brycewang-stanford/Auto-Empirical-Research-Skills (4869 stars)
- Category: Design
- License: see repository
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-mixtape -g -a claude-code -y`
Codex: `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-mixtape -g -a codex -y`
Cursor: `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-mixtape -g -a cursor -y`
Gemini CLI: `npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-mixtape -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add brycewang-stanford/Auto-Empirical-Research-Skills`

## Description

This skill should be used when the user asks to "implement a DiD regression", "write a causal inference pipeline", "set up an event study", "implement instrumental variables", "run a regression discontinuity design", "build a synthetic control model", "implement propensity score matching", "write parallel trends test", "implement Bacon decomposition", or needs code templates for causal inference methods in Python, R, or Stata. Based on Scott Cunningham''s Causal Inference: The Mixtape.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Causal Inference: The Mixtape, Code Skill

Practitioner-oriented causal inference skill built from Scott Cunningham's *Causal Inference: The Mixtape* repository. Covers 10 identification strategies with ready-to-run code templates in Python, R, and Stata.

---

## Methods Covered

| Method | Python | R | Stata | Reference |
|--------|--------|---|-------|-----------|
| OLS / Regression | statsmodels | estimatr | reg/reghdfe | `references/method-patterns.md` §1 |
| Difference-in-Differences | statsmodels + C() | lfe/fixest | xtreg/reghdfe | `references/method-patterns.md` §2 |
| Event Study (Dynamic DiD) | manual lead/lag | estimatr | reghdfe | `references/method-patterns.md` §3 |
| Staggered DiD / TWFE | statsmodels | bacondecomp | bacondecomp | `references/method-patterns.md` §4 |
| Regression Discontinuity | statsmodels polynomial | rdrobust | rdplot/rdrobust | `references/method-patterns.md` §5 |
| Instrumental Variables | linearmodels IV2SLS | AER/ivreg | ivregress 2sls | `references/method-patterns.md` §6 |
| Synthetic Control | rpy2 → R Synth | Synth + SCtools | synth | `references/method-patterns.md` §7 |
| Matching / PSM / IPW | manual logit + weights | MatchIt + Zelig | teffects/cem | `references/method-patterns.md` §8 |
| DAGs / Collider Bias | dagitty (conceptual) | dagitty/ggdag |, | `references/method-patterns.md` §9 |
| Randomization Inference | permutation loop | ri2 | ritest | `references/method-patterns.md` §10 |

---

## Core Workflow

### Implement a Causal Method

1. Identify the method from the table above
2. Load the appropriate template from `references/method-patterns.md`
3. Adapt variable names, fixed effects, and clustering to the user's data
4. Add robustness checks (parallel trends for DiD, McCrary for RDD, first-stage F for IV)

### Choose the Right Language

The rest: https://github.com/brycewang-stanford/Auto-Empirical-Research-Skills/blob/HEAD/skills/10-Jill0099-causal-inference-mixtape/SKILL.md
