ExamSaathi learning library · Government exams · SSC CGL quantitative foundations; published syllabus labelled 2024 · Quantitative aptitude

Karl Pearson's correlation coefficient: strength of a straight-line link

Measure how closely two variables u and v follow a straight line: read scatter diagrams, calculate Karl Pearson's correlation coefficient r from a table of deviations or from the covariance, and use its limits and the change of origin and scale rule.

Status: original pilot lesson. Teacher review is pending. It is not a complete course or official exam material.

You will learn to

Before you start

Correlation looks at pairs of measurements taken on the same people or things: the hours each student revised and the marks that student scored, or the price of tomatoes on a market day and the kilograms sold that day. Here the two variables are called u and v, because x is reserved for multiplication. You will need the mean and the standard deviation from the earlier lessons. For every pair, write du = u - (mean of u) and dv = v - (mean of v); these are the deviations from the two means. The du values always total 0, and so do the dv values. Throughout this lesson a covariance, a variance or a standard deviation is found by dividing by n, the number of pairs.

Scatter diagrams: direction and closeness

A scatter diagram marks every pair as one dot, with u measured along the horizontal axis and v up the vertical axis. Look for two things. Direction: if the dots climb from the lower left towards the upper right, larger u goes with larger v, and the correlation is positive. If they slide from the upper left down to the lower right, larger u goes with smaller v, and the correlation is negative. If they make a shapeless cloud that tilts neither way, there is no correlation. Closeness: the more tightly the dots crowd around a straight line, the stronger the correlation, and when every dot sits exactly on one slanting straight line the correlation is called perfect. A scatter diagram gives a picture but no number; Karl Pearson's coefficient r turns the picture into a number.

Karl Pearson's coefficient r

Karl Pearson's coefficient, also called the product moment correlation coefficient, is r = sum of (du x dv) / sqrt(sum of du^2 x sum of dv^2). The top line decides the sign. A pair with both values above their means, or both below, gives a positive product du x dv; a pair with one value above its mean and the other below gives a negative product. When the positive products outweigh the negative ones, r is positive. The bottom line is positive whenever both variables vary, and it scales the result so that r carries no unit: rupees, kilograms or marks cancel out. Dividing the top and the bottom by n gives the covariance form r = cov(u, v) / (SD of u x SD of v), where the covariance is cov(u, v) = sum of (du x dv) / n and SD of u = sqrt(sum of du^2 / n). The two forms always agree, so pick the one that suits the figures you are given.

The working table, and coding large values

Give each pair one line with seven entries: u, v, du, dv, du x dv, du^2 and dv^2. Total the last three columns, and before going further confirm that the du column and the dv column each come to 0. Then put the three totals into the formula. When the values are large, such as prices of Rs. 20 to Rs. 60 or sales of several hundred kilograms, code them first: from every u subtract a convenient number near the middle and divide by a convenient positive number, and treat every v the same way with its own two numbers. The coded values give exactly the same r and need far less multiplying. If the coded values do not average to 0, take their deviations from their own mean before forming the products, just as with the original values.

What r can and cannot be

The value of r always lies from -1 to +1, so a result outside that range signals an arithmetic slip. r = +1 or r = -1 happens only when every dot lies on one slanting straight line, rising for +1 and falling for -1. Values near either end show a strong straight-line link, and values near 0 a weak one. r = 0 means there is no straight-line link, not that there is no link at all: dots lying on a U-shaped curve can give r = 0 even though each v is fixed by its u. Change of origin and scale: adding a constant to u or to v, subtracting one, or multiplying or dividing either variable by a positive number leaves r exactly as it was. If just one of the two variables is multiplied by a negative number, r keeps its size but changes sign; if both are, the two sign changes cancel.

Common mistakes

Leaving out the square root in the bottom line, or taking the root of only one of the two sums. Putting variances where the covariance form needs standard deviations. Losing the minus sign of a negative product du x dv while adding the column. Skipping the zero-total check on the deviation columns, so a wrong mean spoils every later line. Reading r = 0 as proof that u and v have nothing to do with each other. Treating correlation as cause: across children from Class 1 to Class 8, shoe size and reading speed are strongly correlated because both grow with age, yet bigger shoes do not make anyone read faster. Finally, changing the sign of r after subtracting a constant; only multiplying exactly one variable by a negative number flips the sign.

A routine for correlation questions

1. Name the two variables u and v and count the pairs, n. 2. Predict the direction: should r come out positive or negative? 3. If the numbers are large, code them, always dividing by positive numbers. 4. Find the means, then du and dv for every pair, and confirm that each column totals 0. 5. Add up du x dv, du^2 and dv^2. 6. Work out r = sum of (du x dv) / sqrt(sum of du^2 x sum of dv^2), or r = cov(u, v) / (SD of u x SD of v) when summary figures are given. 7. Sense-check: r must lie from -1 to +1, and its sign must match the direction you predicted. 8. Describe the result as a link between u and v, never as proof that one causes the other.

Worked examples

  1. A teacher in Bhopal noted, for five students, the hours u each spent revising in the week before a test and the marks v each scored out of 20. Written as (u, v), the pairs were (6, 9), (7, 13), (8, 16), (9, 17) and (10, 15). Find Karl Pearson's coefficient r and say what it shows.

    1. Means: mean of u = (6 + 7 + 8 + 9 + 10) / 5 = 40 / 5 = 8 hours, and mean of v = (9 + 13 + 16 + 17 + 15) / 5 = 70 / 5 = 14 marks.
    2. Pair (6, 9): du = -2, dv = -5, du x dv = 10, du^2 = 4, dv^2 = 25.
    3. Pair (7, 13): du = -1, dv = -1, du x dv = 1, du^2 = 1, dv^2 = 1.
    4. Pair (8, 16): du = 0, dv = 2, du x dv = 0, du^2 = 0, dv^2 = 4.
    5. Pair (9, 17): du = 1, dv = 3, du x dv = 3, du^2 = 1, dv^2 = 9.
    6. Pair (10, 15): du = 2, dv = 1, du x dv = 2, du^2 = 4, dv^2 = 1.
    7. Checks and totals: the du values total 0 and so do the dv values. Sum of (du x dv) = 16, sum of du^2 = 10 and sum of dv^2 = 40.
    8. r = 16 / sqrt(10 x 40) = 16 / sqrt(400) = 16 / 20 = 0.8.
    9. Covariance form as a check: cov(u, v) = 16 / 5 = 3.2, SD of u = sqrt(10 / 5) = sqrt(2) and SD of v = sqrt(40 / 5) = sqrt(8). Their product is sqrt(16) = 4, so r = 3.2 / 4 = 0.8 again.

    Answer: r = 0.8, a strong positive correlation: in this group, more hours of revision went with higher marks.

  2. A vegetable stall at a mandi in Nashik recorded the price of tomatoes u (Rs. per kg) and the quantity sold v (kg) on five days. Written as (u, v), the pairs were (20, 500), (30, 460), (40, 380), (50, 420) and (60, 340). Code the values to find r.

    1. Code the data with g = (u - 40) / 10 and h = (v - 420) / 40. Subtracting a constant and dividing by a positive number do not change r.
    2. Coded pairs (g, h): (-2, 2), (-1, 1), (0, -1), (1, 0) and (2, -2). Each coded column totals 0, so the coded means are 0 and the coded values already are the deviations.
    3. Products g x h: -4, -1, 0, 0 and -4, total -9.
    4. Squares g^2: 4, 1, 0, 1 and 4, total 10. Squares h^2: 4, 1, 1, 0 and 4, total 10.
    5. r = -9 / sqrt(10 x 10) = -9 / 10 = -0.9.

    Answer: r = -0.9 for both the coded and the original figures, a strong negative correlation: on dearer days the stall sold fewer kilograms.

  3. Over 10 summer days in Jaipur, the noon temperature u (degrees C) and the glasses of sugarcane juice v sold at a stall had cov(u, v) = 21, variance of u = 9 and variance of v = 100. Find r. The stall prepares 300 glasses' worth of juice every morning, so w = 300 - v glasses are left unsold each day. Find the correlation coefficient between u and w as well.

    1. Standard deviations: SD of u = sqrt(9) = 3 and SD of v = sqrt(100) = 10.
    2. r between u and v = cov(u, v) / (SD of u x SD of v) = 21 / (3 x 10) = 21 / 30 = 0.7.
    3. w = 300 - v multiplies v by -1 and then adds 300. Adding 300 changes nothing, but the factor -1 flips the sign of r and keeps its size.
    4. Direct check: cov(u, w) = -21 and SD of w = 10, so r between u and w = -21 / 30 = -0.7.

    Answer: r = 0.7 between temperature and glasses sold, and r = -0.7 between temperature and glasses left unsold.

Practice checks

  1. Five tailors in Surat have u years of experience and stitch v shirts a week. Written as (u, v), the pairs are (8, 12), (9, 14), (10, 18), (11, 16) and (12, 20). Karl Pearson's coefficient r is:
  2. For a set of paired data, cov(u, v) = -12, the variance of u is 16 and the variance of v is 25. The correlation coefficient r is:
  3. The correlation coefficient between u and v is 0.45. Two new variables are made: g = (u - 7) / 3 and h = (12 - v) / 4. The correlation coefficient between g and h is:
  4. For u = 1, 2, 3, 4 and 5 the values of v are 4, 1, 0, 1 and 4, so each v equals (u - 3)^2 exactly. What is Karl Pearson's r for these five pairs, and what does it show?
  5. For some paired data, r = 0.8, the sum of (du x dv) = 48 and the sum of du^2 = 40. The sum of dv^2 is:

Sources checked