Causal Graphs: Confounders, Mediators, Colliders
By the end of this lesson, you should be able to: draw the three ways three variables can be wired together, say what conditioning does to each, explain why two of them are impossible to tell apart from data, and spot the filter that manufactures a correlation out of nothing.
The question and two stories about it
Alder Ads wants to know whether seeing an ad causes a purchase. Here are two accounts of the same business, both entirely plausible, told by two people who have looked at the same dashboard.
The ad works. Someone sees an ad, the ad brings them to the site, and being on the site is what produces the purchase. Ads matter, and the site visit is how they matter.
Intent does everything. Someone already wanted the product. Wanting it is why they searched, which is why the retargeting system showed them an ad, and wanting it is also why they bought. The ad was a bystander.
These are different claims about the world, so you'd expect the data to favour one. It doesn't.
Two structures, one dataset
Simulate both, 200,000 users each, from separate random streams. Then compute every correlation an analyst has access to.
| Pair | Chain | Fork | Gap |
|---|---|---|---|
| Ads with the middle variable | 0.700 | 0.703 | 0.0027 |
| Middle variable with purchase | 0.601 | 0.601 | 0.0000 |
| Ads with purchase | 0.421 | 0.420 | 0.0010 |
The standard error of a correlation at this sample size is about 0.0018, so those gaps are sampling noise. The two structures produce the same correlation matrix, and that isn't a coincidence of the numbers I picked. A chain and a fork over three variables are observationally equivalent, always.
Try to break the tie by conditioning on the middle variable.
| Before | After | |
|---|---|---|
| Chain: condition on the visit | 0.421 | 0.001 |
| Fork: condition on intent | 0.420 | -0.003 |
Both collapse. There's still no way to tell them apart.