Chapter 10: Linear Regression and Correlation

10.3 The Regression Equation

Learning Objectives

By the end of this section, the student should be able to:

  • Create and interpret the line of best fit.
  • Calculate and interpret the correlation coefficient.
  • Calculate and interpret the coefficient of determination.

Data rarely fit a straight line exactly. Usually, you must be satisfied with rough predictions. Typically, you have a set of data whose scatter plot appears to "fit" a straight line. This is called a Line of Best Fit or Least-Squares Line.

Example

A random sample of 11 statistics students produced the following data, where [latex]x[/latex] is the third exam score out of 80, and [latex]y[/latex] is the final exam score out of 200. Can you predict the final exam score of a random student if you know the third exam score?

Table below shows the scores on the final exam based on scores from the third exam.

Table 1: Scores on the Final Exam based on Scores from the Third Exam
[latex]x[/latex] (third exam score) [latex]y[/latex] (final exam score)
65 175
67 133
71 185
71 163
66 126
75 198
67 153
70 163
71 159
69 151
69 159
The scatter plot shows the scores on the final exam based on scores from the third exam.
This is a scatter plot of the data provided. The points form a strong, positive, linear pattern.
Figure 1. The third exam score is plotted on the x-axis, and the final exam score is plotted on the y-axis.

The third exam score, [latex]x[/latex], is the independent variable, and the final exam score, [latex]y[/latex], is the dependent variable. We will plot a regression line that best "fits" the data. If each of you were to fit a line "by eye," you would draw different lines. We can use what is called a least-squares regression line to obtain the best fit line.

Consider the following diagram. Each point of data is of the form [latex](x, y)[/latex] and each point of the line of best fit using least-squares linear regression has the form [latex](x, \hat{y})[/latex].

The [latex]\hat{y}[/latex] is read "y hat" and is the estimated value of [latex]y[/latex]. It is the value of y obtained using the regression line. It is not generally equal to [latex]y[/latex] from data.

 

The scatter plot of exam scores with a line of best fit.
Figure 2. One data point is highlighted along with the corresponding point on the line of best fit. Both points have the same x-coordinate. The distance between these two points illustrates how to compute the sum of squared errors.

The term [latex]y_0 - \hat{y}_0 = \epsilon_0[/latex] is called the "error" or residual. It is not an error in the sense of a mistake. The absolute value of a residual measures the vertical distance between the actual value of [latex]y[/latex] and the estimated value of [latex]y[/latex]. In other words, it measures the vertical distance between the actual data point and the predicted point on the line.

If the observed data point lies above the line, the residual is positive, and the line underestimates the actual data value for [latex]y[/latex]. If the observed data point lies below the line, the residual is negative, and the line overestimates that actual data value for [latex]y[/latex].

In the diagram above, [latex]y_0 - \hat{y}_0 = \epsilon_0[/latex] is the residual for the point shown. Here the point lies above the line and the residual is positive.

[latex]\epsilon =[/latex] the Greek letter epsilon

For each data point, you can calculate the residuals or errors, [latex]y_i - \hat{y}_i = \epsilon_i[/latex] for [latex]i = 1, 2, 3, ..., 11[/latex].

Each [latex]\left| \epsilon \right|[/latex] is a vertical distance.

For the example about the third exam scores and the final exam scores for the 11 statistics students, there are 11 data points. Therefore, there are 11 [latex]\epsilon[/latex] values. If you square each [latex]\epsilon[/latex] and add, you get [latex]{\left({\epsilon }_{1}\right)}^{2}+{\left({\epsilon }_{2}\right)}^{2}+...+{\left({\epsilon }_{11}\right)}^{2}=\stackrel{11}{\underset{i\text{ }=\text{ }1}{\Sigma }}{\epsilon }^{2}[/latex].

This is called the Sum of Squared Errors (SSE).

Using calculus, you can determine the values of [latex]a[/latex] and [latex]b[/latex] that make the SSE a minimum. When you make the SSE a minimum, you have determined the points that are on the line of best fit. It turns out that the line of best fit has the equation:

[latex]\hat{y}=a+bx[/latex] where [latex]a=\overline{y}-b\overline{x}[/latex] and [latex]b=\frac{\Sigma \left(x-\overline{x}\right)\left(y-\overline{y}\right)}{\Sigma {\left(x-\overline{x}\right)}^{2}}[/latex].

The sample means of the x values and the y values are [latex]\overline{x}[/latex] and [latex]\overline{y}[/latex], respectively. The best fit line always passes through the point [latex]\left(\overline{x},\overline{y}\right)[/latex].

The slope [latex]b[/latex] can be written as [latex]b=r\left(\frac{{s}_{y}}{{s}_{x}}\right)[/latex] where [latex]s_y =[/latex] the standard deviation of the [latex]y[/latex] values and [latex]s_x =[/latex] the standard deviation of the x values. [latex]r[/latex] is the correlation coefficient, which is discussed in the next section.

Your Turn!

SCUBA divers have maximum dive times they cannot exceed when going to different depths. The data in the table below show different depths with the maximum dive times in minutes. Find the least squares regression line and predict the maximum dive time for 110 feet.
Table 2: Maximum Dive Time versus Depth in Feet
X (depth in feet) Y (maximum dive time)
50 80
60 55
70 45
80 35
90 25
100 22
Solution

[latex]\hat{y} = 127.24 - 1.11x[/latex]

At 110 feet, a diver could dive for only five minutes.

Least Squares Criteria for Best Fit

The process of fitting the best-fit line is called linear regression. The idea behind finding the best-fit line is based on the assumption that the data are scattered about a straight line. The criteria for the best fit line is that the sum of the squared errors (SSE) is minimized, that is, made as small as possible. Any other line you might choose would have a higher SSE than the best fit line. This best fit line is called the least-squares regression line.

Example: Third Exam vs. Final Exam

The scatter plot with the line of best fit for the third-exam/final-exam example is as follows:

As described in the text above.
Figure 3. The scatter plot of exam scores with a line of best fit.

The least squares regression line (best-fit line) for the third-exam/final-exam example has the equation: [latex]\hat{y}=-173.51+4.83x[/latex]

Reminder

Remember, it is always important to plot a scatter diagram first. If the scatter plot indicates that there is a linear relationship between the variables, then it is reasonable to use a best fit line to make predictions for y given x within the domain of x-values in the sample data, but not necessarily for x-values outside that domain. You could use the line to predict the final exam score for a student who earned a grade of 73 on the third exam. You should NOT use the line to predict the final exam score for a student who earned a grade of 50 on the third exam, because 50 is not within the domain of the x-values in the sample data, which are between 65 and 75.

Understanding Slope

The slope of the line, [latex]b[/latex], describes how changes in the variables are related. It is important to interpret the slope of the line in the context of the situation represented by the data. You should be able to write a sentence interpreting the slope in plain English.

Interpretation of the slope: the slope of the best-fit line tells us how the dependent variable ([latex]y[/latex]) changes for every one unit increase in the independent ([latex]x[/latex]) variable, on average.

Example: Third Exam vs. Final Exam

Slope: The slope of the line is [latex]b = 4.83[/latex].

Interpretation: For a one-point increase in the score on the third exam, the final exam score increases by 4.83 points, on average.

The Correlation Coefficient r

Besides looking at the scatter plot and seeing that a line seems reasonable, how can you tell if the line is a good predictor? Use the correlation coefficient as another indicator (besides the scatterplot) of the strength of the relationship between [latex]x[/latex] and [latex]y[/latex].

The correlation coefficient, [latex]r[/latex], developed by Karl Pearson in the early 1900s, is numerical and provides a measure of strength and direction of the linear association between the independent variable [latex]x[/latex] and the dependent variable [latex]y[/latex].

The correlation coefficient is calculated as [latex]r=\frac{n\Sigma \left(xy\right)-\left(\Sigma x\right)\left(\Sigma y\right)}{\sqrt{\left[n\Sigma {x}^{2}-{\left(\Sigma x\right)}^{2}\right]\left[n\Sigma {y}^{2}-{\left(\Sigma y\right)}^{2}\right]}}[/latex], where [latex]n = \text{the number of data points}[/latex].

If you suspect a linear relationship between [latex]x[/latex] and [latex]y[/latex], then [latex]r[/latex] can measure how strong the linear relationship is.

What the VALUE of [latex]r[/latex] tells us:

  • The value of [latex]r[/latex] is always between –1 and +1: [latex]-1 \le r \le 1[/latex].
  • The size of the correlation [latex]r[/latex] indicates the strength of the linear relationship between [latex]x[/latex] and [latex]y[/latex]. Values of [latex]r[/latex] close to –1 or to +1 indicate a stronger linear relationship between [latex]x[/latex] and [latex]y[/latex].
  • If [latex]r = 0[/latex] there is absolutely no linear relationship between [latex]x[/latex] and [latex]y[/latex] (no linear correlation).
  • If [latex]r = 1[/latex], there is perfect positive correlation. If [latex]r = –1[/latex], there is perfect negative correlation. In both these cases, all of the original data points lie on a straight line. Of course, in the real world, this will not generally happen.

What the SIGN of [latex]r[/latex] tells us:

  • A positive value of [latex]r[/latex] means that when [latex]x[/latex] increases, [latex]y[/latex] tends to increase and when [latex]x[/latex] decreases, [latex]y[/latex] tends to decrease (positive correlation).
  • A negative value of [latex]r[/latex] means that when [latex]x[/latex] increases, [latex]y[/latex] tends to decrease and when [latex]x[/latex] decreases, [latex]y[/latex] tends to increase (negative correlation).
  • The sign of [latex]r[/latex] is the same as the sign of the slope, [latex]b[/latex], of the best-fit line.

Note

Strong correlation does not suggest that [latex]x[/latex] causes [latex]y[/latex] or [latex]y[/latex] causes [latex]x[/latex]. We say "correlation does not imply causation."

Below are three scatter plots with lines of best fit:
(a) A scatter plot showing data with a positive correlation; points ascending from the lower left to the upper right. The line of best fit has positive slope. [latex]0 \lt r \lt 1[/latex]
(b) A scatter plot showing data with a negative correlation; points descending from the upper left to the lower right. The line of best fit has negative slope.  [latex]–1 \lt r \lt 0[/latex]
(c) A scatter plot showing data with zero correlation; points form a horizontal pattern. The line of best fit is a horizontal line. [latex]r = 0[/latex]
As described in the text above.
Figure 4. Correlation Examples

The Coefficient of Determination

The variable [latex]r^2[/latex] is called the coefficient of determination and is the square of the correlation coefficient but is usually stated as a percent rather than in decimal form. It has an interpretation in the context of the data:

  • [latex]{r}^{2}[/latex], when expressed as a percent, represents the percent of variation in the dependent (predicted) variable y that can be explained by variation in the independent (explanatory) variable x using the regression (best-fit) line.
  • 1 – [latex]{r}^{2}[/latex], when expressed as a percentage, represents the percent of variation in y that is NOT explained by variation in x using the regression line. This can be seen as the scattering of the observed data points about the regression line.

 

Let's put all this together with an example from earlier on this page and a new example.

Example

A random sample of 11 statistics students produced the following data, where [latex]x[/latex] is the third exam score out of 80, and [latex]y[/latex] is the final exam score out of 200. Can you predict the final exam score of a random student if you know the third exam score?

Table below shows the scores on the final exam based on scores from the third exam.

Table 3: Scores on the Final Exam based on Scores from the Third Exam
[latex]x[/latex] (third exam score) [latex]y[/latex] (final exam score)
65 175
67 133
71 185
71 163
66 126
75 198
67 153
70 163
71 159
69 151
69 159
  • The scatter plot shows the scores on the final exam based on scores from the third exam.
  • The line of best fit is: [latex]\hat{y} = -173.51 + 4.83x[/latex].
  • The correlation coefficient is [latex]r = 0.6631[/latex].
  • The coefficient of determination is [latex]r^2 = 0.6631^2 = 0.4397[/latex].
  • Interpretation of [latex]r^2[/latex] in the context of this example:
    • Approximately 44% of the variation (0.4397 is approximately 0.44) in the final-exam grades can be explained by the variation in the grades on the third exam, using the best-fit regression line.
    • Therefore, approximately 56% of the variation [latex](1 – 0.44 = 0.56)[/latex] in the final exam grades can NOT be explained by the variation in the grades on the third exam, using the best-fit regression line. (This is seen as the scattering of the points about the line.)

Example

The following data is real. The percent of declared ethnic minority students at De Anza College for selected years from 1970–1995 was:

Table 4: "Student Ethnic Minority Percent" Data
Year Student Ethnic Minority Percentage
1970 14.13
1973 12.27
1976 14.08
1979 18.16
1982 27.64
1983 28.72
1986 31.86
1989 33.14
1992 45.37
1995 53.1
The independent variable is "Year," while the independent variable is "Student Ethnic Minority Percent."
Here is the scatter plot for the data:
This is a scatterplot for the data provided. The points show a strong, curved, upward trend.
Figure 5. Year is plotted on the horizontal axis and percent is plotted on the vertical axis for the "Student Ethnic Minority Percentage"
  • For this data, the Line of Best Fit (Least Squares Line) is y = –3176.909 + 1.617x. This is interpreted as percent = –3176.909 + 1.617 (year #).
  • The correlation coefficient r = 0.961
  • The coefficient of determination is r ^2 = 0.924

Section 10.3 Review

A regression line, or a line of best fit, can be drawn on a scatter plot and used to predict outcomes for the [latex]x[/latex] and [latex]y[/latex] variables in a given data set or sample data. There are several ways to find a regression line, but usually the least-squares regression line is used because it creates a uniform line. Residuals, also called “errors,” measure the distance from the actual value of [latex]y[/latex] and the estimated value of [latex]y[/latex]. The Sum of Squared Errors, when set to its minimum, calculates the points on the line of best fit. Regression lines can be used to predict values within the given set of data, but should not be used to make predictions for values outside the set of data.

The correlation coefficient [latex]r[/latex] measures the strength of the linear association between [latex]x[/latex] and [latex]y[/latex]. The variable [latex]r[/latex] has to be between –1 and +1. When [latex]r[/latex] is positive, the [latex]x[/latex] and [latex]y[/latex] will tend to increase and decrease together. When [latex]r[/latex] is negative, [latex]x[/latex] will increase and [latex]y[/latex] will decrease, or the opposite, [latex]x[/latex] will decrease and [latex]y[/latex] will increase. The coefficient of determination [latex]r^2[/latex], is equal to the square of the correlation coefficient. When expressed as a percent, [latex]r^2[/latex] represents the percent of variation in the dependent variable [latex]y[/latex] that can be explained by variation in the independent variable [latex]x[/latex] using the regression line.

Section 10.3 Practice

A random sample of ten professional athletes produced the following data where x is the number of endorsements the player has and y is the amount of money made (in millions of dollars).

Table 5: Random Sample of 10 Pro Athletes
x y x y
0 2 5 12
3 8 4 9
2 7 3 9
1 3 0 3
5 13 4 10
  1. Draw a scatter plot of the data.
  2. Use regression to find the equation for the line of best fit.
  3. Draw the line of best fit on the scatter plot.
  4. What is the slope of the line of best fit? What does it represent?
  5. What is the y-intercept of the line of best fit? What does it represent?

What does an [latex]r[/latex] value of zero mean?

Solution

It means that there is no correlation between the data sets.

What is the process through which we can calculate a line that goes through a scatter plot with a linear pattern?

Explain what it means when a correlation has an [latex]r^2[/latex] of 0.72.

Solution

It means that 72% of the variation in the dependent variable ([latex]y[/latex]) can be explained by the variation in the independent variable ([latex]x[/latex]).

Can a coefficient of determination be negative? Why or why not?

definition

License

Icon for the Creative Commons Attribution-ShareAlike 4.0 International License

Introductory Statistics Copyright © 2024 by LOUIS: The Louisiana Library Network is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where otherwise noted.