pipeline
Classical end-to-end empirical analysis workflow in the traditional Python econometric stack — pandas + numpy + scipy +…
Run IV, DiD, and RDD analyses in R with proper diagnostics. Use when implementing causal inference methods, event studies, or treatment effect estimation.
Claude Code
$ npx -y skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-r --agent claude-code
Codex
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-r -a codex -y
Cursor
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-r -a cursor -y
Gemini CLI
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-r -a gemini-cli -y
GitHub Copilot
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-r -a github-copilot -y
OpenCode
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-r -a opencode -y
Windsurf
$ npx skills add brycewang-stanford/Auto-Empirical-Research-Skills --skill causal-inference-r -a windsurf -y
name: causal-inference-r description: Run IV, DiD, and RDD analyses in R with proper diagnostics. Use when implementing causal inference methods, event studies, or treatment effect estimation.
This skill helps economists run rigorous econometric analyses in R, including Instrumental Variables (IV), Difference-in-Differences (DiD), and Regression Discontinuity Design (RDD). It generates publication-ready code with proper diagnostics and robust standard errors.
Before generating code, ask the user: 1. What is your identification strategy? (IV, DiD, RDD, or simple regression) 2. What is the unit of observation? (individual, firm, country-year, etc.) 3. What fixed effects do you need? (entity, time, two-way) 4. How should standard errors be clustered?
Based on the research design, generate R code that:
1. **Uses the `fixest` package** - Modern, fast, and feature-rich for panel data 2. **Includes proper diagnostics:**
3. **Uses robust/clustered standard errors** appropriate for the data structure 4. **Creates publication-ready output** using `modelsummary` or `etable`
Always include:
# 1. Setup and packages # 2. Data loading and preparation # 3. Descriptive statistics # 4. Main specification # 5. Robustness checks # 6. Visualization # 7. Export results
Include comments explaining:
# ============================================
# Difference-in-Differences Analysis
# ============================================
# Setup
library(tidyverse)
library(fixest)
library(modelsummary)
# Load data
df <- read_csv("data.csv")
# Prepare treatment variable
df <- df %>%
mutate(
post = year >= treatment_year,
treated = state %in% treatment_states,
treat_post = treated * post
)
# ----------------------------------------
# Main DiD Specification
# ----------------------------------------
# Two-way fixed effects
did_model <- feols(
outcome ~ treat_post | state + year,
data = df,
cluster = ~state
)
# View results
summary(did_model)
# ----------------------------------------
# Event Study
# ----------------------------------------
# Create relative time variable
df <- df %>%
mutate(rel_time = year - treatment_year)
# Event study regression
event_study <- feols(
outcome ~ i(rel_time, treated, ref = -1) | state + year,
data = df,
cluster = ~state
)
# Plot coefficients
iplot(event_study,
main = "Event Study: Effect on Outcome",
xlab = "Years Relative to Treatment")
# ----------------------------------------
# Robustness: Alternative Specifications
# ----------------------------------------
# Different clustering
did_robust <- feols(
outcome ~ treat_post | state + year,
data = df,
cluster = ~state + year # Two-way clustering
)
# ----------------------------------------
# Export Results
# ----------------------------------------
modelsummary(
list("Main" = did_model, "Two-way Cluster" = did_robust),
stars = c('*' = 0.1, '**' = 0.05, '***' = 0.01),
output = "results/did_table.tex"
)Install with:
install.packages(c("fixest", "modelsummary", "tidyverse"))1. **Always cluster standard errors** at the level of treatment assignment 2. **Run pre-trend tests** for DiD designs 3. **Report first-stage F-statistics** for IV (should be > 10) 4. **Use `feols` over `lm`** for panel data (faster and more features) 5. **Document all specification choices** in your code comments
## 🔥 力荐 · StatsPAI — Stata 与 R 的 Python 平替,为 AI Agent 而生 🔁 Stata / R 平替:reghdfe、csdid、rdrobust、synth、fixest、did 等常用命令在 Python 中一站式替代,一个 import statspai as sp 搞定 DID / RD / IV / SCM / DML / matching 🤖 面向 Agent 设计:结构化结果对象 + 内置 MCP Server,Claude / Codex
Classical end-to-end empirical analysis workflow in the traditional Python econometric stack — pandas + numpy + scipy +…
Use when the user asks to run a full empirical / causal analysis in Python — by default in the style of an applied economics…
Classical end-to-end empirical analysis workflow in the traditional Python econometric stack — pandas + numpy + scipy +…
Classical end-to-end empirical analysis workflow in the traditional Stata ecosystem — native Stata + reghdfe + ivreg2 + csdid +…
Classical end-to-end empirical analysis workflow in the modern tidyverse + econometrics R ecosystem — dplyr + tidyr + haven +…
Systematic writing framework for philosophy and interdisciplinary academic papers from optimized outline to submission-ready…
Direct browser control via CDP for web interaction: automation, scraping, testing, screenshots, and site/app work. Also covers…
Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling…