HomeData ScienceInstrumental Variables (2D): Untangling a Confounded Cause

Instrumental Variables (2D): Untangling a Confounded Cause

Interactive 2D instrumental-variables simulator: a hidden confounder biases the naive treatment-effect estimate, and a valid instrument recovers the true causal effect via two-stage least squares, with a drag-to-tilt scatter, instrument-strength diagnostic and a live bias-vs-confounding sweep chart.

Data Science2DAdvanced60 FPS📱 Mobile-adapted⇄ 3D version
2d-ds-topic-73 ↗ Open standalone

Correlation between a treatment X and an outcome Y is not proof that X causes Y — a hidden confounder U can drive both and bias any naive regression. This simulator generates a synthetic cohort where that is exactly what happens, plots it as a draggable 2D scatter that tilts to reveal U as it fans the points apart, and fits two regression lines side by side: the biased naive OLS line, and a two-stage-least-squares line built from a valid instrument Z that moves the treatment without ever touching the outcome directly. A second panel diagnoses the instrument itself (how strongly Z moves X), and a third sweeps confounding strength across its full range to chart how naive bias grows while the IV estimate stays anchored to the truth. Sliders let you dial the true causal effect, the confounding strength, the instrument's strength, the noise level and the cohort size, while live readouts track the true β against both estimates and the instrument's relevance — the same diagnostic economists and epidemiologists run before trusting an IV study.

⚙ Under the hood

A draggable 2D scatter of a confounded cohort tilts to reveal how a hidden variable biases the naive treatment-effect estimate, alongside an instrument-strength diagnostic panel and a live sweep chart showing two-stage least squares recovering the true causal effect across the full confounding range.

causal inferenceinstrumental variables2SLSconfoundingregressiondata science

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)