"

Chapter 10: Linear Regression and Correlation

10.6 Outliers

Learning Objectives

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

  • Find and interpret outliers between two quantitative variables.

In some data sets, there are values (observed data points) called outliers. Outliers are observed data points that are far from the least squares line. They have large "errors", where the "error" or residual is the vertical distance from the line to the point.

Outliers need to be examined closely. Sometimes, for some reason or another, they should not be included in the analysis of the data. It is possible that an outlier is a result of erroneous data. Other times, an outlier may hold valuable information about the population under study and should remain included in the data. The key is to examine carefully what causes a data point to be an outlier.

Besides outliers, a sample may contain one or a few points that are called influential points. Influential points are observed data points that are far from the other observed data points in the horizontal direction. These points may have a big effect on the slope of the regression line. To begin to identify an influential point, you can remove it from the data set and see if the slope of the regression line has changed significantly.

Identifying Outliers

We could guess at outliers by looking at a graph of the scatter plot and best fit-line. However, we would like some guideline as to how far away a point needs to be in order to be considered an outlier. As a rough rule of thumb, we can flag any point that is located further than two standard deviations above or below the best-fit line as an outlier. The standard deviation used is the standard deviation of the residuals or errors.

We can do this visually in the scatter plot by drawing an extra pair of lines that are two standard deviations above and below the best-fit line. Any data points that are outside this extra pair of lines are flagged as potential outliers. Or we can do this numerically by calculating each residual and comparing it to twice the standard deviation. The graphical procedure is shown first, followed by the numerical calculations. You would generally need to use only one of these methods.

Graphical Identification of Outliers

Let's see the same third exam versus final exam example.

Note: If there is an outlier, as an exercise, delete it and fit the remaining data to a new line. For this example, the new line ought to fit the remaining data better. This means the SSE should be smaller and the correlation coefficient ought to be closer to 1 or –1.

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

For our example, the line of best fit is: [latex]\hat{y} = -173.51 + 4.83x[/latex]

If we were to measure the vertical distance from any data point to the corresponding point on the line of best fit and that distance was equal to [latex]2s[/latex] or more, then we would consider the data point to be "too far" from the line of best fit. We need to find and graph the lines that are two standard deviations below and above the regression line. Any points that are outside these two lines are outliers.

We first calculate this standard deviation: [latex]s = 16.412[/latex].

Graph the scatter plot with the best fit line ([latex]\hat{y} = -173.51 + 4.83x[/latex]), then the two lines that are two standard deviations below and above the regression line ([latex]y = –173.5 + 4.83x –2(16.4)[/latex] and line [latex]y = –173.5 + 4.83x + 2(16.4)[/latex].

This is seen below:

A scatter plot with a line of best fit. Two yellow dashed lines run parallel to the line of best fit, above and below the best fit line at equal distances.
Figure 1. One data point falls outside the boundary created by the dashed lines—it is an outlier.

 

You will find that the only data point that is not between the lines is the point [latex]x = 65[/latex], [latex]y = 175[/latex]. It is just barely outside these lines.

The outlier is the student who had a grade of 65 on the third exam and 175 on the final exam; this point is farther than two standard deviations away from the best-fit line.

Sometimes a point is so close to the lines used to flag outliers on the graph that it is difficult to tell if the point is between or outside the lines. Note that when the graph does not give a clear enough picture, you can use the numerical comparisons to identify outliers.

Your Turn!

Identify the potential outlier in the scatter plot. The standard deviation of the residuals or errors is approximately 8.6.

Scatter plot with data and line of best fit. One data point away from the line of best fit is considered an outlier.
Figure 2. Outlier Example
Solution

The outlier appears to be at (6, 58). The expected [latex]y[/latex] value on the line for the point (6, 58) is approximately 82. Fifty-eight is 24 units from 82. Twenty-four is more than two standard deviations [latex](2s = 2(8.6) = 17.2)[/latex]. So 82 is more than two standard deviations from 58, which makes (6, 58) a potential outlier.

Numerical Identification of Outliers

In the third/final exam example in Section 10.2, the first two columns are the third-exam and final-exam data. The third column shows the predicted [latex]\hat{y}[/latex] values calculated from the line of best fit: [latex]\hat{y} = –173.5 + 4.83x[/latex]. The residuals, or errors, have been calculated in the fourth column of the table: [latex]\text{observed } y \text{ value} − \text{predicted } y \text{ value} = y − \hat{y}[/latex].

[latex]s[/latex] is the standard deviation of all the [latex]y − \hat{y} = \epsilon[/latex] values where [latex]n = \text{the total number of data points}[/latex]. If each residual is calculated and squared, and the results are added, we get the SSE. The standard deviation of the residuals is calculated from the SSE as [latex]s=\sqrt{\frac{\text{SSE}}{n-2}}[/latex]

Numerical Identification of Outliers: Calculating s and Finding Outliers Manually

You can calculate the outlier in the first example by doing the following.

First, square each [latex]| y – \hat{y} |[/latex].

The squares are [latex]35^2; 17^2; 16^2; 6^2; 19^2; 9^2; 3^2; 1^2; 10^2; 9^2; 1^2[/latex]

Then, add (sum) all the [latex]| y – \hat{y} | ^2[/latex] terms using the formula

[latex]\stackrel{11}{\underset{i = 1}{\Sigma }}{\left(|{y}_{i}-{\hat{y}}_{i}|\right)}^{2}=\stackrel{11}{\underset{i = 1}{\Sigma }}{\epsilon_i}^{2}[/latex] (Recall that [latex]y_i – \hat{y}_i = \epsilon_i[/latex].)

[latex]= 35^2 + 17^2 + 16^2 + 6^2 + 19^2 + 9^2 + 3^2 + 1^2 + 10^2 + 9^2 + 1^2 = 2440 = \text{SSE}[/latex]

The result, SSE, is the Sum of Squared Errors.

Next, calculate [latex]s[/latex], the standard deviation of all the [latex]y – \hat{y} = \epsilon[/latex] values where [latex]n = \text{the total number of data points}[/latex].

The calculation is [latex]s=\sqrt{\frac{\text{SSE}}{n–2}}[/latex].

For the third exam/final exam problem, [latex]s=\sqrt{\frac{2440}{11–2}}=16.47[/latex].

Next, multiply [latex]s[/latex] by 2:

[latex](2)(16.47) = 32.94[/latex]

32.94 is 2 standard deviations away from the mean of the [latex]y – \hat{y}[/latex] values.

If we were to measure the vertical distance from any data point to the corresponding point on the line of best fit and that distance is at least [latex]2s[/latex], then we would consider the data point to be "too far" from the line of best fit. We call that point a potential outlier.

For the example, if any of the [latex]|y - \hat{y}|[/latex] values are at least 32.94, the corresponding [latex](x, y)[/latex] data point is a potential outlier.

For the third exam/final exam problem, all the [latex]|y – \hat{y}|[/latex]'s are less than 31.29 except for the first one which is 35.

[latex]35 > 31.29[/latex] That is, [latex]|y – \hat{y}| \ge (2)(s)[/latex]

The point which corresponds to [latex]|y - \hat{y}| = 35[/latex] is [latex](65, 175)[/latex]. Therefore, the data point [latex](65, 175)[/latex] is a potential outlier. For this example, we will delete it. (Remember, we do not always delete an outlier.)

Note: When outliers are deleted, the researcher should either record that data was deleted, and why, or the researcher should provide results both with and without the deleted data. If data is erroneous and the correct values are known (e.g., student one actually scored a 70 instead of a 65), then this correction can be made to the data.

The next step is to compute a new best-fit line using the ten remaining points. The new line of best fit and the correlation coefficient are [latex]\hat{y} = –355.19 + 7.39x[/latex] and [latex]r = 0.9121[/latex].

Note

We divide by [latex](n – 2)[/latex] because the regression model involves two estimates.

Rather than calculate the value of [latex]s[/latex] for the residuals ourselves, we can find s using the calculator (this was shown how to do earlier in the textbook). For this example, [latex]s = 16.4[/latex] of the residuals 35; –17; 16; –6; –19; 9; 3; –1; –10; –9; –1.

Table 2: Calculations of Standard Deviation
[latex]x[/latex] [latex]y[/latex] [latex]\hat{y}[/latex] [latex]y – \hat{y}[/latex]
65 175 140 175 – 140 = 35
67 133 150 133 – 150= –17
71 185 169 185 – 169 = 16
71 163 169 163 – 169 = –6
66 126 145 126 – 145 = –19
75 198 189 198 – 189 = 9
67 153 150 153 – 150 = 3
70 163 164 163 – 164 = –1
71 159 169 159 – 169 = –10
69 151 160 151 – 160 = –9
69 159 160 159 – 160 = –1

We are looking for all data points for which the residual is greater than [latex]2s = 2(16.4) = 32.8[/latex] or less than –32.8. Compare these values to the residuals in column four of the table. The only such data point is the student who had a grade of 65 on the third exam and 175 on the final exam; the residual for this student is 35.

How Does the Outlier Affect the Best Fit Line?

In the third exam/final exam example, numerically and graphically, we have identified the point (65, 175) as an outlier. We should re-examine the data for this point to see if there are any problems with the data. If there is an error, we should fix the error if possible, or delete the data. If the data is correct, we would leave it in the data set. For this problem, we will suppose that we examined the data and found that this outlier data was an error. Therefore, we will continue on and delete the outlier, so that we can explore how it affects the results, as a learning experience. If you compute a new best-fit line and correlation coefficient using the ten remaining points, you get the new line of best fit and the correlation coefficient are [latex]\hat{y} = –355.19 + 7.39x[/latex] and [latex]r = 0.9121[/latex].

The new line with [latex]r = 0.9121[/latex] is a stronger correlation than the original ([latex]r = 0.6631[/latex]) because [latex]r = 0.9121[/latex] is closer to one. This means that the new line is a better fit to the ten remaining data values. The line can better predict the final exam score given the third exam score.

Example

Using this new line of best fit (based on the remaining ten data points from the third exam/final exam example), what would a student who receives a 73 on the third exam expect to receive on the final exam? Is this the same as the prediction made using the original line?

Solution

Using the new line of best fit, [latex]\hat{y} = –355.19 + 7.39(73) = 184.28[/latex]. A student who scored 73 points on the third exam would expect to earn 184 points on the final exam.

The original line predicted [latex]\hat{y} = –173.51 + 4.83(73) = 179.08[/latex] so the prediction using the new line with the outlier eliminated differs from the original prediction.

Your Turn!

The data points for the graph from the third exam/final exam example are as follows: (1, 5), (2, 7), (2, 6), (3, 9), (4, 12), (4, 13), (5, 18), (6, 19), (7, 12), and (7, 21). Remove the outlier and recalculate the line of best fit. Find the value of [latex]\hat{y}[/latex] when [latex]x = 10[/latex].

Solution

[latex]\hat{y} = 1.04 + 2.96x; 30.64[/latex]

Example

The Consumer Price Index (CPI) measures the average change over time in the prices paid by urban consumers for consumer goods and services. The CPI affects nearly all Americans because of the many ways it is used. One of its biggest uses is as a measure of inflation. By providing information about price changes in the Nation's economy to government, business, and labor, the CPI helps them to make economic decisions. The president, Congress, and the Federal Reserve Board use the CPI's trends to formulate monetary and fiscal policies. In the following table, x is the year and y is the CPI.

Table 3: Data of CPI for Years
[latex]x[/latex] [latex]y[/latex] [latex]x[/latex] [latex]y[/latex]
1915 10.1 1969 36.7
1926 17.7 1975 49.3
1935 13.7 1979 72.6
1940 14.7 1980 82.4
1947 24.1 1986 109.6
1952 26.5 1991 130.7
1964 31.0 1999 166.6
  1. Draw a scatter plot of the data.
  2. Calculate the least squares line. Write the equation in the form [latex]\hat{y} = a + bx[/latex].
  3. Draw the line on the scatter plot.
  4. Find the correlation coefficient. Is it significant?
  5. What is the average CPI for the year 1990?
Solution
  1. Scatter plot and line of best fit of the consumer price index data, on the y-axis, and year data, on the x-axis.
    Figure 3. Scatter Plot for Example
  2. [latex]\hat{y} = –3204 + 1.662x[/latex] is the equation of the line of best fit.
  3. [latex]r = 0.8694[/latex]
  4. The number of data points is [latex]n = 14[/latex]. Use the 95% Critical Values of the Sample Correlation Coefficient table. [latex]n – 2 = 12[/latex]. The corresponding critical value is [latex]0.532[/latex]. Since [latex]0.8694 > 0.532[/latex], [latex]r[/latex] is significant. [latex]\hat{y} = –3204 + 1.662(1990) = 103.4 CPI[/latex]
  5. We find that [latex]s = 25.4[/latex]; graphing the lines [latex]Y = –3204 + 1.662X – 2(25.4)[/latex] and [latex]Y = –3204 + 1.662X + 2(25.4)[/latex] shows that no data values are outside those lines, identifying no outliers. (Note that the year 1999 was very close to the upper line, but still inside it.)

Note

In the example, notice the pattern of the points compared to the line. Although the correlation coefficient is significant, the pattern in the scatter plot indicates that a curve would be a more appropriate model to use than a line. In this example, a statistician should prefer to use other methods to fit a curve to this data, rather than model the data with the line we found. In addition to doing the calculations, it is always important to look at the scatter plot when deciding whether a linear model is appropriate.

Your Turn!

The following table shows economic development measured in per capita income PCINC.

Table 4: Year and PCINC
Year PCINC Year PCINC
1870 340 1920 1050
1880 499 1930 1170
1890 592 1940 1364
1900 757 1950 1836
1910 927 1960 2132
  1. What are the independent and dependent variables?
  2. Draw a scatter plot.
  3. Use regression to find the line of best fit and the correlation coefficient.
  4. Interpret the significance of the correlation coefficient.
  5. Is there a linear relationship between the variables?
  6. Find the coefficient of determination and interpret it.
  7. What is the slope of the regression equation? What does it mean?
  8. Use the line of best fit to estimate PCINC for 1900, for 2000.
  9. Determine if there are any outliers.
Solution
  1. The independent variable ([latex]x[/latex]) is the year and the dependent variable ([latex]y[/latex]) is the per capita income.
  2. Scatter plot shown below.
  3. [latex]\hat{y} = 18.61x – 34574; r = 0.9732[/latex]
  4. At [latex]df = 8[/latex], the critical value is [latex]0.632[/latex]. The [latex]r[/latex] value is significant because it is greater than the critical value.
  5. There does appear to be a linear relationship between the variables.
  6. The coefficient of determination is [latex]0.947[/latex], which means that 94.7% of the variation in PCINC is explained by the variation in the years.
  7. The slope of the regression equation is 18.61, and it means that per capita income increases by $18.61 for each passing year.
  8. [latex]\hat{y} = 785[/latex] when the year is 1900, and [latex]\hat{y} = 2,646[/latex] when the year is 2000.
  9. There do not appear to be any outliers.
Scatter plot with Year on x-axis and PCINC on y-axis.
Figure 4. Scatter Plot for Example

Videos

Below are helpful videos for the content covered in this Section. Videos are provided from YouTube.

Section 10.6 Review

To determine if a point is an outlier, do one of the following:

  • Graph [latex]\begin{array}{l}{y}_{1}=a+bx\hfill \\ {y}_{2}=\left(2s\right)a+bx\hfill \\ {y}_{3}=-\left(2s\right)a+bx\hfill \end{array}[/latex] where [latex]s[/latex] is the standard deviation of the residuals
  • If any point is above [latex]y_2[/latex] or below [latex]y_3[/latex] then the point is considered to be an outlier.

You can also use the residuals and compare their absolute values to [latex]2s[/latex] where s is the standard deviation of the residuals. If the absolute value of any residual is greater than or equal to [latex]2s[/latex], then the corresponding point is an outlier.

Section 10.6 Practice

The scatter plot shows the relationship between hours spent studying and exam scores. The line shown is the calculated line of best fit. The correlation coefficient is 0.69.

Scatter plot with data and line of best fit. One data point away from the line of best fit is considered an outlier.
Figure 5. Outlier Example
  1. Do there appear to be any outliers?
  2. A point is removed, and the line of best fit is recalculated. The new correlation coefficient is 0.98. Does the point appear to have been an outlier? Why?
  3. What effect did the potential outlier have on the line of best fit?
  4. Are you more or less confident in the predictive ability of the new line of best fit?

The Sum of Squared Errors for a data set of 18 numbers is 49. What is the standard deviation?

Solution

[latex]s = 1.75[/latex]

The Standard Deviation for the Sum of Squared Errors for a data set is 9.8. What is the cutoff for the vertical distance that a point can be from the line of best fit to be considered an outlier?

The height (sidewalk to roof) of notable tall buildings in America is compared to the number of stories of the building (beginning at street level).

Table 5: Height and Stories of Notable Buildings
Height (in feet) Stories
1,050 57
428 28
362 26
529 40
790 60
401 22
380 38
1,454 110
1,127 100
700 46
  1. Using “stories” as the independent variable and “height” as the dependent variable, make a scatter plot of the data.
  2. Does it appear from inspection that there is a relationship between the variables?
  3. Calculate the least squares line. Put the equation in the form of: [latex]\hat{y} = a + bx[/latex]
  4. Find the correlation coefficient. Is it significant?
  5. Find the estimated heights for 32 stories and for 94 stories.
  6. Based on the data in the table, is there a linear relationship between the number of stories in tall buildings and the height of the buildings?
  7. Are there any outliers in the data? If so, which point(s)?
  8. What is the estimated height of a building with six stories? Does the least squares line give an accurate estimate of height? Explain why or why not.
  9. Based on the least squares line, adding an extra story is predicted to add about how many feet to a building?
  10. What is the slope of the least squares (best-fit) line? Interpret the slope.
Table 6: School, Mid-Career Salary, Yearly Tuition Data
School Mid-Career Salary (in thousands) Yearly Tuition
Princeton 137 28,540
Harvey Mudd 135 40,133
CalTech 127 39,900
US Naval Academy 122 0
West Point 120 0
MIT 118 42,050
Lehigh University 118 43,220
NYU-Poly 117 39,565
Babson College 117 40,400
Stanford 114 54,506

Using the data to determine the linear-regression line equation with the outliers removed. Is there a linear correlation for the data set with outliers removed? Justify your answer.

Solution

If we remove the two service academies (the tuition is $0.00), we construct a new regression equation of [latex]y = –0.0009x + 160[/latex] with a correlation coefficient of 0.71397 and a coefficient of determination of 0.50976. This allows us to say there is a fairly strong linear association between tuition costs and salaries if the service academies are removed from the data set.

References

Data from the House Ways and Means Committee, the Health and Human Services Department.

Data from Microsoft Bookshelf.

Data from the United States Department of Labor, the Bureau of Labor Statistics.

Data from the Physician’s Handbook, 1990.

Data from the United States Department of Labor, the Bureau of Labor Statistics.

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.