Linear regression playground
Least squares under your fingers: drag points and the fitted line chases them, residuals hanging in gold, with b, a, r and R² recomputed live from the same Sxx, Sxy and Syy the exam expects in your working.
Drag points · tap empty space to add
Slope b 0.822
Intercept a 1.236
Correlation r 0.995
R² 0.990
Sxx 60.00
Sxy 49.30
Syy 40.92
n 9
b = Sxy/Sxx, a = ȳ − b·x̄, and the line always passes through the gold ring at (x̄, ȳ) — drag any point and watch the pivot. Try the presets: “Curved” shows a strong relationship with r ≈ 0 (r measures LINEAR association only), and “One outlier” shows a single point dragging the whole fit — least squares squares the residuals, so far points shout loudest.
Three lessons hiding in the drag
First, the fitted line pivots through (x̄, ȳ) — always. That single fact gives the intercept formula and explains why moving an extreme-x point tilts the line so much more than moving a central one: leverage grows with distance from x̄. Second, r measures LINEAR association only. The curved preset has an obvious relationship and a correlation near zero — quote r without plotting and this is the trap that catches you. Third, least squares minimises SQUARED residuals, so a single outlier contributes disproportionately: watch R² collapse in the outlier preset as one point hauls the line towards itself. R² itself is just the squared correlation in the simple-regression case — the share of Syy the regression explains.
The formulas, on paper. The slope, intercept and R² identities live on the CS1 formula cheat sheet, and regression’s big sibling — the GLM — is there too. Memori is a flashcard app built by actuarial students, with a ready-made CS1 set in the shop. Join the beta.
For education only.