Problem
Analysts often measure the effect of a change that was not assigned at random. The test stores, classes or patients are picked by someone else, or are the best available. Comparing test and control means then mixes the real effect with the existing gap between groups (selection bias). A before/after comparison mixes it with whatever changed over time. Either way the decision rests on a biased estimate.
Example from the article: a school opens advanced math courses, and only the physics and math class attends them. Its grades are higher than the other classes even without the courses, and grades of all classes rise because the topics got easier.
Solution in brief
Measure the metric for every unit before and after the change, in both groups. The test group's change minus the control group's change removes the constant gap between groups and the common time trend. The same number is the interaction coefficient in an OLS regression, and clustered standard errors keep p-values valid.
Questions this case answers
- How to estimate the causal effect of a treatment when assignment to the test group is not random and only before/after data on each unit exist
- How to get valid p-values for a regression on repeated measurements of the same units
- How to estimate the effect of a change when the test group was not chosen at random?
- How to remove selection bias and a common time trend from a before/after comparison?
Tools and methods
- Difference-in-differences (diff-in-diff) — effect estimate from two differences of means, before/after and test/control.
- OLS regression with a group-by-period interaction — gives the effect as one coefficient with a standard error.
- Clustered standard errors — keep the type I error correct when the same unit appears twice.
- Monte Carlo simulation, statsmodels — checks bias and p-value uniformity of each specification.
Google or a one-time email code. No password.
