Play n Tools

Free tools & games for everyone

Free · No sign-up · No accounts

Causal inference lab

Draw a causal diagram, test d-separation, find the variables to adjust for (back-door criterion), simulate data and watch Simpson's paradox happen.

How to use

  1. Type arrows, one per line (or load an example), and choose the cause X and the effect Y. X is teal, Y ochre, adjusted variables navy.
  2. Paths and adjustment: list variables to adjust for. The lab shows every path between X and Y, whether it is open or blocked and why, whether X and Y are independent given your list, and the smallest sets that remove confounding.
  3. Simulate: data is made from the diagram (each variable = effect sizes x causes + random noise). Compare the true effect with the naive estimate and with adjusted ones.
  4. Simpson's paradox: type success counts for two treatments in two groups and see whether the winner flips when the groups are added together.

Keyboard and touch

TabMove between tabs, boxes and buttons
EnterIn a box: work it out

Tips

  • Adjust for confounders (common causes), not for mediators (steps between X and Y) or colliders (common effects).
  • Conditioning on a collider opens a path: that is selection bias. Try the collider example with C in the adjust list.
  • In the M-bias example, adjusting for M makes things worse even though M comes before X.
  • More variables in a regression is not automatically better: the back-door criterion says which ones.

About this tool

Paths and independence follow Judea Pearl's d-separation: a path is blocked by a non-collider you adjust for, or by a collider that neither it nor any of its descendants is adjusted for. The lab checks independence with the moralised ancestral graph and lists the paths separately. Adjustment sets satisfy the back-door criterion: no descendant of X, and every path that starts with an arrow into X is blocked.

The simulation is a linear model with standard normal noise, estimated by least squares; the true total effect is the sum over directed paths of the products of effect sizes. Real data has measurement error and hidden variables, so a diagram is an assumption to be argued, not a fact. Everything runs in your browser.

See you tomorrow!

A fresh daily puzzle every morning, and new tools added every month.

Browse every product