Understanding Regression

Regression Foundations Concept demos

Ten short interactive demos on what regression computes. See where R² comes from, why correlation is a regression slope, what reference categories and interaction terms do, and how omitted variables or correlated predictors distort an estimate.

Pick a demo

Each demo is self-contained and takes a few minutes. Most ask you to commit to a guess before the controls open. Being wrong costs nothing, and it makes the surprise stick.

Building R² from scratch · go at your own pace

Where does R² actually come from?

You have probably seen R² reported as a single number, such as 0.61, alongside a claim that the model is doing well or badly. Taking that number on faith leaves you guessing what it actually counts.

Over the next ten pictures you will build that number from scratch, watching what R² counts rather than taking it on trust. 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 want to predict. More information arrives as you 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 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.