Lab
Regression Playground
The least-squares line is the one line that makes the total of the squared residuals as small as possible. Add points, drag them, and turn on the squares to see what the line is minimizing.
How to do this lab
- Choose what tapping the graph does in the Tapping the graph menu: Adds a point or Removes a point. Tap empty space to add one, and drag a point to move it.
- Read the Least-squares line, r, r² and Sum of squared residuals readouts. They need at least three points that do not all share one x or one y.
- Use the Show menu to switch among Line only, Residuals, Squared residuals, and My line vs least squares.
- Study the Residual plot under the scatterplot as you add, move or remove points.
- In My line vs least squares, drag the two handles and compare Your line's sum with the least-squares sum. Reset points or Clear all to start over.
What you will learn
- Explain what least squares minimizes: the sum of the squared residuals.
- Describe how one point can change r, the slope and the residual plot.
- Read a residual plot for curvature that a high r hides.
- Interpret r and r² for the points on the screen.
Common mistakes
- Assuming a high r means a line is the right model. Check the residual plot for a curved pattern.
- Expecting every outlier to change the line equally. A point far from the other x-values pulls the line much more than one near the middle.
- Reading r² as r. A correlation of 0.9 gives r² of 0.81.
- Thinking the line must pass through the points. Residuals are the vertical gaps, and the line balances them.
Check your work
- Square r by hand and compare it with the r² readout.
- The slope in the equation should have the same sign as r.
- Your own line's sum should never come out below the least-squares sum. A tie means you found the least-squares line.
Challenges
- Make a set of points with r close to 0.9. Now add one point that drops r below 0.5.
- Drag one point far above the line, near the middle of the x-values. Watch r and the residual plot. A point that does not fit the general pattern can change the picture a lot.
- Show the residual plot. Arrange points so the residual plot shows a curved pattern even though r is high.
- Choose My line and drag its two handles to beat least squares. You cannot. Why not?