Causal Inference 101

7 min read

Difference-in-differences (DiD)

Estimate causal effects when a policy or product change hits some groups before others — using before/after and treated/control comparisons.

Difference-in-differences compares the change in outcomes for a treated group to the change for an untreated group. The classic formula: (treated_after − treated_before) − (control_after − control_before).

DiD is standard in policy evaluation: a law applies in one state but not another; wages are tracked before and after. It is also used in product rollouts phased by region.

The parallel trends assumption

DiD assumes that, without treatment, treated and control groups would have followed parallel outcome trends. That cannot be tested directly for the post period, but pre-treatment trends should look similar.

Visualize outcome over time for both groups. Placebo tests (pretend treatment happened earlier) and event-study plots strengthen credibility.

Extensions

Modern DiD handles staggered adoption and heterogeneous timing. When many units switch treatment at different dates, specialized estimators avoid biased weights from simple two-way fixed effects.

Run this method on your data — no Python

CausalLens runs matching, DiD, causal forests, DoWhy refutation, and more — with balance tables, sensitivity checks, and PDF export.