Two-Variable Statistics
Senior 6 · Basic Mathematics
Two-Variable Statistics
Lesson 2 of 4
25 min
"Strong" and "weak" are judgements; two people can look at the same scatter diagram and disagree. To compare data sets fairly, statisticians measure correlation with a number. The measure is built in two steps: first the covariance, then Pearson's coefficient of correlation, which rescales the covariance so that it always lies between and .
A kiosk owner in Kigali counted the bottles of water she sold on five days and noted each day's maximum temperature (illustrative data):
| Day | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| Temperature, (°C) | 22 | 24 | 25 | 27 | 29 |
| Bottles sold, | 40 | 46 | 50 | 55 | 62 |
For values :
The variance is the mean of the squared distances from the mean; the standard deviation brings it back to the original units. The second form, "mean of the squares minus the square of the mean", is quicker with a table of .
Draw a vertical line at and a horizontal line at . For each point form the product .
A point above and to the right of the means gives (positive)(positive), a positive product; a point below and to the left gives (negative)(negative), also positive. Points in the other two quadrants give negative products. When most points lie in the "+" quadrants, the sum of the products is positive: positive correlation. Here all five points lie in the "+" quadrants.
Definition
The covariance of and is the mean of the products of the deviations:
Its sign gives the direction of the linear relationship. Its size depends on the units, so on its own it cannot say "strong" or "weak". Example: for the pairs , , , .
Definition
Pearson's coefficient of correlation divides the covariance by both standard deviations:
It has no units. Example: if , and , then .
Worked example
Worked example 1. Find the covariance and for the water data.
| 22 | 40 | 484 | 1600 | 880 |
| 24 | 46 | 576 | 2116 | 1104 |
| 25 | 50 | 625 | 2500 | 1250 |
| 27 | 55 | 729 | 3025 | 1485 |
| 29 | 62 | 841 | 3844 | 1798 |
| 127 | 253 | 3255 | 13085 | 6517 |
Means: , .
A very strong positive linear correlation: hotter days went with more bottles sold.
Worked example
Worked example 2. The tomato seller's data from the previous lesson give , , , , , , with the price in Frw per kg and the mass sold in kg. Find .
, .
A very strong negative linear correlation. Notice that the covariance, , looks huge only because prices are in hundreds of francs; removes the effect of the units.
| Value of | Common description (a rule of thumb, not a law) |
|---|---|
| strong | |
| moderate | |
| weak | |
| no linear correlation |
The Organic Chemistry Tutor works through r from the covariance and the two standard deviations. If a video divides by n − 1 instead of n, r is the same, because the divisor appears above and below the fraction and cancels.
Warning
Check your answer. If you ever get , you have made an arithmetic error, most often by using where was needed, or by forgetting to subtract . Keep at least four significant figures in and until the last step, then round to 3 decimal places.
Tip
Calculator check: most scientific calculators have a two-variable statistics mode (often labelled "A+BX"). Enter the pairs and read off directly. Always show the table in an exam, then use the calculator to confirm.
Practice
Important
gives the direction; gives direction and strength on a scale from to .
Sources and credits
Text, data, diagram, worked examples and exercises: Written by Ganzaa. All data are illustrative.
Video: How To Calculate The Correlation Coefficient Using The Covariance Formula, The Organic Chemistry Tutor, embedded from YouTube.