Lessons and exercises follow the school system and stay in its language.Les leçons et les exercices suivent le système scolaire et restent dans sa langue.Lektionen und Übungen folgen dem Schulsystem und bleiben in seiner Sprache.
Every lesson of the chapter, ready for paper. Exercise sets are lettered A, B, C… and answered at the end.
To save a PDF, choose “Save as PDF” in the print dialog.
Grade 8
Associations in data
NicknameDate
Scan to open onlineenglish.sedifier.com/en-us/us-ma-2017/grade-8/us.g8.associations/
1. Scatterplots and correlation
Warm-up
Three quick questions from earlier lessons.
Test scores have mean 61 and standard deviation 10. Find the z-score of a score of 48.
Heights are approximately normal with mean 76 and standard deviation 4. By the 68–95–99.7 rule, what percent are between 72 and 84?
Mean 72, standard deviation 2. Which value has z-score −3?
Discover
Points lie close to a line going down from left to right. Which correlation fits?
r=−0.95
r=0.2
Key idea
Describe a scatterplot by direction, form, strength and unusual points. Correlation measures linear strength.
The correlationr is between −1 and 1: its sign gives the direction, ∣r∣ the strength of a linear relationship. It has no units, does not change when units change, and is the same if x and y are swapped. It is sensitive to outliers and misleading for curved patterns.
Worked example
Hours of study vs test score: r=0.78.
Direction: positive (more study, higher scores)
Positive r.
Strength: fairly strong, linear
|r| = 0.78.
Scores out of 50 or 100: same r
Unitless.
Your turn, guided
Your turn: r=0.6 for (x,y). What is r for (y,x)?
0.6
Symmetric in x and y.
Practice ★
A scatterplot of car age against resale value has r=−0.94. How would you describe the relationship?
Strong, negative, linear: older cars tend to be worth less
Weak, because r is negative
Each extra year causes a fixed loss of value
A scatterplot of car age against resale value has r=−0.92. How would you describe the relationship?
Strong, negative, linear: older cars tend to be worth less
Weak, because r is negative
Each extra year causes a fixed loss of value
Heights (cm) and weights (kg) of students have r=0.58. Heights are converted to inches. What is the new correlation?
Still 0.58: changing units does not change r
Smaller, since inches are bigger units
It cannot be known without the data
Watch out!
Practice ★★
Which statements about the correlation r of 50 pairs (x,y) are true? Tick all that are.
−1≤r≤1
r has no units
Swapping x and y does not change r
r measures the strength of any relationship, curved or straight
r=0 means there is no relationship at all
Exit ticket
Three questions to check you have got it.
A scatterplot of car age against resale value has r=−0.94. How would you describe the relationship?
Strong, negative, linear: older cars tend to be worth less
Weak, because r is negative
Each extra year causes a fixed loss of value
A scatterplot of car age against resale value has r=−0.92. How would you describe the relationship?
Strong, negative, linear: older cars tend to be worth less
Weak, because r is negative
Each extra year causes a fixed loss of value
A scatterplot of car age against resale value has r=−0.90. How would you describe the relationship?
Strong, negative, linear: older cars tend to be worth less
Weak, because r is negative
Each extra year causes a fixed loss of value
Summary card
Correlation
−1≤r≤1; sign = direction, size = linear strength.
Unitless; symmetric in x and y.
Watch out: r only sees straight lines.
One more step is optional: a challenge. Try it, or finish the lesson now.
Challenge ★★★
Every point of a data set lies exactly on the line y=50−9x. What is the correlation r?
2. The least-squares regression line
Warm-up
Three quick questions from earlier lessons.
A scatterplot of car age against resale value has r=−0.94. How would you describe the relationship?
Strong, negative, linear: older cars tend to be worth less
Weak, because r is negative
Each extra year causes a fixed loss of value
Which statements about the correlation r of 50 pairs (x,y) are true? Tick all that are.
−1≤r≤1
r has no units
Swapping x and y does not change r
r measures the strength of any relationship, curved or straight
r=0 means there is no relationship at all
Heights (cm) and weights (kg) of students have r=0.58. Heights are converted to inches. What is the new correlation?
Still 0.58: changing units does not change r
Smaller, since inches are bigger units
It cannot be known without the data
Discover
If r=1, every point is on a line. A student 1 SD above the mean in x is then 1 SD above the mean in y. If r=0.5, how many SDs above the mean in y would you predict?
0.5 SD
1 SD
Key idea
The line that minimizes the sum of squared residuals.
Least-squares regression liney^=a+bx with slope b=rsxsy and intercept a=yˉ−bxˉ; it always passes through (xˉ,yˉ).
Worked example
r=0.6, xˉ=10, sx=2, yˉ=50, sy=8.
Step 1The data.
Step 2The point of means (x̄, ȳ) = (10, 50).
Step 3The line ŷ = 26 + 2.4x passes through it.
Step 4Residuals: no other line makes the sum of their squares smaller.
b=2.4
0.6 × 8/2.
a=26
50 − 2.4 × 10.
y^=26+2.4×12=54.8
At x = 12.
Your turn, guided
Your turn: r=0.5, sx=4, sy=6. The slope.
b=0.75
0.5 × 6/4.
Practice ★
r=0.6, sx=15 and sy=16. Find the slope of the least-squares regression line of y on x.
r=0.5, sx=11 and sy=17. Find the slope of the least-squares regression line of y on x.
The regression line is y^=29+2x. Predict y for x=3.
Watch out!
Practice ★★
The least-squares line has slope 3, and xˉ=20, yˉ=12. Find its intercept.
The least-squares line has slope 4, and xˉ=97, yˉ=157. Find its intercept.
Exit ticket
Three questions to check you have got it.
r=0.6, sx=15 and sy=16. Find the slope of the least-squares regression line of y on x.
r=0.5, sx=11 and sy=17. Find the slope of the least-squares regression line of y on x.
r=0.9, sx=19 and sy=12. Find the slope of the least-squares regression line of y on x.
Summary card
Least-squares line
b=rsy/sx, a=yˉ−bxˉ, through (xˉ,yˉ).
Watch out: sy on top.
One more step is optional: a challenge. Try it, or finish the lesson now.
Challenge ★★★
r=0.9, sx=20 and sy=19. Every y-value is doubled. What is the new slope of the least-squares line?
3. Residuals and residual plots
Warm-up
Three quick questions from earlier lessons.
r=0.6, sx=15 and sy=16. Find the slope of the least-squares regression line of y on x.
The least-squares line has slope 3, and xˉ=20, yˉ=12. Find its intercept.
The regression line is y^=29+2x. Predict y for x=3.
Discover
The model predicts 70 for a student who actually scored 76. Is the student above or below the line, and by how much?
6 above
6 below
Key idea
Residuals show what the line misses.
Residual = observed − predicted =y−y^. Positive: point above the line. A residual plot (residuals against x) should look like random scatter around 0; a curve or a fan shape means a linear model is not appropriate.
Worked example
y^=12+3x; the data point is (5,30).
y^=27
Predicted.
Residual =30−27=3
Observed − predicted.
The point is 3 above the line
Positive.
Your turn, guided
Your turn: same line, point (4,20).
Residual −4
20 − 24.
Practice ★
y^=30+3x. A data point is (7,46). Find its residual.
y^=36+4x. A data point is (3,41). Find its residual.
y^=32+6x. A data point is (7,70). Find its residual.
Watch out!
Practice ★★
The residual plot of a linear model fitted to 56 points shows a clear U-shaped curve. What does that tell you?
A straight line is not a good model: the relationship is curved
The model is good, because residuals are both positive and negative
There is one outlier
A point has residual +8. Where is it relative to the regression line?
8 units above the line: the model underpredicts it
8 units below the line
On the line
Exit ticket
Three questions to check you have got it.
y^=30+3x. A data point is (7,46). Find its residual.
y^=36+4x. A data point is (3,41). Find its residual.
y^=32+6x. A data point is (7,70). Find its residual.
Summary card
Residuals
e=y−y^; positive is above the line.
Residual plot: no pattern means a linear model is appropriate.
Watch out: observed minus predicted, in that order.
One more step is optional: a challenge. Try it, or finish the lesson now.
Challenge ★★★
A least-squares line is fitted to three points. Two residuals are 3 and −7. What is the third residual?
4. Interpreting a regression model: slope, r², extrapolation
Warm-up
Three quick questions from earlier lessons.
r=0.6, sx=15 and sy=16. Find the slope of the least-squares regression line of y on x.
The least-squares line has slope 3, and xˉ=20, yˉ=12. Find its intercept.
The regression line is y^=29+2x. Predict y for x=3.
Discover
price=2+0.5weight for bags of rice (dollars, kg). What does 0.5 mean?
Each extra kg adds 0.5 dollars to the predicted price
Every bag costs exactly 0.5 dollars per kg
Key idea
Interpret in context, and know the limits.
Slope: the predicted change in y for each one-unit increase in x. Intercept: the predicted y when x=0 (meaningful only if x=0 makes sense). r2: the fraction of the variation in y explained by the linear model. Predicting outside the range of the data is extrapolation and is unreliable.
Worked example
r=0.9 for study hours and scores.
r2=0.81
Square r.
81% of the variation in scores is explained by the linear model on hours
Interpretation.
19% is not explained
The rest is other factors and chance.
Your turn, guided
Your turn: r=−0.7. Find r2.
0.49
(−0.7)².
Practice ★
A regression has r=0.2. What fraction of the variation in y is explained by the linear model (r2)?
A regression has r=0.8. What fraction of the variation in y is explained by the linear model (r2)?
For trees, height=3+8age (feet, years). What does 8 mean?
For each extra year of age, the predicted height increases by 8 feet
Every tree grows exactly 8 feet each year
A tree of age 0 is 8 feet tall
Watch out!
Practice ★★
A model for children aged 2 to 6 predicts height from age. Is it reasonable to use it for a 40-year-old?
No: 40 is far outside the ages used to fit the model (extrapolation)
Yes, if r is close to 1
Yes: a line can be extended forever
Exit ticket
Three questions to check you have got it.
A regression has r=0.2. What fraction of the variation in y is explained by the linear model (r2)?
A regression has r=0.8. What fraction of the variation in y is explained by the linear model (r2)?
A regression has r=0.4. What fraction of the variation in y is explained by the linear model (r2)?
Summary card
Interpreting regression
Slope: predicted change per unit of x.
r2: share of variation explained.
No extrapolation.
Watch out: r2, not r, is the explained fraction.
One more step is optional: a challenge. Try it, or finish the lesson now.
Challenge ★★★
A regression line has a negative slope and r2=10064. What is r?
5. Two-way tables: joint, marginal and conditional proportions
Warm-up
Three quick questions from earlier lessons.
A survey of 23 students records the following. Tick all the categorical variables.
Eye color
ZIP code
Takes the bus to school (yes/no)
Height in cm
Number of siblings
Area codes such as 770 are numbers. Is the area code of a phone number a quantitative variable?
No: it is categorical, a label that only looks like a number
Yes: its values are numbers
Yes, a discrete quantitative variable
A study measures the resting heart rate of 29 runners. What are the cases (observational units)?
The 29 runners
The heart rates
The number 29
Discover
In a class, 12 of 20 girls and 9 of 15 boys play a sport. Who is more likely to play, a girl or a boy?
Equally likely: 60% each
A girl: 12 is more than 9
Key idea
A two-way table counts cases by two categorical variables.
Joint proportion: a cell ÷ grand total. Marginal proportion: a row or column total ÷ grand total. Conditional proportion: a cell ÷ its row (or column) total: the proportion within one group.
A survey asked 145 people whether they exercise weekly. Under 30: 22 yes, 43 no. Age 30 or over: 27 yes, 53 no. What proportion of the under-30s exercise weekly?
A survey asked 121 people whether they exercise weekly. Under 30: 59 yes, 12 no. Age 30 or over: 23 yes, 27 no. What proportion of the under-30s exercise weekly?
A survey asked 150 people whether they exercise weekly. Under 30: 41 yes, 40 no. Age 30 or over: 19 yes, 50 no. What proportion of the under-30s exercise weekly?
Watch out!
Practice ★★
A survey asked 124 people whether they exercise weekly. Under 30: 21 yes, 50 no. Age 30 or over: 31 yes, 22 no. What proportion of all the people exercise weekly?
A survey asked 140 people whether they exercise weekly. Under 30: 47 yes, 17 no. Age 30 or over: 37 yes, 39 no. What proportion of all the people are under 30 and exercise weekly?
A survey asked 135 people whether they exercise weekly. Under 30: 44 yes, 25 no. Age 30 or over: 10 yes, 56 no. What proportion of all the people are under 30 and exercise weekly?
Exit ticket
Three questions to check you have got it.
A survey asked 145 people whether they exercise weekly. Under 30: 22 yes, 43 no. Age 30 or over: 27 yes, 53 no. What proportion of the under-30s exercise weekly?
A survey asked 121 people whether they exercise weekly. Under 30: 59 yes, 12 no. Age 30 or over: 23 yes, 27 no. What proportion of the under-30s exercise weekly?
A survey asked 150 people whether they exercise weekly. Under 30: 41 yes, 40 no. Age 30 or over: 19 yes, 50 no. What proportion of the under-30s exercise weekly?
Summary card
Two-way tables
Joint: cell / total. Marginal: margin / total.
Conditional: cell / its group total.
Watch out: name the group you condition on.
One more step is optional: a challenge. Try it, or finish the lesson now.
Challenge ★★★
Of 150 students, 50 play an instrument, 40 play a club sport, and 12 do both. How many do neither?
6. Association between categorical variables
Warm-up
Three quick questions from earlier lessons.
A survey asked 145 people whether they exercise weekly. Under 30: 22 yes, 43 no. Age 30 or over: 27 yes, 53 no. What proportion of the under-30s exercise weekly?
A survey asked 124 people whether they exercise weekly. Under 30: 21 yes, 50 no. Age 30 or over: 31 yes, 22 no. What proportion of all the people exercise weekly?
A survey asked 140 people whether they exercise weekly. Under 30: 47 yes, 17 no. Age 30 or over: 37 yes, 39 no. What proportion of all the people are under 30 and exercise weekly?
Discover
70% of students who sleep 8+ hours passed a test, and 40% of those who sleep less passed. Is there an association between sleep and passing?
Yes, the pass rates differ
We cannot tell without an experiment
Key idea
Compare conditional distributions.
Two categorical variables are associated if the conditional distribution of one differs across the groups of the other. If the conditional proportions are all equal, there is no association. Association in observational data does not show causation.
Worked example
Of 50 phone users, 30 sleep badly; of 50 non-users, 10 sleep badly.
60% vs 20% sleep badly
Within each group.
Association between phone use and sleep
A big difference.
It does not prove phones cause bad sleep
Observational data.
Your turn, guided
Your turn: the difference in proportions (users − non-users).
0.4
0.6 − 0.2.
Practice ★
Of 40 drivers who texted, 30 had a near-miss; of 40 who did not text, 10 had one. Is there an association between texting and near-misses in these data?
Yes: 75% of texters vs 25% of non-texters had a near-miss
No: both groups have 40 drivers
Yes, and it proves texting causes near-misses
In a school, 50 of 125 girls and 100 of 250 boys walk to school. What does this suggest?
No association: 40% of each group walks
Boys are more likely to walk: 100 > 50
Girls are more likely to walk
Watch out!
Practice ★★
A survey asked 135 people whether they exercise weekly. Under 30: 44 yes, 40 no. Age 30 or over: 18 yes, 33 no. Find the proportion of under-30s who exercise minus the proportion of those 30 or over who exercise.
A survey asked 163 people whether they exercise weekly. Under 30: 45 yes, 37 no. Age 30 or over: 48 yes, 33 no. Find the proportion of under-30s who exercise minus the proportion of those 30 or over who exercise.
Exit ticket
Three questions to check you have got it.
A survey asked 135 people whether they exercise weekly. Under 30: 44 yes, 40 no. Age 30 or over: 18 yes, 33 no. Find the proportion of under-30s who exercise minus the proportion of those 30 or over who exercise.
A survey asked 163 people whether they exercise weekly. Under 30: 45 yes, 37 no. Age 30 or over: 48 yes, 33 no. Find the proportion of under-30s who exercise minus the proportion of those 30 or over who exercise.
A survey asked 112 people whether they exercise weekly. Under 30: 28 yes, 48 no. Age 30 or over: 13 yes, 23 no. Find the proportion of under-30s who exercise minus the proportion of those 30 or over who exercise.
Summary card
Association
Compare conditional proportions across groups.
Different: associated. Equal: not associated.
Watch out: association is not causation; counts are not rates.
One more step is optional: a challenge. Try it, or finish the lesson now.
Challenge ★★★
People were asked if they exercise weekly. Under 30: 37 yes, 28 no. Age 30 or over: 31 yes, 46 no. Of the people who said yes, what fraction are under 30?
7. The least-squares line
Discover
A line fits some points, but none lies exactly on it. Which line is 'best'?
The one that makes the sum of the squared vertical misses as small as possible
Any line through two of the points
Key idea
Least squares.
The least-squares line y=mx+b makes ∑(yi−mxi−b)2 as small as possible. It always passes through the mean point (xˉ,yˉ).
Worked example
Data: (1,2), (2,3), (3,7). The least-squares slope is 2.5. Find b.
xˉ=2, yˉ=4
Mean point.
4=2.5×2+b, so b=−1
The line passes through it.
Your turn, guided
Your turn: the line has slope 3 and xˉ=4, yˉ=20. Find b.
b=8
20=3×4+b.
Practice ★
A least-squares line has slope 7 and the mean point is (7,57). Find its intercept b.
A least-squares line has slope 8 and the mean point is (8,25). Find its intercept b.
A least-squares line has slope 8 and the mean point is (5,43). Find its intercept b.
Practice ★★
Three points have residuals 1, −1 and 0 for the line y=2x+1. Find the sum of the squared residuals.
Three points have residuals 1, −1 and 0 for the line y=2x+9. Find the sum of the squared residuals.
Exit ticket
Two questions to check.
A least-squares line has slope 7 and the mean point is (7,57). Find its intercept b.
A least-squares line has slope 8 and the mean point is (8,25). Find its intercept b.
Summary card
Least squares
Minimize the sum of squared residuals.
The line passes through (xˉ,yˉ).
Every spreadsheet's 'trend line' is a least-squares line.
8. History of regression: Legendre, Gauss and Galton
Discover
Around 1800, astronomers had more observations of a comet than they needed, and the observations did not quite agree. How could they combine them?
Choose the orbit that makes the squared errors as small as possible
Keep only the best observation
Key idea
From comets to heights of children.
Step 1Adrien-Marie Legendre1752–1833Unknown artist. Public domain1806: Legendre's book on comet orbits gives the least-squares method in an appendix.
Step 2Carl Friedrich Gauss1777–1855Gottlieb Biermann / After Christian Albrecht Jensen, 1840. Public domain1809: Gauss publishes his own version of least squares.
Step 3Francis Galton1822–1911Eveleen Myers (née Tennant), 1890s. Public domainGalton (born 1822) compares heights of parents and children and names regression.
Legendre gave the least-squares method in an appendix to his 1806 book on comet orbits; Gauss published his version in 1809. Later Francis Galton (born 1822) studied how tall children are compared with their parents: very tall parents tend to have children closer to the average. He called this regression, and drew the regression line.
Worked example
Galton's idea with numbers: a regression slope of 0.5 means that 10 cm above average for the parents predicts…
0.5×10
Multiply by the slope.
5 cm above average for the child
Closer to the average.
Practice ★
In which book did Legendre first print the method of least squares, in 1806?
A book on the orbits of comets
A book on heights of children
A book on games of chance
Galton's regression: the slope is 0.7. Parents are 17 cm above average. How many cm above average is the predicted child?
Galton's regression: the slope is 0.5. Parents are 12 cm above average. How many cm above average is the predicted child?
Galton's line passes through the mean point (170 cm, 170 cm) with slope 0.7. Predict the height (cm) of the child of parents 19 cm above the mean, that is 189 cm.
Summary card
Regression today
Economists predict prices and sales with regression lines.
Doctors relate dose and effect, or age and blood pressure.
Machine learning starts with least squares.
Sources: MacTutor biographies of Legendre, Gauss and Galton (see "Sources and credits").
Answers: Associations in data
1. Scatterplots and correlation
A
−1.3
81.5
66
B
Strong, negative, linear: older cars tend to be worth less
Strong, negative, linear: older cars tend to be worth less
C
Still 0.58: changing units does not change r
D
−1≤r≤1 · r has no units · Swapping x and y does not change r
E
Strong, negative, linear: older cars tend to be worth less
Strong, negative, linear: older cars tend to be worth less
Strong, negative, linear: older cars tend to be worth less
F
−1
2. The least-squares regression line
A
Strong, negative, linear: older cars tend to be worth less
−1≤r≤1 · r has no units · Swapping x and y does not change r
Still 0.58: changing units does not change r
B
0.64
2217
C
35
D
−48
−231
E
0.64
2217
9554
F
1.71
3. Residuals and residual plots
A
0.64
−48
35
B
−5
−7
−4
C
A straight line is not a good model: the relationship is curved
D
8 units above the line: the model underpredicts it
E
−5
−7
−4
F
4
4. Interpreting a regression model: slope, r², extrapolation
A
0.64
−48
35
B
0.04
0.64
C
For each extra year of age, the predicted height increases by 8 feet
D
No: 40 is far outside the ages used to fit the model (extrapolation)
E
0.04
0.64
0.16
F
−54
5. Two-way tables: joint, marginal and conditional proportions
A
Eye color · ZIP code · Takes the bus to school (yes/no)
No: it is categorical, a label that only looks like a number
The 29 runners
B
6522
7159
8141
C
3113
D
14047
13544
E
6522
7159
8141
F
72
6. Association between categorical variables
A
6522
3113
14047
B
Yes: 75% of texters vs 25% of non-texters had a near-miss
C
No association: 40% of each group walks
D
35761
−221497
E
35761
−221497
6845
F
6837
7. The least-squares line
A
8
−39
3
B
2
2
C
8
−39
8. History of regression: Legendre, Gauss and Galton