Pick one of five data sets from the chapter and move the two sliders to draw your own line. Each point sends a vertical segment to your line; the square on that segment has area equal to the squared residual, and the least squares line is the one that makes the total area of the squares as small as possible. The page compares your total with the minimum, shows the residual plot of both lines, and reports r and r2. Then switch on the options: drop one observation (Chemist B), take logarithms (Moore's law), or draw the regression of x on y as well. A high r does not mean a line fits: look at the residuals.
Everything is computed in your browser from the data tables of the book. Only the displayed least squares numbers are exact; the sliders move in small steps. The identity behind the "extra" row is L(b, h) = SSE + Sxx(b − b̂)2 + n(h − ybar)2, with h the height of the line at the mean of x.
code/ch11_regression.py (ols, fit_exponential, r_squared; Figures 11.2.1 to 11.2.6, 11.2.8 and 11.4.1).