A teacher records, for each student, the hours spent studying in the week before a test and the score on that test. Do students who study more tend to score higher, and how closely do the two go together? The answer lives in the pairs, not in the two columns separately. This lesson plots the pairs, measures how they vary together with the sample covariance and the Pearson correlation, shows what a single point or a narrow range can do to those numbers, and adds a rank-based measure for relationships that keep rising without following a straight line.
Key terms
Scatter plot
Definition A scatter plot displays paired observations of two numerical variables, measured on the same individuals, as points in a plane, with one variable on the horizontal axis and the other on the vertical axis. It shows the direction of a relationship (upward or downward), its form (straight, curved or clustered), its strength (how tightly the points follow the form) and any unusual points. When one variable is thought of as explaining the other, it usually goes on the horizontal axis.
In plain words Each point is one individual, so the pairing has to stay intact. A scatter plot shows association in the data. It does not show that one variable causes the other, because other conditions may affect both.
Example Three constructed students studied 1, 2 and 3 hours and scored 2, 1 and 3 points on a short quiz, which gives the points , and . The pattern tilts weakly upward. Sorting the two columns separately would produce , and , a perfect line, but the pairs and belong to no student.
Sample covariance
Definition For pairs with means and , the sample covariance is
A product is positive when both deviations have the same sign and negative when their signs differ. The covariance is positive when the positive products outweigh the negative ones in total, which happens when values above the mean of one variable tend to go with values above the mean of the other. Its unit is the product of the units of the two variables. If every is replaced by and every by , the covariance becomes . The covariance of a variable with itself is its sample variance, so .
In plain words Center both variables, multiply the paired deviations and add the products, then divide by . The sign gives the direction of the joint variation. The size depends on the units, so a covariance of 5 can be large or tiny depending on how the variables were measured.
Example For the three students, hours and points. The deviation pairs are , and , with products 0, 0 and 1, so
measured in hours times points. If every score is multiplied by 10, every deviation is 10 times as large and the covariance becomes 5, although the pattern of the points is unchanged.
Pearson correlation
Definition For pairs whose sample standard deviations satisfy and , the Pearson correlation is
It has no unit and always satisfies . It equals 1 exactly when all points lie on a line with positive slope, and it equals exactly when they lie on a line with negative slope. It is undefined when either variable is constant. Replacing every by leaves unchanged when and reverses its sign when , and the same holds for . The correlation measures linear association, the tendency of the points to follow a straight line, in both direction and strength.
In plain words Correlation is covariance with the units divided out, so it measures how closely the points follow a rising or falling straight line. A value of 0.5 does not mean that half the points agree, or that one variable produces half of the other. A value near 0 means little linear association, not that the variables are unrelated, since a strong curved pattern can give .
Example For the three students, both sample standard deviations equal 1, so . Multiplying every score by 10 multiplies both and by 10, so stays 0.5. Now take and , which gives . Here and , and the deviation products are , , , and . They add to 0, so even though every is determined exactly by its .
Influential observation
Definition An observation is influential for a summary or a fitted relationship when including or removing it changes the result substantially. An outlier is an observation that is unusual relative to the pattern of the rest of the data. A point far from or has a large deviation, so its product can dominate the covariance and the correlation. The two ideas overlap but are not the same, since a point far from the others can be influential while still following the general direction of the rest.
In plain words Look at the scatter plot with and without a questioned point, and report both results. Check whether the point is a recording error or comes from a different situation, but do not delete it only because the answer looks better without it.
Example Add a fourth student, who studied 8 hours and scored 8 points, to the three students. Both means become 3.5, the sum of the deviation products becomes 28, and the new point alone contributes of it. The correlation rises from 0.5 to about 0.97. Had the fourth student scored 1 point instead, the correlation would be about . One point far out on the horizontal axis decides both the sign and the size of here, so the value describes that student more than the other three.
Range restriction
Definition Range restriction occurs when the data cover only part of the range of values that a variable takes in the population of interest, often because individuals were selected on that variable or on a related one. A correlation computed from restricted data describes only the restricted group. It can be smaller or larger than the correlation in the full group, and no general correction recovers the full value without further assumptions.
In plain words A narrow slice of the data can hide a relationship or exaggerate one. Say which group a correlation describes, for example applicants who passed an entrance test rather than all applicants.
Example The six constructed pairs , , , , and have sample covariance 3.1, and both sample variances are 3.5, so . Keeping only the pairs with leaves , and , whose correlation is 0.5. Restriction can also raise a correlation. The curve above has for from to , but its three points with , namely , and , have .
Spearman rank correlation
Definition To compute the Spearman rank correlation , replace each by its rank among the values, with rank 1 for the smallest, and each by its rank among the values. Tied values receive the average of the ranks they would occupy. The Spearman correlation is the Pearson correlation of the pairs of ranks, and it is defined when neither variable is constant. An association is monotonic when tends to move in one direction as increases, upward throughout or downward throughout, at a rate that need not be constant. With no ties, exactly when a larger always comes with a larger , and exactly when a larger always comes with a smaller .
In plain words Pearson correlation asks how close the points are to a straight line. Spearman correlation asks only how well the two orderings agree, so a curve that keeps rising gets a perfect score. Replacing a variable by a strictly increasing function of it, such as the square or the logarithm of positive values, keeps the order and leaves unchanged. A pattern that rises and then falls is not monotonic, and both measures can be near 0 for it. Neither measure establishes causation.
Example For and , the relationship is curved and the Pearson correlation is about 0.98. Both lists are already in increasing order, so both rank lists are 1, 2, 3, 4 and . For the values of the earlier curve, the two values 1 share ranks 2 and 3 and each gets 2.5, and the two values 4 share ranks 4 and 5 and each gets 4.5. The ranks of are 4.5, 2.5, 1, 2.5 and 4.5, and their Pearson correlation with the ranks 1 to 5 of is 0.
Check yourself
- For the pairs , , and , compute the sample covariance and the Pearson correlation.
Show the answer
Both means are 2.5. The deviation products are , , and , which add to 4, so . Each variable has squared deviations 2.25, 0.25, 0.25 and 2.25, which add to 5, so and . The correlation is
- Starting from the pairs in question 1, predict the covariance and the Pearson correlation after each change separately. First, every is converted from hours to minutes. Second, 10 is added to every . Third, every is replaced by . Fourth, every is replaced by its square.
Show the answer
Converting hours to minutes multiplies every by 60, so the covariance becomes . The standard deviation is also multiplied by 60, so stays 0.8.
Adding 10 to every raises the mean by 10 and leaves every deviation unchanged, so the covariance stays and stays 0.8.
Replacing by reverses the sign of every deviation, so the covariance becomes and becomes .
Squaring gives . This change is not linear, so nothing guarantees that is preserved, and in fact the covariance becomes and the correlation about 0.79. The Spearman correlation stays 0.8, because squaring positive numbers keeps their order.
- Five constructed students slept 4, 5, 6, 7 and 8 hours before a test and scored 60, 75, 80, 75 and 60 points. Compute the Pearson correlation. A classmate concludes that the score is unrelated to sleep. Is that right?
Show the answer
The means are 6 hours and 70 points. The deviation products are , , , and , which add to 0, so and .
The conclusion does not follow. The scores rise and then fall in an exactly symmetric pattern, so these five pairs show a clear relationship between sleep and score, but not a linear one. The Spearman correlation is also 0 here, because the ranks of the scores, 1.5, 3.5, 5, 3.5 and 1.5, rise and fall in the same symmetric way. Both measures can miss a pattern that is not monotonic, while a scatter plot shows the curve at once. And even a strong correlation in data like these would show an association, not that sleep causes the scores.