This demonstration allows you to explore fitting data with linear functions. When the demonstration begins, five points are plotted in the graph. The X axis ranges from 1 to 5 and the Y axis ranges from 0 to 5. The five points are plotted in different colors; next to each point is the Y value of that point. For example, the red point has the value 1.00 next to it. A vertical black line is drawn with the Y value of 3.0; this line consists of the predicted values for Y. (It is clear that this line does not contain the best predictions.) This line is called the "regression line." The equation for the regression line is Y' = 0X +3 where Y' is the predicted value for Y. Since the slope is 0, the same prediction of 3 is made for all values of X.
The error of prediction for each point is represented by a vertical line between the point and the regression line. For the point with a value of 1 on the X axis, the line goes from the point (1,1) to the point (1,3) on the line. The length of the vertical line is 2. This means the error of prediction is 2 and the squared error of prediction is 2 x 2 = 4. This error is depicted graphically by the graph on the right. The height of the red square is the error of prediction and the area of the red square is the squared error of prediction.
The errors associated with the other points are plotted in a similar way. Therefore the height of the stacked squares is the sum of the errors of prediction (the lengths of the lines are used, so all errors are positive) and the area of all squares is the total sum of squared errors.
This demonstration allows you to change the regression line and examine the effects on the errors of prediction. If you click and drag an end of the line, the slope of the line will change. If you click and drag the middle of the line, the intercept will change. As the line changes, the errors and squared errors are updated automatically.
You can also change the values of the points by clicking on them and dragging. You can only change the Y values.
You can get a good feeling for the regression line and error by changing the points and the slope and intercept of the line and observing the results.
To see the line that minimizes the squared errors of prediction click the "OK" button.