maths.free › Statistics & Probability › Linear regression and correlation
Linear regression and correlation
The least-squares line, the correlation coefficient, and prediction.
Regression fits the line that minimises the total squared vertical distance to the points; correlation r measures how tightly they cluster around it, from −1 to 1. The slope says how much y changes per unit of x; the intercept is the prediction at x = 0, which may or may not mean anything.
Linear Equations
Linear regression for two variables is based on a linear equation with one independent variable. The equation has the form
\[y=a+bx\]
where a and b are constant numbers.
The variable x is the independent variable; y is the dependent variable. Typically, you choose a value to substitute for the independent variable and then solve for the dependent variable.
Example
The following examples are linear equations.
\[y=3+\text{2}x\]\[y=-0.01+\text{1.2}x\]The graph of a linear equation of the form y = a + bx is a straight line. Any line that is not vertical can be described by this equation.
Example
Graph the equation y = –1 + 2x.
Example
Aaron’s Word Processing Service does word processing. The rate for services is $32 per hour plus a $31.50 one-time charge. The total cost to a customer depends on the number of hours it takes to complete the job.
Try it.
Find the equation that expresses the total cost in terms of the number of hours required to complete the job.
Solution
Let x = the number of hours it takes to get the job done.
Let y = the total cost to the customer.
The $31.50 is a fixed cost. If it takes x hours to complete the job, then (32)(x) is the cost of the word processing only. The total cost is y = 31.50 + 32x.
Slope and
For the linear equation y = a + bx, b = slope and a = y-inttercept. From algebra, recall that the slope is a number that describes the steepness of a line; the y-intercept is the y-coordinate of the point (0, a), where the line crosses the y-axis.
Please note that in previous courses you learned \(y=mx+b\) was the slope-intercept form of the equation, where m represented the slope and b represented the y-intercept. In this text, the form \(y=a+bx\) is used, where a is the y-intercept and b is the slope. The key is remembering the coefficient of x is the slope, and the constant number is the y-intercept.
Example
Svetlana tutors to make extra money for college. For each tutoring session, she charges a one-time fee of $25 plus $15 per hour of tutoring. A linear equation that expresses the total amount of money Svetlana earns for each session she tutors is y = 25 + 15x.
Try it.
What are the independent and dependent variables? What is the y-intercept, and what is the slope? Interpret them using complete sentences.
Solution
The independent variable (x) is the number of hours Svetlana tutors each session. The dependent variable (y) is the amount, in dollars, Svetlana earns for each session.
The y-intercept is 25 (a = 25). At the start of the tutoring session, Svetlana charges a one-time fee of $25 (this is when x = 0). The slope is 15 (b = 15). For each session, Svetlana earns $15 for each hour she tutors.
Linear Equations
Use the following information to answer the next three exercises. A vacation resort rents scuba equipment to certified divers. The resort charges an up-front fee of $25 and another fee of $12.50 an hour.
Use the following information to answer the next two exercises. A credit card company charges $10 when a payment is late and $5 a day each day the payment remains unpaid.
Use the following information to answer the next exercise. contains real data for the first two decades of flu reporting.
| Year | Number of Flu Cases Diagnosed | Number of Flu Deaths |
| Pre-1981 | 91 | 29 |
| 1981 | 319 | 121 |
| 1982 | 1,170 | 453 |
| 1983 | 3,076 | 1,482 |
| 1984 | 6,240 | 3,466 |
| 1985 | 11,776 | 6,878 |
| 1986 | 19,032 | 11,987 |
| 1987 | 28,564 | 16,162 |
| 1988 | 35,447 | 20,868 |
| 1989 | 42,674 | 27,591 |
| 1990 | 48,634 | 31,335 |
| 1991 | 59,660 | 36,560 |
| 1992 | 78,530 | 41,055 |
| 1993 | 78,834 | 44,730 |
| 1994 | 71,874 | 49,095 |
| 1995 | 68,505 | 49,456 |
| 1996 | 59,347 | 38,510 |
| 1997 | 47,149 | 20,736 |
| 1998 | 38,393 | 19,005 |
| 1999 | 25,174 | 18,454 |
| 2000 | 25,522 | 17,347 |
| 2001 | 25,643 | 17,402 |
| 2002 | 26,464 | 16,371 |
| Total | 802,118 | 489,093 |
Use the following information to answer the next two exercises. A specialty cleaning company charges an equipment fee and an hourly labor fee. A linear equation that expresses the total amount of the fee the company charges for each session is y = 50 + 100x.
Use the following information to answer the next three questions. As a result of erosion, a river shoreline is losing several thousand pounds of soil each year. A linear equation that expresses the total amount of soil lost per year is y = 12,000x.
Use the following information to answer the next two exercises. The price of a single issue of stock can fluctuate throughout the day. A linear equation that represents the price of stock for Shipment Express is y = 15 – 1.5x, where x is the number of hours passed in an eight-hour day of trading.
The Regression Equation
Data rarely fit a straight line exactly. Usually, you must be satisfied with rough predictions. Typically, you have a set of data with a scatter plot that appear to fit a straight line. This is called a line of best fit or least-squares regression line.
Example
A random sample of 11 statistics students produced the data in , where x is the third exam score out of 80 and y 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?
| x (third exam score) | y (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 third exam score, x, is the independent variable, and the final exam score, y, 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 obtain a line of best fit using either the median-median line approach or by calculating the least-squares regression line.
| x (third exam score) | y (final exam score) |
| 65 | 175 |
| 66 | 126 |
| 67 | 133 |
| 67 | 153 |
| 69 | 151 |
| 69 | 159 |
| 70 | 163 |
| 71 | 159 |
| 71 | 163 |
| 71 | 185 |
| 75 | 198 |
| Group | x (third exam score) | y (final exam score) | Median x value | Median y value |
| 1 | 65 66 67 67 | 126 133 153 175 | 66.5 | 143 |
| 2 | 69 69 70 | 151 159 163 | 69 | 159 |
| 3 | 71 71 71 75 | 159 163 185 198 | 71 | 174 |
The ordered pairs are (66.5, 143), (69, 159), and (71, 174).
\[ŷ=a+bx\]Condensed — the full section is in OpenStax Statistics.
Least-Squares Criteria for Best Fit
The process of fitting the best-fit line is called linear regression. We assume that the data are scattered about a straight line. To find that line, we minimize the sum of the squared errors (SSE), or make it 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.
Third Exam vs. Final Exam Example
The graph of the line of best fit for the third exam/final exam example is as follows:
The least-squares regression line (best-fit line) for the third exam/final exam example has the equation
\[ŷ=-173.51+4.83x\text{.}\]Understanding and Interpreting the
The y-intercept, a, of the line describes where the plot line crosses the y-axis. The y-intercept of the best-fit line tells us the best value of the relationship when x is zero. In some cases, it does not make sense to figure out what y is when x = 0. For example, in the third exam vs. final exam example, the y-intercept occurs when the third exam score, or x, is zero. Since all the scores are grouped around a passing grade, there is no need to figure out what the final exam score, or y, would be when the third exam was zero.
However, the y-intercept is very useful in many cases. For many examples in science, the y-intercept gives the baseline reading when the experimental conditions aren't applied to an experimental system. This baseline indicates how much the experimental condition affects the system. It could also be used to ensure that equipment and measurements are calibrated properly before starting the experiment.
In biology, the concentration of proteins in a sample can be measured using a chemical assay that changes color depending on how much protein is present. The more protein present, the darker the color. The amount of color can be measured by the absorbance reading. shows the expected absorbance readings at different protein concentrations. This is called a standard curve for the assay.
| Concentration (mM) | Absorbance (mAU) |
| 125 | 0.021 |
| 250 | 0.023 |
| 500 | 0.068 |
| 750 | 0.086 |
| 1,000 | 0.105 |
| 1,500 | 0.124 |
| 2,000 | 0.146 |
The scatter plot includes the line of best fit.
The y-intercept of this line occurs at 0.0226 mAU. This means the assay gives a reading of 0.0226 mAU when there is no protein present. That is, it is the baseline reading that can be attributed to something else, which, in this case, is some other non-protein chemicals that are absorbing light. We can tell that this line of best fit is reasonable because the y-intercept is small, close to zero. When there is no protein present in the sample, we expect the absorbance to be very small, or close to zero, as well.
Understanding Slope
The slope of the line, b, 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 (y) changes for every one unit increase in the independent (x) variable, on average.
Slope: The slope of the line is b = 4.83.
Interpretation: For a 1-point increase in the score on the third exam, the final exam score increases by 4.83 points, on average.
Condensed — the full section is in OpenStax Statistics.
The Correlation Coefficient
Besides looking at the scatter plot and seeing that a line seems reasonable, how can you determine whether the line is a good predictor? Use the correlation coefficient as another indicator (besides the scatter plot) of the strength of the relationship between x and y.
The correlation coefficient, r, developed by Karl Pearson during the early 1900s, is numeric and provides a measure of the strength and direction of the linear association between the independent variable x and the dependent variable y.
If you suspect a linear relationship between x and y, then r can measure the strength of the linear relationship.
- The value of r is always between –1 and +1. In other words, –1 ≤ r ≤ 1.
- The size of the correlation r indicates the strength of the linear relationship between x and y. Values of r close to –1 or to +1 indicate a stronger linear relationship between x and y.
- If r = 0, there is absolutely no linear relationship between x and y (no linear correlation).
- If r = 1, there is perfect positive correlation. If r = –1, there is perfect negative correlation. In both these cases, all the original data points lie on a straight line. Of course, in the real world, this does not generally happen.
- A positive value of r means that when x increases, y tends to increase and when x decreases, y tends to decrease (positive correlation).
- A negative value of r means that when x increases, y tends to decrease and when x decreases, y tends to increase (negative correlation).
- The sign of r is the same as the sign of the slope, b, of the best-fit line.
The correlation coefficient is calculated as the quantity of data points times the sum of the quantity of the x-coordinates times the y-coordinates, minus the quantity of the sum of the x-coordinates times the sum of the y-coordinates, all divided by the square root of the quantity of data points times the sum of the x-coordinates squared minus the square of the sum of the x-coordinates, times the number of data points times the sum of the y-coordinates squared minus the square of the sum of the y-coordinates. It can be summarized by the following equation:
\[r=\frac{n\Sigma (xy)-(\Sigma x)(\Sigma y)}{\sqrt{[n\Sigma {x}^{2}-{(\Sigma x)}^{2}][n\Sigma {y}^{2}-{(\Sigma y)}^{2}]}}\]
Condensed — the full section is in OpenStax Statistics.
The Coefficient of Determination
The variable r2 is called the coefficient of determination and it is the square of the correlation coefficient, but it is usually stated as a percentage, rather than in decimal form. It has an interpretation in the context of the data:
- \({r}^{2}\text{,}\) when expressed as a percent, represents the percentage 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 – \({r}^{2}\text{,}\) when expressed as a percentage, represents the percentage 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.
Consider the third exam/final exam example introduced in the previous section.
- The line of best fit is: ŷ = –173.51 + 4.83x.
- The correlation coefficient is r = .6631.
- The coefficient of determination is r2 = .66312 = .4397.
Interpret r2 in the context of this example.
- Approximately 44 percent 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, the rest of the variation (1 – 0.44 = 0.56 or 56 percent) in the final exam grades cannot be explained by the variation of the grades on the third exam with the best-fit regression line. These are the variation of the points that are not as close to the regression line as others.
The Regression Equation
Use the following information to answer the next five exercises. A random sample of 10 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.
| x | y | x | y |
| 0 | 2 | 5 | 12 |
| 3 | 8 | 4 | 9 |
| 2 | 7 | 3 | 9 |
| 1 | 3 | 0 | 3 |
| 5 | 13 | 4 | 10 |
Testing the Significance of the Correlation Coefficient (Optional)
The correlation coefficient, r, tells us about the strength and direction of the linear relationship between x and y. However, the reliability of the linear model also depends on how many observed data points are in the sample. We need to look at both the correlation coefficient r and the sample size n, together.
We perform a hypothesis test of the significance of the correlation coefficient to decide whether the linear relationship in the sample data is strong enough to use to model the relationship in the population.
The sample data are used to compute r, the correlation coefficient for the sample. If we had data for the entire population, we could find the population correlation coefficient. But, because we have only sample data, we cannot calculate the population correlation coefficient. The sample correlation coefficient, r, is our estimate of the unknown population correlation coefficient.
- The symbol for the population correlation coefficient is ρ, the Greek letter rho.
- ρ = population correlation coefficient (unknown).
- r = sample correlation coefficient (known; calculated from sample data).
The hypothesis test lets us decide whether the value of the population correlation coefficient ρ is close to zero or significantly different from zero. We decide this based on the sample correlation coefficient r and the sample size n.
If the test concludes the correlation coefficient is significantly different from zero, we say the correlation coefficient is significant.
- Conclusion: There is sufficient evidence to conclude there is a significant linear relationship between x and y because the correlation coefficient is significantly different from zero.
- What the conclusion means: There is a significant linear relationship between x and y. We can use the regression line to model the linear relationship between x and y in the population.
If the test concludes the correlation coefficient is not significantly different from zero (it is close to zero), we say the correlation coefficient is not significant.
- Conclusion: There is insufficient evidence to conclude there is a significant linear relationship between x and y because the correlation coefficient is not significantly different from zero.
- What the conclusion means: There is not a significant linear relationship between x and y. Therefore, we cannot use the regression line to model a linear relationship between x and y in the population.
Condensed — the full section is in OpenStax Statistics.
Performing the Hypothesis Test
- Null hypothesis: H0: ρ = 0.
- Alternate hypothesis: Ha: ρ ≠ 0.
- Null hypothesis H0: The population correlation coefficient is not significantly different from zero. There is not a significant linear relationship (correlation) between x and y in the population.
- Alternate hypothesis Ha: The population correlation coefficient is significantly different from zero. There is a significant linear relationship (correlation) between x and y in the population.
There are two methods to make a conclusion. The two methods are equivalent and give the same result.
- Method 1: Use the p-value.
- Method 2: Use a table of critical values.
In this chapter, we will always use a significance level of 5 percent, α = 0.05.
Condensed — the full section is in OpenStax Statistics.
Third Exam vs. Final Exam Example: Critical Value Method
Consider the third exam/final exam example. The line of best fit is: ŷ = –173.51 + 4.83x, with r = .6631, and there are n = 11 data points. Can the regression line be used for prediction? Given a third exam score (x value), can we use the line to predict the final exam score (predicted y value)?
- H0: ρ = 0
- Ha: ρ ≠ 0
- α = 0.05
- Use the 95 Percent Critical Values table for r with df = n – 2 = 11 – 2 = 9.
- Using the table with df = 9, we find that the critical value listed is 0.602. Therefore, the critical values are ±0.602.
- Since 0.6631 > 0.602, r is significant.
- Decision: Reject the null hypothesis.
- Conclusion: There is sufficient evidence to conclude there is a significant linear relationship between the third exam score (x) and the final exam score (y) because the correlation coefficient is significantly different from zero.
Because r is significant and the scatter plot shows a linear trend, the regression line can be used to predict final exam scores.
Example
Suppose you computed the following correlation coefficients. Using the table at the end of the chapter, determine whether r is significant and whether the line of best fit associated with each correlation coefficient can be used to predict a y value. If it helps, draw a number line.
- r = 0.567 and the sample size, n, is 19.
To solve this problem, first find the degrees of freedom. df = n - 2 = 17.
Then, using the table, the critical values are ±0.456.
0.567 < 0.456, or you may say that 0.567 is not between the two critical values.
r is significant and may be used for predictions.
- r = 0.708 and the sample size, n, is 9.
df = n - 2 = 7
The critical values are ±0.666.
0.708 > 0.666.
r is significant and may be used for predictions.
- r = 0.134 and the sample size, n, is 14.
df = 14 - 2 = 12.
The critical values are ±0.532.
0.134 is between 0.532 and 0.532.
r is not significant and may not be used for predictions. - r = 0 and the sample size, n, is 5.
It doesn't matter what the degrees of freedom are because r = 0 will always be between the two critical values, so r is not significant and may not be used for predictions.
Assumptions in Testing the Significance of the Correlation Coefficient
Testing the significance of the correlation coefficient requires that certain assumptions about the data be satisfied. The premise of this test is that the data are a sample of observed points taken from a larger population. We have not examined the entire population because it is not possible or feasible to do so. We are examining the sample to draw a conclusion about whether the linear relationship that we see between x and y in the sample data provides strong enough evidence that we can conclude there is a linear relationship between x and y in the population.
The regression line equation that we calculate from the sample data gives the best-fit line for our particular sample. We want to use this best-fit line for the sample as an estimate of the best-fit line for the population. Examining the scatter plot and testing the significance of the correlation coefficient helps us determine whether it is appropriate to do this.
- There is a linear relationship in the population that models the sample data. Our regression line from the sample is our best estimate of this line in the population.
- The y values for any particular x value are normally distributed about the line. This implies there are more y values scattered closer to the line than are scattered farther away. Assumption 1 implies that these normal distributions are centered on the line; the means of these normal distributions of y values lie on the line.
- Normal distributions of all the y values have the same shape and spread about the line.
- The residual errors are mutually independent (no pattern).
- The data are produced from a well-designed, random sample or randomized experiment.
Prediction (Optional)
Recall the third exam/final exam example.
We found the equation of the best-fit line for the final exam grade as a function of the grade on the third exam. We can now use the least-squares regression line for prediction.
Suppose you want to estimate, or predict, the mean final exam score of statistics students who received a 73 on the third exam. The exam scores (x values) range from 65 to 75. Since 73 is between the x values 65 and 75, substitute x = 73 into the equation. Then,
\[\overset{\wedge}{y}=-173.51+4.83(73)=179.08\text{.}\]We predict that statistics students who earn a grade of 73 on the third exam will earn a grade of 179.08 on the final exam, on average.
Example
Recall the third exam/final exam example.
Try it.
a. What would you predict the final exam score to be for a student who scored a 66 on the third exam?
Solution
a. 145.27
Try it.
b. What would you predict the final exam score to be for a student who scored a 90 on the third exam?
Solution
b. The x values in the data are between 65 and 75. 90 is outside the domain of the observed x values in the data (independent variable), so you cannot reliably predict the final exam score for this student. Even though it is possible to enter 90 into the equation for x and calculate a corresponding y value, the y value that you get will not be reliable.
To understand how unreliable the prediction can be outside the x values observed in the data, make the substitution x = 90 into the equation:
\(ŷ=-173.51+4.83(90)=261.19\text{.}\)
The final exam score is predicted to be 261.19. The most points that can be awarded for the final exam are 200.
Prediction (Optional)
Use the following information to answer the next two exercises. An electronics retailer used regression to find a simple model to predict sales growth in the first quarter of the new year (January through March). The model is good for 90 days, where x is the day. The model can be written as ŷ = 101.32 + 2.48x, where ŷ is in thousands of dollars.
Use the following information to answer the next three exercises. A landscaping company is hired to mow the grass for several large properties. The total area of the properties is 1,345 acres. The rate at which one person can mow is ŷ = 1350 – 1.2x, where x is the number of hours and ŷ represents the number of acres left to mow.
Use the following information to answer the next 14 exercises. contains real data for the first two decades of flu reporting.
| Year | Number of Flu Cases Diagnosed | Number of Flu Deaths |
| Pre-1981 | 91 | 29 |
| 1981 | 319 | 121 |
| 1982 | 1,170 | 453 |
| 1983 | 3,076 | 1,482 |
| 1984 | 6,240 | 3,466 |
| 1985 | 11,776 | 6,878 |
| 1986 | 19,032 | 11,987 |
| 1987 | 28,564 | 16,162 |
| 1988 | 35,447 | 20,868 |
| 1989 | 42,674 | 27,591 |
| 1990 | 48,634 | 31,335 |
| 1991 | 59,660 | 36,560 |
| 1992 | 78,530 | 41,055 |
| 1993 | 78,834 | 44,730 |
| 1994 | 71,874 | 49,095 |
| 1995 | 68,505 | 49,456 |
| 1996 | 59,347 | 38,510 |
| 1997 | 47,149 | 20,736 |
| 1998 | 38,393 | 19,005 |
| 1999 | 25,174 | 18,454 |
| 2000 | 25,522 | 17,347 |
| 2001 | 25,643 | 17,402 |
| 2002 | 26,464 | 16,371 |
| Total | 802,118 | 489,093 |
Outliers
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 not very close to the best-fit line.
Outliers need to be examined closely. Sometimes, they should not be included in the analysis of the data, like if it is possible that an outlier is a result of incorrect 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 determine whether the slope of the regression line is changed significantly.
You also want to examine how the correlation coefficient, r, has changed. Sometimes, it is difficult to discern a significant change in slope, so you need to look at how the strength of the linear relationship has changed. Computers and many calculators can be used to identify outliers and influential points. Regression analysis can determine if an outlier is, indeed, an influential point. The new regression will show how omitting the outlier will affect the correlation among the variables, as well as the fit of the line. A graph showing both regression lines helps determine how removing an outlier affects the fit of the model.
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 regarding how far away a point needs to be to be considered an outlier. As a rough rule of thumb, we can flag as an outlier any point that is located farther than two standard deviations above or below the best-fit line. 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 outside this extra pair of lines are flagged as potential outliers. Or, we can do this numerically by calculating each residual and comparing it with twice the standard deviation. With regard to the TI-83, 83+, or 84+ calculators, the graphical approach is easier. The graphical procedure is shown first, followed by the numerical calculations. You would generally need to use only one of these methods.
Condensed — the full section is in OpenStax Statistics.
Numerical Identification of Outliers
In , the first two columns include the third exam and final exam data. The third column shows the predicted ŷ values calculated from the line of best fit: ŷ = –173.5 + 4.83x. The residuals, or errors, that were mentioned in Section 3 of this chapter have been calculated in the fourth column of the table: Observed y value predicted y value = y ŷ.
s is the standard deviation of all the y ŷ = ε values, where n is the total number of data points. 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
\[s=\sqrt{\frac{SSE}{n-2}}\text{.}\]Rather than calculate the value of s ourselves, we can find s using a computer or calculator. For this example, the calculator function LinRegTTest found s = 16.4 as the standard deviation of the residuals
- 35
- –17
- 16
- –6
- –19
- 9
- 3
- –1
- –10
- –9
- –1
| x | y | ŷ | y – ŷ |
| 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 2s = 2(16.4) = 32.8 or less than –32.8. Compare these values with 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?
Numerically and graphically, we have identified point (65, 175) as an outlier. Recall that recalculation of the least-squares regression line and summary statistics, following deletion of an outlier, may be used to determine whether an outlier is also an influential point. This process also allows you to compare the strength of the correlation of the variables and possible changes in the slope both before and after the omission of any outliers.
Compute a new best-fit line and correlation coefficient using the 10 remaining points.
On the TI-83, TI-83+, or TI-84+ calculators, delete the outlier from L1 and L2. Using the LinRegTTest, found under Stat and Tests, the new line of best fit and correlation coefficient are the following:
\(ŷ=-355.19+7.39x\) and \(r=0.9121\).
The slope is now 7.39, compared to the previous slope of 4.83. This seems significant, but we need to look at the change in r-values as well. The new line shows \(r=0.9121\), which indicates a stronger correlation than the original line, with \(r=0.6631\text{,}\) since \(r=0.9121\) is closer to 1. This means the new line is a better fit to the data values. The line can better predict the final exam score given the third exam score. It also means the outlier of (65, 175) was an influential point, since there is a sizeable difference in r-values. We must now decide whether to delete the outlier. If the outlier was recorded erroneously, it should certainly be deleted. Because it produces such a profound effect on the correlation, the new line of best fit allows for better prediction and an overall stronger model.
You may use Excel to graph the two least-squares regression lines and compare the slopes and fit of the lines to the data, as shown in .
You can see that the second graph shows less deviation from the line of best fit. It is clear that omission of the influential point produced a line of best fit that more closely models the data.
Numerical Identification of Outliers: Calculating
If you do not have the function LinRegTTest on your calculator, then you must calculate the outlier in the first example by doing the following.
First, square each |y – ŷ|.
The squares are
- 352
- 172
- 162
- 62
- 192
- 92
- 32
- 12
- 102
- 92
- 12.
Then, add (sum) all the |y – ŷ| squared terms using the formula
\(\underset{i=1}{\Sigma }11{(|{y}_{i}-{ŷ}_{i}|)}^{2}=\underset{i=1}{\Sigma }11{\epsilon }_{i}{}^{2}\) (Recall that yi – ŷi = εi).
= 352 + 172 + 162 + 62 + 192 + 92 + 32 + 12 + 102 + 92 + 12
= 2,440 = SSE.
The result, SSE, is the sum of squared errors.
Example
Try it.
Using this new line of best fit (based on the remaining 10 data points in 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, ŷ = –355.19 + 7.39(73) = 184.28. A student who scored 73 points on the third exam would expect to earn 184 points on the final exam.
The original line predicted that ŷ = –173.51 + 4.83(73) = 179.08, so the prediction using the new line with the outlier eliminated differs from the original prediction.
Condensed — the full section is in OpenStax Statistics.
95 Percent Critical Values of the Sample Correlation Coefficient Table
| Degrees of Freedom: n – 2 | Critical Values: + and – |
| 1 | 0.997 |
| 2 | 0.950 |
| 3 | 0.878 |
| 4 | 0.811 |
| 5 | 0.754 |
| 6 | 0.707 |
| 7 | 0.666 |
| 8 | 0.632 |
| 9 | 0.602 |
| 10 | 0.576 |
| 11 | 0.555 |
| 12 | 0.532 |
| 13 | 0.514 |
| 14 | 0.497 |
| 15 | 0.482 |
| 16 | 0.468 |
| 17 | 0.456 |
| 18 | 0.444 |
| 19 | 0.433 |
| 20 | 0.423 |
| 21 | 0.413 |
| 22 | 0.404 |
| 23 | 0.396 |
| 24 | 0.388 |
| 25 | 0.381 |
| 26 | 0.374 |
| 27 | 0.367 |
| 28 | 0.361 |
| 29 | 0.355 |
| 30 | 0.349 |
| 40 | 0.304 |
| 50 | 0.273 |
| 60 | 0.250 |
| 70 | 0.232 |
| 80 | 0.217 |
| 90 | 0.205 |
| 100 | 0.195 |
Outliers
Use the following information to answer the next four exercises. 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.
Bring It Together
Use the following information to answer the next two exercises. The cost of a leading liquid laundry detergent in different sizes is given in .
| Size (ounces) | Cost ($) | Cost per Ounce |
| 16 | 3.99 | |
| 32 | 4.99 | |
| 64 | 5.99 | |
| 200 | 10.99 |
Exemplo trabalhado: line through (1,2) and (3,6)
Passo a passo
- m = \frac{\Delta y}{\Delta x} = \frac{4}{2} = 2
Slope = rise over run.
- y - 2 = 2(x - 1)
Point-slope form through P.
- y = 2 x
Slope-intercept form.
Revelar a resposta
Practice (40)
Try each one on paper first. Reveal the answer to check; verified ones can be opened in the solver for every step.
-
Is the following an example of a linear equation?
y = –0.125 – 3.5x
Revelar a resposta
yes
-
Is the following an example of a linear equation? Why or why not?
Revelar a resposta
No, the graph is not a straight line; therefore, it is not a linear equation.
-
Find the equation that expresses the total cost in terms of the number of hours required to complete the job.
Revelar a resposta
Let x = the number of hours it takes to get the job done.
Let y = the total cost to the customer.The $31.50 is a fixed cost. If it takes x hours to complete the job, then (32)(x) is the cost of the word processing only. The total cost is y = 31.50 + 32x.
-
Emma’s Extreme Sports hires hang-gliding instructors and pays them a fee of $50 per class, as well as $20 per student in the class. The total cost Emma pays depends on the number of students in a class. Find the equation that expresses the total cost in terms of the number of students in a class.
Revelar a resposta
y = 50 + 20x
-
What are the independent and dependent variables? What is the y-intercept, and what is the slope? Interpret them using complete sentences.
Revelar a resposta
The independent variable (x) is the number of hours Svetlana tutors each session. The dependent variable (y) is the amount, in dollars, Svetlana earns for each session.
The y-intercept is 25 (a = 25). At the start of the tutoring session, Svetlana charges a one-time fee of $25 (this is when x = 0). The slope is 15 (b = 15). For each session, Svetlana earns $15 for each hour she tutors.
-
Ethan repairs household appliances such as dishwashers and refrigerators. For each visit, he charges $25 plus $20 per hour of work. A linear equation that expresses the total amount of money Ethan earns per visit is y = 25 + 20x.
What are the independent and dependent variables? What is the y-intercept, and what is the slope? Interpret them using complete sentences.
Revelar a resposta
The independent variable (x) is the number of hours Ethan works each visit. The dependent variable (y) is the amount, in dollars, Ethan earns for each visit.
The y-intercept is 25 (a = 25). At the start of a visit, Ethan charges a one-time fee of $25 (this is when x = 0). The slope is 20 (b = 20). For each visit, Ethan earns $20 for each hour he works.
-
What are the dependent and independent variables?
Revelar a resposta
dependent variable: fee amount
independent variable: time
-
Find the equation that expresses the total fee in terms of the number of hours the equipment is rented.
-
Graph the equation from .
-
Find the equation that expresses the total fee in terms of the number of days the payment is late.
-
Graph the equation from .
-
Is the equation y = 10 + 5x – 3x2 linear? Why or why not?
-
Which of the following equations are linear?
a. y = 6x + 8
b. y + 7 = 3x
c. y – x = 8x2
d. 4y = 8
Revelar a resposta
y = 6x + 8, 4y = 8, and y + 7 = 3x are all linear equations.
-
Does the graph in show a linear equation? Why or why not?
-
Use the columns Year and Number of Flu Cases Diagnosed. Why is year the independent variable and number of flu cases diagnosed the dependent variable (instead of the reverse)?
Revelar a resposta
The number of flu cases depends on the year. Therefore, year becomes the independent variable and the number of flu cases is the dependent variable.
-
What are the independent and dependent variables?
-
What is the y-intercept, and what is the slope? Interpret them using complete sentences.
Revelar a resposta
The y-intercept is 50 (a = 50). At the start of the cleaning, the company charges a one-time fee of $50 (this is when x = 0). The slope is 100 (b = 100). For each session, the company charges $100 for each hour they clean.
-
What are the independent and dependent variables?
-
How many pounds of soil does the shoreline lose in a year?
Revelar a resposta
12,000 lb of soil
-
What is the y-intercept? Interpret its meaning.
-
What are the slope and y-intercept? Interpret their meaning.
Revelar a resposta
The slope is –1.5 (b = –1.5). This means the stock is losing value at a rate of $1.50 per hour. The y-intercept is $15 (a = 15). This means the price of stock before the trading day was $15.
-
If you owned this stock, would you want a positive or negative slope? Why?
-
For each of the following situations, state the independent variable and the dependent variable.
- A study is done to determine whether elderly drivers are involved in more motor vehicle fatalities than other drivers. The number of fatalities per 100,000 drivers is compared with the age of drivers.
- A study is done to determine whether the weekly grocery bill changes based on the number of family members.
- Insurance companies base life insurance premiums partially on the age of the applicant.
- Utility bills vary according to power consumption.
- A study is done to determine whether a higher education reduces the crime rate in a population.
Revelar a resposta
- independent variable: age; dependent variable: fatalities
- independent variable: number of family members; dependent variable: grocery bill
- independent variable: age of applicant; dependent variable: insurance premium
- independent variable: power consumption; dependent variable: utility
- independent variable: higher education (years); dependent variable: crime rates
-
Piece-rate systems are widely debated incentive payment plans. In a recent study of loan officer effectiveness, the following piece-rate system was examined:
% of goal reached < 80 80 100 120 Incentive n/a $4,000, with an additional $125 added per percentage point from 81% to 99% $6,500, with an additional $125 added per percentage point from 101% to 119% $9,500, with an additional $125 added per percentage point starting at 121% If a loan officer makes 95 percent of his or her goal, write the linear function that applies based on the incentive plan table. In context, explain the y-intercept and slope.
-
SCUBA divers have maximum dive times they cannot exceed when going to different depths. The data in show different depths in feet, with the maximum dive times in minutes. Use your calculator to find the least squares regression line and predict the maximum dive time for 110 feet.
x (depth) y (maximum dive time) 50 80 60 55 70 45 80 35 90 25 100 22 Revelar a resposta
ŷ = 127.24 – 1.11x
At 110 feet, a diver could dive for only five minutes.
-
Table 12.16 below represents the relationship between the number of hours spent studying and final exam grades.
x (number of hours spent studying) y (final exam grades) 3 50 5 72 1 45 2 51 6 80 8 96 4 65 7 90 Fill in the following chart as a first step in finding the line of best fit, using the median–median approach.
Group x (no. of hours spent studying) y (final exam grades) Median x Value Median y Value 1 2 3 Revelar a resposta
Group x (no. of hours spent studying) y (final exam grades) Median x value Median y value 1 1
2
345
50
512 50 2 4
565
724.5 68.5 3 6
7
880
90
967 90 -
Draw a scatter plot of the data.
-
Use regression to find the equation for the line of best fit.
Revelar a resposta
ŷ = 2.23 + 1.99x
-
Draw the line of best fit on the scatter plot.
-
What is the slope of the line of best fit? What does it represent?
Revelar a resposta
The slope is 1.99 (b = 1.99). It means that for every endorsement deal a professional player gets, he gets an average of another $1.99 million in pay each year.
-
What is the y-intercept of the line of best fit? What does it represent?
-
What does an r value of zero mean?
Revelar a resposta
It means that there is no correlation between the data sets.
-
When n = 2 and r = 1, are the data significant? Explain.
-
When n = 100 and r = –0.89, is there a significant correlation? Explain.
Revelar a resposta
Yes. There are enough data points and the value of r is strong enough to show there is a strong negative 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 r2 value of .72.
Revelar a resposta
It means that 72 percent of the variation in the dependent variable (y) can be explained by the variation in the independent variable (x).
-
Can a coefficient of determination be negative? Why or why not?
-
The table below represents the relationship between SAT scores on the math portion of the test and high school grade point averages (GPAs).
Use the median-median line approach to find the equation for the line of best fit.
x (SAT math scores) y (GPAs) 624 90 544 86 363 70 373 71 350 65 741 98 262 60 587 87 327 62 364 67 261 50 Revelar a resposta
x (SAT math scores) y (GPAs) 261 50 262 60 327 62 350 65 363 70 364 67 373 71 544 86 587 87 624 90 741 98 We must remember to check the order of the y values within each group as well. We notice that the y values in the second group are not in order from the least value to the greatest value; these values thus must be reordered, meaning the median y value for that group is 70.
Group x (SAT math scores) y (GPAs) Median x value Median y value 1 261
262
327
35050
60
62
65294.5 61 2 363
364
37367
70
71364 70 3 544
587
624
74186
87
90
98605.5 88.5 The ordered pairs are (294.5, 61), (364, 70), and (605.5, 88.5).
The slope can be calculated using the formula \(m=\frac{{y}_{3}-{y}_{1}}{{x}_{3}-{x}_{1}}\text{.}\) Substituting the median x and y values, from the first and third groups gives \(m=\frac{88.5-61}{605.5-294.5}\text{,}\) which simplifies to \(m\approx 0.09\text{.}\)
The y-intercept may be found using the formula \(b=\frac{\sum y-m\sum x}{3}\text{.}\) The sum of the median x values is 1264, and the sum of the median y values is 219.5. Substituting these sums and the slope into the formula gives \(b=\frac{219.5-0.09(1264)}{3}\text{,}\) which simplifies to \(b\approx 35.25\text{.}\)
The line of best fit is represented as \(y=mx+b\). Thus, the equation can be written as \(y=0.09x+35.25\text{.}\)
-
For a given line of best fit, you computed that r = 0.6501 using n = 12 data points, and the critical value found on the table is 0.576. Can the line be used for prediction? Why or why not?
Revelar a resposta
If the scatter plot looks linear then yes, the line can be used for prediction, because r > the positive critical value.
-
For a given line of best fit, you compute that r = 0.5204 using n = 9 data points, and the critical values are ±0.666. Can the line be used for prediction? Why or why not?
Revelar a resposta
No, the line cannot be used for prediction, because r < the positive critical value.
Tente o seu próprio
Parts of this page are adapted from OpenStax Statistics (CC BY 4.0). Condensed and re-explained here; errors are ours.
Mais em Statistics & Probability
Sampling and dataDescribing data with graphsMean, median and modeProbabilityCounting: permutations and combinationsDiscrete random variablesContinuous random variablesThe normal distributionThe central limit theoremConfidence intervalsHypothesis testingComparing two samplesChi-square testsANOVA and the F distribution