Scatterplots and the Correlation Coefficient
Describe scatterplots by direction, form, strength and outliers, compute Pearson's r, and see why the same r can hide very different patterns.
Welcome back!
Step 1 of 13Learn
Does heat sell iced coffee?
The owner of a small coffee shop suspects that hot days sell more iced drinks. She records the daily high temperature and the number of iced drinks sold for 60 days. Looking at the two columns of numbers tells her almost nothing. Plotting them does.
A scatterplot puts one variable on the x-axis and the other on the y-axis, with one dot per observation. Usually the x-axis holds the explanatory variable (also called the predictor or independent variable), the one you think helps explain or predict the other. The y-axis holds the response variable (the outcome or dependent variable). Here temperature is explanatory and iced drink sales are the response.
Her plot shows dots rising from lower left to upper right: hotter days, more iced drinks. On 30 °C days she sells around 120; on 15 °C days, around 50. There is scatter, of course. Rainy hot days are slower, and a nearby festival produced one huge day that sits far above the cloud.
This whole course is about turning such clouds of dots into precise statements: how strongly two variables are related, what line best summarizes the relationship, how confident we can be about it, and what changes when we add more variables. It starts with learning to read the plot itself.
Step 2 of 13Practice · Chart
Iced drinks sold vs. daily high temperature
Tap the festival day that sits far above the cloud.
Tap the point that answers the question, then press Check.
| Point | High temperature (°C) | Iced drinks |
|---|---|---|
| Day 1 | 14 | 46 |
| Day 2 | 16 | 55 |
| Day 3 | 17 | 52 |
| Day 4 | 19 | 68 |
| Day 5 | 21 | 74 |
| Day 6 | 22 | 70 |
| Day 7 | 24 | 92 |
| Day 8 | 25 | 88 |
| Day 9 | 27 | 104 |
| Day 10 | 28 | 110 |
| Day 11 | 30 | 121 |
| Day 12 | 23 | 185 |
Step 3 of 13Learn
Four things to describe in any scatterplot
When you look at a scatterplot, describe four features:
- Direction: positive if y tends to rise as x rises (temperature and iced drinks), negative if y tends to fall (car age and resale price), or no clear direction.
- Form: is the pattern roughly a straight line, or does it curve? Fuel economy versus speed rises and then falls; the value of a savings account grows along a curve. Many regression tools assume a straight line, so spotting curvature early matters.
- Strength: how tightly do the points cluster around the pattern? A tight band is strong; a loose cloud is weak.
- Unusual points: outliers that sit far from the pattern, and points with extreme x-values far from the rest. The festival day is an outlier in y. A single 45 °C heatwave day would be extreme in x.
Also look for clusters, separate groups of points that might be different populations mixed together, such as weekdays and weekends forming two parallel bands.
Describing these features in words before calculating anything protects you from nonsense. A correlation coefficient or regression line calculated on curved, clustered or outlier-dominated data can be technically correct and completely misleading. The plot is not decoration; it is the first and most important step of every regression analysis.
Step 4 of 13Practice · Choose one
A researcher studies whether the number of hours students sleep before an exam helps predict their exam scores. Which variable belongs on the x-axis?
Step 5 of 13Learn
Measuring linear association: Pearson's r
The correlation coefficient r puts a number on the direction and strength of a linear relationship. One way to define it uses z-scores. Convert each x and each y to a z-score, multiply the pairs and average them, dividing by n − 1:
r = Σ(z_x × z_y) / (n − 1)
The intuition: when a point is above average in both x and y, or below average in both, the product of its z-scores is positive. When it is above in one and below in the other, the product is negative. If most points fall in the "same side" quadrants, r is positive; if most fall in the "opposite side" quadrants, r is negative; if they are spread evenly, r is near zero.
An equivalent formula uses sums of squares. With Sxy = Σ(x − x̄)(y − ȳ), Sxx = Σ(x − x̄)² and Syy = Σ(y − ȳ)²:
r = Sxy / √(Sxx × Syy)
Example: five students practiced 1, 2, 3, 4 and 5 hours and scored 3, 5, 4, 7 and 8 on a 10-point quiz. The means are 3 and 5.4, and you can check that Sxy = 12, Sxx = 10 and Syy = 17.2. So r = 12 / √(10 × 17.2) = 12 / 13.11 ≈ 0.92, a strong positive linear relationship.
Step 6 of 13Practice · Diagram
Reading r on its scale
Which pair has the weakest linear relationship?
Tap the shape that answers the question, then press Check.
- Car age vs. resale price
Older cars sell for less, fairly consistently.
- Shoe size vs. exam score
No linear relationship to speak of.
- Sleep vs. exam score
A real tendency, with lots of scatter.
- Temperature vs. iced drinks
Points hug a rising line.
Step 7 of 13Try the calculator
Correlation from sums of squares
Enter Sxy, Sxx and Syy. The defaults are the practice-hours example.
- Correlation r
- 0.915
- r squared
- 0.837
Step 8 of 13Practice · Work it out
For a dataset, Sxy = −30, Sxx = 25 and Syy = 64. What is the correlation coefficient r? Give two decimal places.
Step 9 of 13Learn
Properties and pitfalls of r
Useful properties of r:
- It always lies between −1 and +1. The extremes mean all points lie exactly on a line.
- It has no units and doesn't change if you rescale either variable, such as Celsius to Fahrenheit or dollars to euros.
- It is symmetric: the correlation of x with y equals the correlation of y with x.
And its pitfalls:
- It only measures straight-line association. A perfect U-shaped relationship can have r = 0.
- Outliers can dominate it. One extreme point can turn r = 0.1 into r = 0.7, or the reverse.
- Restricted range weakens it. Among all job applicants, test scores may correlate well with later performance. Among only the hired applicants, who all scored high, the correlation looks much weaker, because the range of scores was cut off.
- Aggregation strengthens it. Correlations between averages, such as state-level income and state-level voting, are usually much stronger than the same relationship between individuals.
- It is not the slope. r = 0.9 doesn't mean y rises 0.9 units per unit of x. A steep and a shallow line can have the same r if the points hug each line equally closely.
The cure for most of these is the same: plot the data before trusting any number.
Step 10 of 13Note
Step 11 of 13Practice · Match the pairs
Match each correlation to the best description of its scatterplot.
Tap an answer, then tap the place where it belongs (or drag it there).
- r = 0.95
- r = −0.60
- r = 0.05
- r = −0.98
Step 12 of 13Practice · True or false
Converting temperature from Celsius to Fahrenheit changes the correlation between temperature and iced drink sales.
Step 13 of 13Practice · Choose one
A company finds a correlation of 0.6 between an aptitude test and job performance across all applicants it tested, but only 0.2 among the employees it hired, who all had high test scores. What best explains the difference?
Lesson complete!