Interactive demo · Introduction to Mathematical Statistics · Chapter 11

Least squares, residuals and what r hides

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.

Data set

Your line

slope b
height at xbar

Options

Try these

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.

In the lecture notes