Applies DiD, RDD, and IV methods to establish causality from observational data.
Click to play with sound.
---
name: Causal Inference
description: Estimate causal effects from observational data with DiD, RDD, and IV.
---
# Causal Inference
Move from correlation to causation using credible identification strategies. Always state assumptions explicitly.
## Frame the question
Define the treatment, the outcome, the unit, and the counterfactual. Draw a DAG to encode assumptions about confounders, mediators, and colliders. Never condition on a collider or a post-treatment variable.
## Difference-in-Differences (DiD)
Compares the change in outcomes over time between a treated and control group.
Key assumption: parallel trends. Absent treatment, both groups would have moved together.
```python
import statsmodels.formula.api as smf
model = smf.ols("y ~ treated * post", data=df).fit(
cov_type="cluster", cov_kwds={"groups": df["unit"]}
)
```… install to load the full skillSign in to rate and review this skill.
No reviews yet. Be the first to review this skill.