Chapter 7
Fat Versus Protein: An Example
The following is a scatterplot of total fat versus
The Linear Model
The correlation in this example is 0.83. Using
that value and the graph, last chapter we said “There is a fairly strong, linear, positive
association between protein and fat.”
In this chapter we will say more about the linear
The Linear Model (cont.)
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
Residuals
The model won’t be perfect, regardless of the line
we draw.
As George Box said “All models are wrong, but
some models are useful.”
Some points will be above the line and some will
be below.
The estimate made from a model is the predicted
Residuals (cont.)
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:
Residuals (cont.)
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
“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.
Correlation and the Line
The figure shows the
scatterplot of z-scores for fat and
protein.
If a burger has average
protein content, it should have about average fat content too.
Moving one standard
Correlation and the Line (cont.)
Put generally, moving any number of standard
deviations away from the mean in x moves us r
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
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.
y
=
mx
+
b
ˆ
y
=
b
0+
b
1x
ˆ
The Regression Line in Real
Units(cont.)
We write
b
1 and
b
0 for the slope and intercept ofthe line.
b
1 is the slope, which tells us how rapidly
changes with respect to
x
.
b
0 is the y-intercept, which tells where the line
crosses (intercepts) the
y
-axis.ˆ
The Regression Line in Real Units
(cont.)
In our model, we have a slope (b
1):
The slope is built from the correlation and the
standard deviations:
The Regression Line in Real Units
(cont.)
In our model, we also have an intercept (b 0).
The intercept is built from the means and the
slope:
Our intercept is always in units of y.
Regression line equation
where
y
ˆ
=
b
0+
b
1x
y
s
s
r
Regression line equation
b
1 = slope of line.
For every unit increase in x, changes by the
amount of the slope.
Very important for interpreting data.
b
0 = y-intercept of line.
The value of when x = 0.
Usually not important for interpreting data.
Values of x are usually not close to 0.
y
ˆ
Calculating the regression line.
Degree Days vs. Gas Usage
9953 . 0 , 37 . 3 , 74 . 17 , 31 . 5 , 31 .
22 = = = =
= y s s r
x x y
x y
Calculating the regression line.
Degree Days vs. Gas Usage
9953 . 0 , 37 . 3 , 74 . 17 , 31 . 5 , 31 .
22 = = = =
= y s s r
x x y
19
.
0
74
.
17
37
.
3
)
9953
.
0
(
1
=
=
=
Calculating the regression line.
Degree Days vs. Gas Usage
9953 . 0 , 37 . 3 , 74 . 17 , 31 . 5 , 31 .
22 = = = =
= y s s r
x x y
19
.
0
74
.
17
37
.
3
)
9953
.
0
(
1
=
=
=
x y
s
s
r
b
x
b
y
Calculating the regression line.
Degree Days vs. Gas Usage
9953 . 0 , 37 . 3 , 74 . 17 , 31 . 5 , 31 .
22 = = = =
= y s s r
x x y
19
.
0
74
.
17
37
.
3
)
9953
.
0
(
1
=
=
=
Calculating the regression line.
Don’t forget to write the equation.
Interpretations
Slope
For every one unit increase in degree days,
there is a predicted 0.19 unit increase in predicted gas usage.
Intercept
Prediction
Use regression equation to predict y from x.
Ex. Predicted gas consumption when degree
days = 40?
Ex. Predicted gas consumption when degree
Prediction
Use regression equation to predict y from x.
Ex. Predicted gas consumption when degree
days = 40?
Ex. Predicted gas consumption when degree
days = 20?
67 . 8 6 . 7 07 . 1 ) 40 ( 19 . 0 07 . 1
ˆ = + = + =
y 87 . 4 8 . 3 07 . 1 ) 20 ( 19 . 0 07 . 1
ˆ = + = + =
Example: pg. 189 #13
A random sample of records of sales of homes from Feb. 15 to Apr. 30, 1993, from the files maintained by the Albuquerque Board of Realtors gives the price (in thousands of dollars) and size (in square feet) of 117 homes. A regression analysis gives us the model:
a. What does the slope of this line say about housing prices and
house size?
b. What price would you predict to pay for a 3000 square foot
home?
c. A real estate agent shows a potential buyer a 1200 sq-ft home
with an asking price that is $6000 less than one would expect to
Example: pg. 189 #13 cont.
a. Every square foot increase in size increases the
average price $0.061x1000, or $61.
b. $230,820 (230.82 thousand)
Example: Success in College pg. 192 #28
Colleges use SAT scores in the admissions process because they believe these scores provide some insight into how a high school student will perform at the college level. Suppose that entering freshmen at a certain college have mean combined SAT scores of 1833 with a standard deviation of 123. In the first semester these students attained a mean GPA of 2.66 with a standard deviation of 0.56. A scatterplot showed the association to be reasonably linear, and the correlation between SAT score and GPA was 0.47.
a. Write the equation of the regression line.
Example: Success in College pg. 192 #28
a. predictedGPA =-1.262 + 0.00214SAT
b. One could say that a person with a 0 SAT score would have a -1.262 gpa, but this is impossible. The y
intercept serves to adjust the line and is meaningless by itself.
c. The expected GPA increases 0.21 points for every
hundred combined SAT points.
d. 3.23
e. R2 is only .221. SAT is probably only somewhat useful.
Plotting the regression line
Find two points on line.
Pick two x values
Find predicted for each x value.
Ex. x = 20, =4.87 and x = 40, = 8.67
Plot two points on graph.
Make line through two points.
Regression line .
y
ˆ
Properties of regression line
Regression line always goes through point
r is connected to the value of b
1.
r has same sign as b
1.
)
,
(
x
y
x y
Properties of regression line
The values of the y variable vary.
Regression line tries to explain variation
of y through its relationship with x.
Not perfectly – points not exactly on line.
Points close to line: regression explains
variation of y well.
Points far from line: regression does not explain
Properties of regression line
How much variation can we explain with our
regression?
Answer: R2
Percent of variation in y that is explained by the
linear relationship with x.
Higher values of R2 mean regression line helps
Degree Days vs. Gas Usage
R2 = r2
Ex. r = 0.9953, R2 = 0.9906 or 99.06% of the
Example: Roller Coasters
People who responded to a July 2004 Discovery
Channel poll names the 10 best roller coasters in the United States. A table in Chapter 7,
Exercise 33 shows the length of the initial drop (in feet) and the duration of the ride (in
seconds). A regression to predict duration from drop has R2=12.4%.
a. What are the variables and units in this
regression?
b. Write a sentence (in context) summarizing that
Example: Roller Coasters
a. y: Duration (in seconds) x: drop (in feet)
b. 12.4% of the variation in the duration of the ride on the roller coaster can be explained by a
linear relationship with the drop.
c. 0.352 The correlation coefficient of .352 shows a weak, positive linear relationship between
Residuals
Variation in y not measured by regression line. Formula:
Residual for each data point.
Mean of residuals = 0.
y
y
Example: Calculating Residuals
Degree Days vs. Gas Usage
Find the residual for the point (30,6.4)
Calculating Residuals
Degree Days vs. Gas Usage
Find the residual for the point (30,6.4)
Explain what this residual means in context?
x
y
ˆ
=
1
.
07
+
0
.
19
Residual Plots
Scatterplot
Explanatory variable (x) on horizontal axis.
Residuals (e) on vertical axis.
Horizontal line at residual = 0.
Good Residual Plot
No pattern or shape
Technology
We almost always use technology to find the
equation of the regression line.
Your calculator has a Linear Regression tool.
Computer software makes a table for regression.
This table is what is usually provided on the AP
Fat Versus Protein: An Example
The regression line for the
Burger King data fits the data well:
The equation is
Residuals Revisited (cont.)
The residuals for the BK menu regression look
Interpreting Residual Plots
Curved Pattern
relationship is not linear.
Increasing spread about line as x increases.
Predictions of y for larger x will be less accurate.
Decreasing spread about line as x increases.
The ages (in months) and heights (in
inches) of seven children are given.
x
1624426075102 120
y
24303540485660
Find the LSRL.
LSRL Song
(to YMCA tune)Young man, is your scatterplot straight? I said, young man, is your r value great?
I said, young man, check your residual plot, Good fits look so, so, so messy!! (repeat)
Let’s predict with the LSRL. Let’s predict with the LSRL.
The Residual Standard Deviation
The standard deviation of the residuals, s
e, measures how much the points spread around the regression line.
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 interpret s
e in the context of a data set. It is the typical error in the predictions made by the regression
AP Tips
Make sure you can find the following values from
a computer’s regression output.
The explanatory and response variables
R2 (and ignore R2(adj.)) slope and y-intercept
AP Tips
Know how to interpret these values in the context
of the problem.
Make sure to include model words (predicted
approximately, about, etc…) when interpreting slope and y-intercept. Without those words, you will not receive full credit.
Be able to take the square root of R2 to find the
AP Tips
Know how to calculate an individual residual and
interpret its value in context.
Always write regression equations with the data
Assumptions and Conditions
Quantitative Variables Condition: Regression can only be done on two
quantitative variables (and not two categorical variables), so make sure to check this
condition.
Straight Enough Condition:
The linear model assumes that the relationship
Assumptions and Conditions (cont.)
If the scatterplot is not straight enough, stop here.
You can’t use a linear model for any two
variables, even if they are related.
They must have a linear association or the
model won’t mean a thing.
Some nonlinear relationships can be saved by
Assumptions and Conditions (cont.)
It’s a good idea to check linearity again after
computing the regression when we can examine the residuals.
Does the Plot Thicken? Condition:
Look at the residual plot -- for the standard
Assumptions and Conditions (cont.)
Outlier Condition:
Watch out for outliers.
Outlying points can dramatically change a
regression model.
Outliers can even change the sign of the slope,
misleading us about the underlying relationship between the variables.
If the data seem to clump or cluster in the
Reality Check:
Is the Regression Reasonable?
Statistics don’t come out of nowhere. They are
based on data.
The results of a statistical analysis should
reinforce your common sense, not fly in its face.
If the results are surprising, then either you’ve
What Can Go Wrong?
Don’t fit a straight line to a nonlinear relationship.
Beware extraordinary points (y-values that stand
off from the linear pattern or extreme x-values).
Don’t extrapolate beyond the data—the linear
model may no longer hold outside of the range of the data.
Don’t infer that x causes y just because there is a
good linear model for their relationship— association is not causation.
What have we learned?
When the relationship between two quantitative
variables is fairly straight, a linear model can help summarize that relationship.
The regression line doesn’t pass through all
What have we learned? (cont.)
The correlation tells us several things about the
regression:
The slope of the line is based on the correlation,
adjusted for the units of x and y.
For each SD in x that we are away from the x
mean, we expect to be r SDs in y away from the y
mean.
Since r is always between –1 and +1, each
What have we learned?
The residuals also reveal how well the model
works.
If a plot of the residuals against predicted
values shows a pattern, we should re-examine the data to see why.
The standard deviation of the residuals
What have we learned? (cont.)
The linear model makes no sense unless the
Linear Relationship Assumption
is satisfied.
Also, we need to check the
Straight Enough
Condition
and
Outlier Condition
with a
scatterplot.