causal-inference
This skill covers causal inference methods in observational and quasi-experimental settings.
Skill by James-Traina
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/james-traina-causal-inference
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: ml
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
causal-inference- Description
- This skill covers causal inference methods in observational and quasi-experimental settings. Use when the user is implementing, choosing between, or debugging causal identification strategies — including instrumental variables, difference-in-differences, regression discontinuity, synthetic control, or matching estimators. Triggers on "causal effect", "identification strategy", "instrumental variable", "2SLS", "GMM", "difference-in-differences", "DiD", "staggered treatment", "regression discontinuity", "RDD", "synthetic control", "matching", "propensity score", "IPW", "AIPW", "doubly robust", "LATE", "ATT", "ATE", "parallel trends", "exclusion restriction", "first stage", "weak instruments", or "endogeneity".
- License
- MIT
- Instructions
- 220 lines in SKILL.md · view on GitHub
Files (4)
- SKILL.md
- method-implementations.md · references/
- staggered-did.md · references/
- synthetic-control.md · references/
SKILL.md (first lines)
# Causal Inference
Reference for implementing causal inference methods: from identification strategy to estimation to diagnostics and robustness. Covers the major quasi-experimental and observational methods used in applied economics and quantitative social science.
## When to Use This Skill
Use when the user is:
- Choosing an identification strategy for a causal question
- Implementing IV/2SLS, DiD, RDD, synthetic control, or matching
- Debugging specification issues (weak instruments, parallel trends violations, bandwidth sensitivity)
- Running robustness checks or falsification tests
- Working with modern DiD methods for staggered treatment timing
Skip when:
- The task is structural estimation (use `structural-modeling` skill)
- The task is pure prediction/ML (no causal question)
- The user needs simulation design (use `numerical-auditor` agent)
## Where to Start
- **Choosing a method?** Jump to [Method Selection Guide](#method-selection-guide) at the end
- **Implementing a specific method?** Go directly to that method's section below
- **Need full code?** See `references/method-implementations.md` for complete implementations
## Frameworks
Two complementary frameworks underpin all causal inference:
**Potential Outcomes (Rubin):** Define Y(1), Y(0) as potential outcomes under treatment and control. The causal effect is τ = Y(1) - Y(0). The fundamental problem: we never observe both for the same unit. All methods are strategies for constructing valid counterfactuals.
**DAGs (Pearl):** Graphical models encoding conditional independence assumptions. Use d-separation to determine what must be conditioned on (and what must NOT be conditioned on) to identify causal effects. Particularly useful for reasoning about bad controls (colliders, mediators), overcontrol bias, and which instruments satisfy the exclusion restriction.
## Quick Reference: Methods at a Glance
| Method | Key Assumption | Target Parameter | Key Package |
|--------|---------------|-----------------|-------------|
| IV/2SLS | Exclusion restriction, monotonicity | LATE | `linearmodels` (Py), `fixest` (R), `ivregress` (Stata) |
| DiD | Parallel trends | ATT | `fixest` (R), `reghdfe` (Stata), `linearmodels` (Py) |
| RDD | No manipulation, local continuity | LATE at cutoff | `rdrobust` (all) |
| Synthetic Control | Weights reproduce pre-treatment trends | ATT (single unit) | `Synth`/`augsynth` (R) |
| Matching/AIPW | Selection on observables | ATE or ATT | `econml` (Py), `MatchIt`/`WeightIt` (R) |
## Target Parameters
Be precise about what parameter you are estimating:
| Parameter | Definition | Estimated by |
|-----------|-----------|-------------|
| ATE | E[Y(1) - Y(0)] | Randomized experiment, IPW, AIPW |
| ATT | E[Y(1) - Y(0) \| D=1] | DiD, matching, selection-on-observables |
| LATE | E[Y(1) - Y(0) \| compliers] | IV/2SLS (Imbens-Angrist 1994) |
| ATT(g,t) | Group-time specific treatment effect | Staggered DiD (Callaway-Sant'Anna) |
**Common mistake:** IV estimates LATE, not ATE. DiD estimates ATT, not ATE. This matters for policy interpretation.
## Instrumental Variables (IV/2SLS)
**Key idea:** Find a variable Z that shifts D (first stage) but affects Y only through D (exclusion restriction).
```python
from linearmodels.iv import IV2SLS
result = IV2SLS.from_formula(
'lwage ~ 1 + exper + expersq + [educ ~ nearc4 + nearc2]',
data=df
).fit(cov_type='robust')
# Always check first-stage F > 10; report LIML as robustness with weak instruments
```
For R/Stata implementations, weak instrument corrections (LIML, Anderson-Rubin), and overidentification tests, see `references/method-implementations.md`.
**IV Diagnostics Checklist:**
- [ ] First-stage F > 10 (or Olea-Pflueger effective F for robust inference)
- [ ] Exclusion restriction argued substantively (not testable)
- [ ] Monotonicity for LATE interpretation (no defiers)
- [ ] Reduced form significant (regress Y directly on Z)
- [ ] Overidentification test reported if over-identified
- [ ] Compare OLS vs 2SLS — direction and magnitude as expected?
- [ ] Report LATE interpretation — who are the compliers?
## Difference-in-Differences (DiD)
**Key idea:** Compare changes over time between treated and control groups, assuming they would have followed parallel trends absent treatment.
```python
import statsmodels.formula.api as smf
# Standard 2x2 DiD
result = smf.ols('y ~ treated + post + treated:post', data=df).fit(
cov_type='cluster', cov_kwds={'groups': df['state']}
)
# Coefficient on treated:post is the DiD estimate
```
**Staggered treatment timing:** With staggered adoption, TWFE can produce sign-reversed estimates due to negative weights. Use:
- **Callaway-Sant'Anna** (`did` R package): Most flexible aggregation, doubly robust
- **Sun-Abraham** (`fixest::sunab`): Integrates directly into `feols`; simpler for event studies
- **Bacon decomposition** (`bacondecomp` R): Diagnose how much weight TWFE puts on contaminated comparisons
For full staggered DiD code (C-SA, Sun-Abraham, BJS24, de Chaisemartin-D'H), see `references/staggered-did.md`. For event study code and HonestDiD pre-trend sensitivity, see `references/method-implementations.md`.
**DiD Diagnostics Checklist:**
- [ ] Pre-trends: Event study shows no significant pre-treatment coefficients
- [ ] Parallel trends sensitivity: Rambachan-Roth or similar analysis
- [ ] Staggered timing: If varies, use C-SA or S-A — NOT naive TWFE
- [ ] Clustering at level of treatment assignment (typically state/county)
- [ ] Anticipation: Check period just before treatment
- [ ] Bacon decomposition if using TWFE
## Regression Discontinuity (RDD)
**Key idea:** Units just above and below a threshold are locally comparable; the jump at the threshold identifies the causal effect.
```python
from rdrobust import rdrobust, rdbwselect, rdplot
# Basic sharp RD with bias-corrected robust CI
result = rdrobust(y=df['outcome'], x=df['running_var'], c=0)
# Reports: point estimate, robust CI, MSE-optimal bandwidth, N left/rightFrom James-Traina/compound-science, MIT.
Signals
- Stars
- 14
- Forks
- 2
- Open issues
- 1
- Last commit (this folder)
- Mar 29, 2026 (7 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/James-Traina/compound-science
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
Cite this page
causal-inference skill. Agent Mart. https://agentmart.dev/skills/james-traina-causal-inference (last updated 2026-10-24)