İnteraktif Dersler

Two variables: scatter plots, correlation and regression

Lecture notes

Definition

Pairs and the table of pairs

In a study of two variables every person (or thing) gives two numbers, a pair . The table of pairs lists them: one column or row for and one for . Both variables are quantitative: they are numbers, such as hours and a pulse.
x123456y787475706865
Example
Six pupils: hours of sport per week () and resting pulse (). The third pupil does 3 hours and has a pulse of 75, so the pair is . Six pairs give six dots.
12456760657080xy375
Definition

The scatter plot

A scatter plot draws every pair as one dot: along the horizontal axis and along the vertical axis. Look at the whole cloud of dots. Does it rise or fall (direction)? Is it a narrow band or wide (strength)? Does it bend? Is one dot far from the others?
xy
Example
Twelve pupils: the dots fall from left to right (dashed arrow). The pupils who do more sport tend to have a lower resting pulse. The arrow is only a help for the eye.
xy
Definition

The question, the explanatory and the response variable

A good question names two quantitative variables and who is measured: “Is there a relationship between and among the pupils of a school?” The explanatory variable goes on the horizontal axis. The response variable is the one we expect to change with it. Swapping them does not change , but it changes the line of best fit.
xyyx
Example
Five pairs give the line . With the axes swapped the line is : another line, but the same .
Rule

Plan and prepare the data

To get pairs you can trust: choose the pupils at random (everybody has the same chance), take enough pairs (15 or more), keep no names, and prepare the lists. Both lists have the same length, every value is a number and the units are clear (hours, beats per minute).
Example
A school has 600 pupils. Give each pupil a number, let the computer draw 30 numbers and measure those 30 pupils: 30 pairs. Asking 5 friends is not random and too few.
Rule

The count ratio by regions

Draw a vertical line at the mean of and a horizontal line at the mean of . They cut the plot into four regions: A upper right, B upper left, C lower left, D lower right. Count the dots in each region (a dot on a line is not counted). A and C are the same direction regions, B and D the opposite ones. The count ratio goes from to .
xyABCD
Example
Ten dots: A , B , C , D . The count ratio is .
xy4141
Rule

Reading the count ratio

A count ratio near means that almost all dots are in A and C: a positive relationship (higher , higher ). Near almost all dots are in B and D: a negative relationship. Near both pairs of regions hold the same number: no clear direction. This is the idea behind the correlation coefficient .
xyxyxy
Example
Left: gives . Middle: gives . Right: gives .
Definition

The correlation coefficient r

The correlation coefficient is one number for the straight-line relationship of two quantitative variables. Software gives it: you do not work it out by hand. Its sign is the direction and its size is the strength. or means that all dots lie on a straight line. has no unit.
xyxyxyxy
Example
For the five pairs , , , , the software gives : a strong positive relationship.
Rule

Direction and strength in words

The direction is positive when (the dots rise) and negative when (they fall). The strength comes from , the size without the sign. A rule of thumb (books differ a little): below 0.2 no relationship, from 0.2 to 0.4 weak, from 0.4 to 0.7 moderate, 0.7 or more strong.
01
Example
: the sign is minus, so the relationship is negative. lies between 0.4 and 0.7: moderate. A moderate negative relationship.
01
Special case

r = 1, r = −1 and no variation

If all dots lie on one rising line, ; on a falling line, . In real data this almost never happens. If all the values are equal (or all the values) nothing varies: cannot be worked out and the software shows an error or a dash. Then there is no direction to talk about.
xy
Example
Six pupils all have a resting pulse of 70, whatever their sport: the dots lie on a flat line. does not exist, but the picture is clear: the pulse does not change with sport.
Tip

Always draw the plot first

Very different data sets can have the same . Only the picture shows the difference: a straight band, a curve, one far dot, or all dots at one value. Never report without looking at the scatter plot.
xyxyxyxy
Example
Anscombe’s four data sets of 11 pairs each all have and the same line . Only the first one looks like a straight band.
Definition

An outlier: one far dot

An outlier is a dot far from the others. One outlier can change a lot: it can make a relationship appear or hide one. Find out why it is far away (a mistake, or a different kind of person?). Do not delete it just because it spoils , and give with and without it.
xy
Example
Ten pupils (shoe size and reading score) have . Add their teacher with shoe size 46 and score 49 and . One dot made the relationship.
xy
Watch out!

A relationship is not a cause

Two variables can move together without one causing the other. A third variable can explain both, or the cause can run the other way. Only a well-designed experiment can show a cause. Say “goes with” or “tends to”, not “causes”. Atomic weight and density of elements also go together, yet neither makes the other.
xy
Example
Over 12 months the ice creams sold and the swimming accidents have . Hot weather (orange months) raises both. Inside the cold months and inside the warm months .
xy
Rule

One sample is one sample

Another random sample gives other pairs, so another . The of a sample is only an estimate for the whole group. Write “in this sample” and do not give too many digits. More pairs make steadier.
xyxy
Example
In a (simulated) school where is about 0.6, two random samples of 12 pupils gave and .
Watch out!

Few pairs, not a random sample

Five friends are too few and not a random sample: they cannot speak for everybody. A line through a few chosen dots can look perfect and still be wrong for the whole group.
xy
Example
The five orange friends have and a steep line. All 12 pupils (the grey ones too) have and a flatter line.
Definition

The line of best fit

The line of best fit (regression line) runs through the cloud and is used to predict from . The slope tells how much changes for 1 more . The intercept is the predicted at (it can be meaningless). Software gives and .
1234564045505560xy
Example
Revision hours and marks of five pupils give . Each extra hour goes with about 4 more marks in this sample.
1234564045505560xy14
Definition

The residual

The residual of a dot is actual minus predicted: the vertical distance from the dot to the line. A dot above the line has a positive residual, a dot below it a negative one.
12345645505560xy+1−20+2−1
Example
At the line predicts and the pupil scored 58: residual . At it predicts 48 and the pupil scored 46: residual .
Rule

Least squares

The best line is the one with the smallest sum of the squares of the residuals: the method of least squares. Squaring makes every miss positive and punishes big misses more. Every other line has a larger sum.
1234564045505560xy
Example
Best line : . A line drawn by eye, : . The best line has the smaller sum.
14041416140
Rule

Two things that are always true

For the line of least squares the residuals add up to , and the line goes through the point of the means . So you can find the intercept from the means and the slope.
124564060xy352
Example
, and : . The residuals add up to .
Rule

Interpolation: predicting inside the data

Predicting for an inside the range of the data is interpolation. It is fairly safe when the relationship is strong and the dots are close to the line. A prediction is a guide, not a promise.
1234564045505560xy
Example
hours lies between 1 and 5, inside the data. marks.
Watch out!

Extrapolation and impossible values

Predicting outside the range of the data is extrapolation. The pattern may stop or bend, and the line can give values that are impossible: a mark above 100, a negative length. Do not stretch a line far beyond the data.
5101520406080100120xy
Example
hours: marks. That is impossible: the line reaches 100 at 15 hours ().
Watch out!

Mixed groups can turn a trend round

When two groups are mixed in one plot, the trend of all dots together can be the opposite of the trend inside each group. Colour the groups and look at each one.
xy
Example
Hours of study and marks of 10 pupils in two courses: all together (more study, lower mark?). Inside the easy course and inside the hard course : more study raises the mark in both. The hard-course pupils study more but get lower marks.
xy
Special case

r measures straight lines only

tells how well the dots follow a straight line. Dots on a curve can have a strong relationship and still . So means “no straight-line relationship”, not “no relationship”.
xy
Example
Seven dots on with from to : and the best line is flat at . Yet is exactly .
Rule

When the dots bend, use another model

Even a high does not make a straight line right. If the dots bend, look at the residuals: a pattern such as says “curve”. Then try a power or an exponential model (the applications power-fit and exponential-models).
xy
Example
Bacteria that double: 1, 2, 4, 8, 16, 32 at times 0 to 5. The best straight line has , but the dots follow exactly.
Tip

A careful sentence

Say what the data show and nothing more: “In this sample of [number] [group], [x] and [y] have a [strength] [positive or negative] relationship ( …). This does not show that [x] causes [y].” Words like “tends to” are right; “proves” and “always” are wrong.
Example
In this sample of 30 pupils, more sleep goes with higher marks: a moderate positive relationship (). This does not show that sleep causes the marks.
Tip

The checklist for claims

When somebody makes a claim about two variables, check: (1) a third variable behind both? (2) a far dot that makes or hides the pattern? (3) mixed groups? (4) few pairs or not a random sample? (5) extrapolation or an impossible value? (6) words too strong for the size of or a cause? (7) a curve, where does not fit?
Example
Claim: “Ice cream sales and swimming accidents have , so ice cream is dangerous.” Check 1: hot weather raises both. Check 6: the claim says “cause”. Verdict: refute.
Rule

Refute or accept

Name the flaw and give a number as the reason: with and without a dot, inside each group, the value of the line at the of the claim. Refute a claim when the flaw changes its conclusion. Accept it when it says only what the data show, with care.
Example
“Pupils with bigger shoes read better ().” Without the teacher : refute. “In this random sample of 30 pupils, more sleep goes with higher marks ()”: no cause, inside the data: accept.
Tip

Where to look next

When the dots bend open the applications power-fit and exponential-models. For the summary tools of one variable open data-tools. To practise choosing a display and a summary for ready-made data open ready-data-lab in “Data and questions”.
Example
If doubles at every step (1, 2, 4, 8, 16, 32) open exponential-models. If grows like open power-fit.

Exercises

The software gives for 12 pupils: hours of sport per week and resting pulse. Say the direction and the strength of the relationship. Easy
xy
Show solution
is negative, so the dots fall from left to right: a negative relationship.
is 0.7 or more: strong.
Answer → a strong negative relationship
This describes the dots in the sample. It does not say that sport lowers the pulse.
The dashed lines go through the means of and . Count the dots in the four regions and work out the count ratio. Easy
xyABCD
Show solution
Count: A , B , C , D .
xy4141
Same direction: . Opposite: .
The count ratio is .
Answer → 0.6
A positive count ratio points the same way as . The software gives for these dots: also positive.
For five pupils the mean revision time is 3 hours and the mean mark is 52. The slope of the line of best fit is 4 marks per hour. Find the intercept and write the line. Easy
124564060xy352
Show solution
The line goes through the point of the means: .
.
124564060xy352
Answer →
Check: at the line gives , the mean mark.
The line of best fit is . A pupil with scored 58. Find the residual and say whether the dot is above or below the line. Easy
1234564045505560xy
Show solution
Predicted: .
Residual: actual minus predicted: .
The residual is positive: the dot is above the line.
Answer → residual , above the line
Check: in the picture the orange dot is 2 marks above the line.
Use (the revision hours were between 1 and 5) to predict the mark after 2.5 hours. Can you trust it? Medium
1234564045505560xy
Show solution
.
2.5 lies between 1 and 5, inside the data, and is strong.
Answer → 50 marks, a good guide (interpolation)
It is still a guide: another pupil can score a few marks more or less.
Four residuals of the line of best fit are , , and . Find the fifth residual and the sum of the squares of the five. Medium
Show solution
The residuals of the line of best fit add up to 0: .
So .
12345645505560xy+1−20+2−1
Squares: .
Answer → and the sum of squares
These are the residuals of the five pupils of this page: .
Use to predict the mark after 20 hours of revision. Is that possible? From how many hours does the line give more than 100? Medium
5101520406080100120xy
Show solution
.
A mark above 100 is impossible.
gives : above 15 hours the line gives more than 100.
Answer → 120 marks: impossible; the line passes 100 at 15 hours
The data only cover 1 to 5 hours: this is extrapolation.
For 11 dots (10 pupils and their teacher) the software gives . Without the teacher’s dot . What does the teacher’s dot do, and what do you say about the pupils? Medium
xy
Show solution
With the dot (moderate positive), without it (no relationship).
One far dot creates the relationship.
Among the 10 pupils there is no relationship between shoe size and reading score.
Answer → the far dot creates the relationship; among the pupils there is none
The teacher is not a pupil, so leaving the dot out is fair here. Always say that you left it out.
Two lines go through the five dots: and . Which is the better line? Give the sum of the squares of the residuals of each. Medium
1234564045505560xy
Show solution
First line: residuals ; squares .
Second line: predicted , residuals ; squares .
The smaller sum belongs to the better line.
Answer → (10 against 25)
The residuals of the second line add up to , not 0: it is not the line of least squares.
Over 12 months the ice creams sold and the swimming accidents have . Somebody says: “ice cream causes swimming accidents”. Why is that not supported? Medium
xy
Show solution
Look at the colours: warm months (orange) have many ice creams and many accidents, cold months (blue) have few of both.
Hot weather is a third variable that raises both.
Inside the cold months , inside the warm months : hardly any relationship is left.
xy
Answer → a third variable (hot weather) explains both; a pattern is not a cause
Only a well-designed experiment can show a cause.
Two random samples of 12 pupils of the same school give and . Can both be right? What should a report say? Medium
xyxy
Show solution
Each sample has other pupils, so each has another .
Both are honest estimates of the of the whole school.
A report says “in this sample” and warns that a new sample gives another .
Answer → yes, both can be right; say “in this sample” and mention the uncertainty
More pairs make steadier.
Five pairs: , , , , . Find the line of best fit and the sum of the squares of the residuals. Hard
Show solution
Means: , . Deviations: is and is .
and , so and : .
2464812xy
Predicted ; residuals ; squares .
Answer → and the sum of squares
Check: the residuals add up to 0.
The line for five pupils is ( in hours) with . Now is in half-hours: . Find the new slope, intercept and . What changes if you swap and ? Hard
Show solution
, so : slope 2, intercept 40. has no unit: still .
Swapped: stays , but the slope of on is about , not : another line.
Answer → slope 2, intercept 40, ; swapped: same , other line
A new unit changes the slope, not .
Ten pupils, two courses. All together , in the easy course , in the hard course . “Studying more lowers your mark,” says a teacher. Refute it. Hard
xy
Show solution
Group lines: easy , hard . Both slopes are positive.
At 5 hours: easy , hard .
The negative comes from mixing the groups.
Answer → refute: inside each course more study raises the mark
Colour the groups before you trust one .
Five dots lie exactly on : , , , , . The software gives . A pupil says: “So and are not related.” Is that right? Hard
xy
Show solution
and the dots on the left mirror the dots on the right: the line of best fit is flat, , so .
But exactly: a perfect relationship, a curve.
only measures straight lines: draw the plot first.
Answer → no: there is no straight-line relationship, but is exactly
Check: and both give .

Interactive applications for this topic

Free applications open with a free student account. Teachers can use all applications in a live lesson.

About the free account and Plus

Are you a teacher?

Start live lessons with these applications for your whole class. Free to try for one month.

Try it free

Fits these school years

IB (MYP, Diploma): MYP 5, Diploma, year 1

Cambridge International: IGCSE

Netherlands: Havo · Mathematics A, Vwo · Mathematics A, Vwo · Mathematics C, Vwo · Mathematics D

Türkiye (MEB): Year 11 (MEB)

England (GCSE, A Level): Year 10 (GCSE), Year 11 (GCSE), Year 12 (A Level)

USA (Common Core): Algebra 1

What the applications of this topic teach 5 applications

Scatter plots

  • Turning a situation into a question about two quantitative variables
  • Putting pairs in a scatter plot and reading direction and strength
  • Describing a scatter plot in a careful sentence without a cause

Correlation

  • Reading r: the sign gives direction, the size gives strength
  • Seeing what an outlier does to r
  • Knowing that r measures straight lines only

The line of best fit

  • Putting a line through a cloud by eye and judging it with residuals
  • Knowing the least squares line passes through the point of the means
  • Reading the slope and intercept in words and making a prediction
  • Telling interpolation from extrapolation

Claim critic

  • Finding the flaw in a claim about two variables
  • Using numbers as a reason: r with and without a dot
  • Refuting or accepting a claim with the right reason

Two variables in everyday life

  • Reading a situation: the question, r in words, the sentence in context
  • Using the line for a prediction and deciding how far to trust it
  • Knowing that a relationship is not a cause