Introduction to Linear Regression
This section defines simple linear regression, uses scatter plots to reveal linear patterns, and talks about prediction error. It also discusses how to compute regression line by minimizing squared errors.
Introduction to Linear Regression
- Define linear regression
- Identify errors of prediction in a scatter plot with a regression line
In simple linear regression, we predict scores on one variable from the scores on a second variable. The variable we are predicting is called the criterion variable and is referred to as . The variable we are basing our predictions on is called the predictor variable and is referred to as . When there is only one predictor variable, the prediction method is called simple regression. In simple linear regression, the topic of this section, the predictions of when plotted as a function of form a straight line.
The example data in Table 1 are plotted in Figure 1. You can see that there is a positive relationship between and . If you were going to predict from , the higher the value of , the higher your prediction of .
Figure 1. A scatter plot of the example data.
Linear regression consists of finding the best-fitting straight line through the points. The best-fitting line is called a regression line. The black diagonal line in Figure 2 is the regression line and consists of the predicted score on for each possible value of . The vertical lines from the points to the regression line represent the errors of prediction. As you can see, the red point is very near the regression line; its error of prediction is small. By contrast, the yellow point is much higher than the regression line and therefore its error of prediction is large.
Figure 2. A scatter plot of the example data. The black line consists of the predictions, the points are the actual data, and the vertical lines between the points and the black line represent errors of prediction.
The error of prediction for a point is the value of the point minus the predicted value (the value on the line). Table 2 shows the predicted values () and the errors of prediction . For example, the first point has a of 1.00 and a predicted (called ) of 1.21. Therefore, its error of prediction is -0.21.
Table 2. Example data.
You may have noticed that we did not specify what is meant by "best-fitting line." By far, the most commonly-used criterion for the best-fitting line is the line that minimizes the sum of the squared errors of prediction. That is the criterion that was used to find the line in Figure 2. The last column in Table 2 shows the squared errors of prediction. The sum of the squared errors of prediction shown in Table 2 is lower than it would be for any other regression line.
The formula for a regression line is
where is the predicted score, is the slope of the line, and is the intercept. The equation for the line in Figure 2 is
Computing the Regression Line
In the age of computers, the regression line is typically computed with statistical software. However, the calculations are relatively easy, and are given here for anyone who is interested. The calculations are based on the statistics shown in Table 3. is the mean of , is the mean of , is the standard deviation of , is the standard deviation of , and is the correlation between and .
The slope () can be calculated as follows:
and the intercept () can be calculated as
For these data,
Note that the calculations have all been shown in terms of sample statistics rather than population parameters. The formulas are the same; simply use the parameter values for means, standard deviations, and the correlation.
The regression equation is simpler if variables are standardized so that their means are equal to 0 and standard deviations are equal to 1, for then and . This makes the regression line:
where is the predicted standard score for , is the correlation, and is the standardized score for . Note that the slope of the regression equation for standardized variables is .
A Real Example
The case study "SAT and College GPA" contains high school and university grades for 105 computer science majors at a local state school. We now consider how we could predict a student's university GPA if we knew his or her high school GPA.
Figure 3 shows a scatter plot of University GPA as a function of High School GPA. You can see from the figure that there is a strong positive relationship. The correlation is 0.78. The regression equation is
Therefore, a student with a high school GPA of 3 would be predicted to have a university GPA of
Figure 3. University GPA as a function of High School GPA.
It may surprise you, but the calculations shown in this section are assumption-free. Of course, if the relationship between and were not linear, a different shaped function could fit the data better. Inferential statistics in regression are based on several assumptions, and these assumptions are presented in a later section of this chapter.
Source: David M. Lane , https://onlinestatbook.com/2/regression/intro.html
This work is in the Public Domain.