Download presentation
Presentation is loading. Please wait.
1
Chapter 8 Part 1 Linear Regression
Honors Statistics Chapter 8 Part 1 Linear Regression
2
Objectives: Linear model Predicted value Residuals Least squares
Regression to the mean Regression line Line of best fit Slope intercept se R2
3
Fat Versus Protein: An Example
The following is a scatterplot of total fat versus protein for 30 items on the Burger King menu:
4
The Linear Model The correlation in this example is It says “There seems to be a linear association between these two variables,” but it doesn’t tell what that association is. We can say more about the linear relationship between two quantitative variables with a model. A model simplifies reality to help us understand underlying patterns and relationships.
5
The Linear Model The linear model is just an equation of a straight line through the data. The points in the scatterplot don’t all line up, but a straight line can summarize the general pattern with only a couple of parameters. The linear model can help us understand how the values are associated.
6
The Linear Model Unlike correlation, the linear model requires that there be an explanatory variable and a response variable. Linear Model A line that describes how a response variable y changes as an explanatory variable x changes. Used to predict the value of y for a given value of x. Linear model of the form:
7
The Linear Model The model won’t be perfect, regardless of the line we draw. Some points will be above the line and some will be below. The estimate made from a model is the predicted value (denoted as ).
8
The Linear Model The predicted value:
Putting a hat on y is standard statistics notation to indicate that something has been predicted by a model. Whenever you see a hat over a variable name or symbol, you can assume it is the predicted version of that variable or symbol.
9
Example: Linear Model Observed Values Linear Model Predicted Values
10
The Linear Model The linear model will not pass exactly through all the points, but should be as close as possible. A good linear model makes the vertical distances between the observed points and the predicted points (the error) as small as possible. This “error” doesn’t mean it’s a mistake. Statisticians often refer to variability not explained by the model as error.
11
The Linear Model Predicted value ŷ (y-hat) Observed value y Error = observed – predicted (y – ŷ)
12
Residuals This “error”, the difference between the observed value and its associated predicted value is called the residual. To find the residuals, we always subtract the predicted value from the observed one:
13
Residuals Symbol for residual is: e Why e for residual?
Because r is already taken. No, the e stands for “error.” So,
14
Residuals A negative residual means the predicted value’s too big (an overestimate). A positive residual means the predicted value’s too small (an underestimate). In the figure, the estimated fat of the BK Broiler chicken sandwich is 36 g, while the true value of fat is 25 g, so the residual is –11 g of fat.
15
“Best Fit” Means Least Squares
Some residuals are positive, others are negative, and, on average, they cancel each other out. So, we can’t assess how well the line fits by adding up all the residuals. Similar to what we did with deviations, we square the residuals and add the squares. The smaller the sum, the better the fit. The line of best fit is the line for which the sum of the squared residuals is smallest, the least squares line.
16
Least – Squares Regression Line (LSRL)
The LSRL is the line that minimizes the sum of the squared residuals between the observed and predicted y values (y – ŷ).
17
Correlation and the Line
What we know about correlation from chapter 7 can lead us to the equation of the linear model. Start with a scatterplot of standardized values. Standardized scatterplot – zy (standardized fat) vs zx (standardized protein). Original scatterplot - fat versus protein for 30 items on the Burger King menu.
18
Correlation and the Line
What line would you choose to model the relationship of standardized values? Start at the center of the line. If an item has average protein , should it have average fat ? Yes, so the line should pass through the point This is the first property of the line we are looking for, it must always pass through the point In the plot of z-scores, the point is the origin and then the line passes through the origin (0, 0).
19
Correlation and the Line
The equation for a line that passes through the origin is y = mx. So the equation on our standardized plot will be We use to indicate that the point on the line is the predicted value , not the actual value zy.
20
Correlation and the Line
Many lines with different slopes pass through the origin. Which one best fits our data? That is, which slope determines the line that minimizes the sum of the squared residuals? It turns out that the best choice for slope is the correlation coefficient r. So, the equation of the linear model is
21
Correlation and the Line
What does this tell us? Moving one standard deviation away from the mean in x moves us r standard deviations away from the mean in y. Put generally, moving any number of standard deviations away from the mean in x moves us r times that number of standard deviations away from the mean in y.
22
How Big Can Predicted Values Get?
r cannot be bigger than 1 (in absolute value), so each predicted y tends to be closer to its mean (in standard deviations) than its corresponding x was. This property of the linear model is called regression to the mean; the line is called the regression line.
23
The Term Regression Sir Francis Galton related the heights of sons to the heights of their fathers with a regression line. The slope of the line was less than one. That is, sons of tall fathers were tall, but not as much above the mean height as their fathers had been above their mean. Sons of short fathers were short, but generally not as far from their mean as their fathers. Galton interpreted the slope correctly as indicating a “regression” toward the mean height. And regression stuck as a description of the method he used to find the line.
24
The Regression Line in Real Units
Remember from Algebra that a straight line can be written as: In Statistics we use a slightly different notation: We write to emphasize that the points that satisfy this equation are just our predicted values, not the actual data values. This model says that our predictions from our model follow a straight line. If the model is a good one, the data values will scatter closely around it.
25
The Regression Line in Real Units
We write b1 and b0 for the slope and intercept of the line. b1 is the slope, which tells us how rapidly changes with respect to x. b0 is the y-intercept, which tells where the line crosses (intercepts) the y-axis.
26
The Regression Line in Real Units
In our model, we have a slope (b1): The slope is built from the correlation and the standard deviations: Our slope is always in units of y per unit of x.
27
The Regression Line in Real Units
In our model, we also have an intercept (b0). The intercept is built from the means and the slope: Our intercept is always in units of y.
28
Example: Fat Versus Protein
The regression line for the Burger King data fits the data well: The equation is The predicted fat content for a BK Broiler chicken sandwich (with 30 g of protein) is (30) = 35.9 grams of fat.
29
Calculate Regression Line by Hand
First calculate the following for the data; The means The standard deviations The correlation r Then the LSRL is Slope y- - intercept
30
Calculate Regression Line on TI-83/84
Enter the data into lists: explanatory variable L1 and response L2 STAT/CALC/LinReg(a+bx)/L1,L2,VARS/Y-VARS/FUNCTION/Y1 Your display on the screen shows LinReg(a+bx)L1,L2,Y1. This creates the LSRL and stores it as function Y1. The LSRL will now overlay your scatterplot.
31
Graphing the LSRL by Hand
The equation of the LSRL makes prediction easy. Just substitute an x-value into the equation and calculate the corresponding y-value. Use the equation to calculate two points on the line. One at each end of the line (ie. low x-value and high x-value). Plot the two points and draw a line.
32
Example: Calculate the LSRL by hand and on the calculator (r = -.64).
33
LSRL by Hand Calculate the slope Calculate the y-intercept
From 2-VAR Stats Calculate the y-intercept
34
LSRL by Hand - Continued
Then the LRSL is; Or in the context of the problem
35
By Calculator STAT/CALC/LinReg(a+bx)/L1,L2,VARS/Y-VARS/FUNCTION/Y1 or
y=a+bx a= b= r2= r= or
36
Your Turn: Calculate the linear model by hand using r=.894.
37
Your Turn: Calculate and graph the linear model using the Ti-83/84.
Year Powerboat Reg. (1000s) Manatees Killed 1977 447 13 1978 460 21 1979 481 24 1980 498 16 1981 513 1982 512 20 1983 526 15 1984 559 34 1985 585 33 1986 614 1987 645 39 1988 675 43 1989 711 50 1990 719 47 Calculate and graph the linear model using the Ti-83/84.
38
Facts About LSRL The distinction between explanatory and response variables is essential in regression. LSR uses the distances of the data points from the line in only the y direction. If the 2 variables are reversed, you get a different LSRL. The LSRL always passes through the point
39
More Facts on LSRL There is a close connection between correlation and the slope of the LSRL. A change of one standard deviation in x corresponds to a change of r standard deviations in y.
40
Residuals Revisited The linear model assumes that the relationship between the two variables is a perfect straight line. The residuals are the part of the data that hasn’t been modeled. Data = Model + Residual or (equivalently) Residual = Data – Model Or, in symbols,
41
Residuals Revisited Residuals help us to see whether the model makes sense. When a regression model is appropriate, nothing interesting should be left behind. After we fit a regression model, we usually plot the residuals in the hope of finding…nothing.
42
Residuals Revisited The residuals for the BK menu regression look appropriately boring: The sum of the residuals is always equal to zero.
43
Finding Residuals Use the LSRL to find predicted values for each observed value and calculate the corresponding residual. Example: Data – (0,1) (1,6) (2,8) (3,13) (4,13) LSRL ŷ = x
44
Calculated Residuals
45
Residual Plot Is a scatterplot of the residuals against the explanatory variable (x). The residuals are plotted on the vertical axis. The explanatory variable (x) is plotted on the horizontal axis. The residual plot helps us assess the fit of a regression line.
46
Residual Plot Whenever you calculate a LSRL on the TI-83/84, the calculator automatically calculates the residuals for that particular LSRL and stores them in a list named RESIDS. To create a residual plot on the calculator, make sure you calculate the LSRL first.
47
Another Example - Data
48
Scatterplot
49
Residual Plot
50
What to Look for on the Residual Plot
Random points, no pattern – data fits the linear model. Curved pattern – the relationship is not linear. Increasing (or decreasing) spread about the zero line as x increases – Prediction of y will be less (more) accurate for larger values of x.
51
Random Points, No Pattern
52
Curved Pattern
53
Increasing Spread
54
Residual Plot Individual points with large residuals – these points are outliers in the vertical (y) direction. Outlier in the y direction
55
Residual Plot Individual points that are extreme in the x direction – these points are outliers in the horiztonal (x) direction, such points may not have large residuals, but they can be very important. Outlier in the x direction
56
Residual Plot No regression analysis is complete without a display of the residuals to check that the model is reasonable. Because the residuals are the “left over” after the model describes the relationship, they often reveal subtleties that were not clear from a plot of the original data.
57
Importance of Checking the Residual Plot
The scatterplot of the data seems to indicate that a linear model will be a good fit.
58
Next, the LSRL The LSRL ŷ = x yieds an r = and r2 =
59
Now the Residual Plot The residual plot, however, displays a distinctly curved pattern, indicating that a nonlinear model will be a better fit for the data. The pattern you see in the residual hints at a model you may need to fit your data.
60
Moral Always look at a residual plot of your data!
Any function is linear if plotted over a small enough interval. A residual plot will help you to see patterns in the data that may not be apparent in the original graph.
61
The Residual Standard Deviation
If the residual plot shows no interesting pattern, we can look at how large the residuals are. After all, we are trying to make them as small as possible. Since the mean of the residuals is always zero, it makes sense to look at how they vary or their standard deviation.
62
The Residual Standard Deviation
The standard deviation of the residuals, se, measures how much the points spread around the regression line. For se to make sense, the residuals should all share the same variation or spread. Check to make sure the residual plot has about the same amount of scatter throughout. Check the Equal Variance Assumption with the Does the Plot Thicken? Condition. We can check the Equal Variance Assumption in the original scatterplot or in the residual plot.
63
Equal Variance Assumption
Use either the original scatterplot or the residual plot. Scatterplot: Variation about the regression line is about the same. Residual plot: Variation about the zero residual line is about the same. Therefore, both plots show the residuals meet the equal Variance Assumption.
64
The Residual Standard Deviation
We estimate the SD of the residuals using: We don’t need to subtract the mean because the mean of the residuals We divide by n-2 rather than n-1. We used n-1 for s when we estimated the mean (used for µ). Now we are estimating both slope and the y-intercept, so we use n-2. We subtract one more for each parameter we estimate.
65
The Residual Standard Deviation
Then it’s a good to make a histogram of the residuals. It should look unimodal and roughly symmetric. Then we can apply the Rule to see how well the regression model describes the data.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.