did-causal

Estimates heterogeneous treatment effects using DID, TWFE event-study validation, Callaway-Sant'Anna staggered adoption, Bacon decomposition, and placebo tests for panel data in econometrics workflows with Python linearmodels and optional R packages.

33|6|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/xjtulyc/awesome-rosetta-skills --skill did-causal
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: did-causal
Source: https://github.com/xjtulyc/awesome-rosetta-skills/tree/main/skills/07-economics/did-causal
Command: npx skills add https://github.com/xjtulyc/awesome-rosetta-skills --skill did-causal

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires linearmodels, pandas, numpy, matplotlib, statsmodels, did, bacondecomp, fixest, dplyr, ggplot2.

What problem does it solve?

Difference-in-differences methods estimate causal treatment effects, but classic estimators can produce biased results under staggered adoption and heterogeneous effects; this Skill helps you compute credible DID estimates while validating key assumptions.

Core Features & Use Cases

  • Two-Way Fixed Effects (TWFE) DID: Estimate treatment effects with unit and time fixed effects for panel data.
  • Parallel trends pre-testing & event-study plots: Diagnose whether treated and control groups follow similar pre-treatment trends.
  • Staggered adoption support (Callaway-Sant'Anna) & bias diagnosis (Goodman-Bacon): Use C&S ATT(g,t) for heterogeneous staggered rollout and use Bacon decomposition to understand TWFE bias patterns.

Quick Start

Use the did-causal skill to estimate the causal impact of a policy change on an outcome using a panel dataset, including a parallel trends pre-test and (if treatment timing is staggered) a Callaway-Sant'Anna estimator.

Frequently Asked Questions about did-causal

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I estimate difference-in-differences treatment effects with staggered adoption?▼

To estimate difference-in-differences effects with staggered adoption, use the Callaway-Sant'Anna estimator to calculate group-time average treatment effects ATT(g,t), which handles heterogeneous treatment effects across cohorts without the bias of classic methods.

Why does my TWFE DID estimator produce biased results under staggered rollout?▼

TWFE DID estimators produce biased results under staggered rollout because heterogeneous treatment effects contaminate the weights applied to earlier and later treated groups. Use Goodman-Bacon decomposition to diagnose these bias patterns in your panel data.

How do I test for parallel trends before running a DID analysis?▼

To test for parallel trends before running DID analysis, estimate a Two-Way Fixed Effects event-study regression and plot the pre-treatment coefficients. Pre-trend placebo tests check if treated and control groups follow similar trends before treatment.

Can I use Python linearmodels for event-study validation with fixed effects?▼

Yes, you can use Python linearmodels for event-study validation with unit and time fixed effects. It supports TWFE panel data regressions needed to diagnose pre-trends, while optional R packages handle Callaway-Sant'Anna and bacondecomp diagnostics.

What is the best way to diagnose TWFE bias in panel data econometrics?▼

The best way to diagnose TWFE bias in panel data econometrics is Goodman-Bacon decomposition. It breaks down the Two-Way Fixed Effects estimator into individual comparisons, revealing how staggered treatment timing and heterogeneous effects bias the overall estimate.

Do I need R packages to compute Callaway-Sant'Anna ATT estimates if I use Python?▼

You need R packages like did and bacondecomp to compute Callaway-Sant'Anna ATT(g,t) estimates and run Goodman-Bacon decomposition. Python linearmodels handles TWFE and event-study regressions, but the C&S estimator requires the R ecosystem.