Understanding Regression

Regression Foundations Concept demos

Ten short interactive demos that take the mystery out of regression — where R² comes from, why correlation is a regression slope, what a reference category or an interaction term is really doing, and how an omitted variable or a pair of correlated predictors can wreck a reading.

Pick a demo

Each one is self-contained and takes a few minutes. Most ask you to commit to a guess before the controls unlock — being wrong costs nothing and is rather the point.

Building R² from scratch · go at your own pace

Where does actually come from?

You have almost certainly seen R² reported as a single number — something like 0.61 — alongside a claim that the model is doing well, or badly. That is a lot to take on faith, and taking statistics on faith is exactly how it starts feeling like magic.

So let us not take it on faith. Over the next ten pictures we are going to build that number from nothing. By the end you will be able to say precisely what R² counts, because you will have watched it being counted. There is no formula to memorise here.

Go slowly, and use the play buttons. Each picture is the same chart as the one above it with a single new thing added, so nothing ever jumps or reshuffles on you.

THE SETUP — You work for a retail chain with thirty stores. For each store you know how much revenue it brought in last quarter, and revenue is the thing you would like to be able to predict. More information arrives as we go: in a few steps you will find out what each store spent on advertising, and later still whether it sits inside a mall or stands on its own. For now, though, assume you know nothing at all except the revenue figures. That blank slate is where every model starts.

Thirty simulated stores. Everything on this page is computed from that one table — the fitted lines, the squares, and both piles. A note on the piles: the squares are scaled down to fit inside the dashed box, and both piles are scaled by exactly the same amount, which is what makes comparing them fair. The box itself is defined as the total, so the baseline pile fills it completely by construction. If you'd like to check any of this by hand, the raw numbers are in the drawer below.