# Finding the Correlation Coefficient Using Pearson Correlation and Spearman Rank Correlation

*Ray is a licensed engineer in the Philippines. He loves to write about mathematics and civil engineering.*

Comparing the test performances of three students in a classroom and say, John did the best, Betty did the next best, and Cole did the worst, gives us the ranked form. We cannot say how much better John did than Betty and Cole, but we know how the three performed. If presented with their actual test scores, we would have data in measurement form and could determine precisely how much better John did than Betty and Cole. These two different means of identifying the relationship between sets of data are the Spearman Rank Correlation and the Pearson Correlation. But, how are these two different?

## What Is Pearson Correlation?

Pearson Product Moment Correlation is a measure of the correlation between two sets of measured data. It measures the strength of the linear relationship between two sets of data. The formula for calculating the Pearson Product Moment Correlation Coefficient r is:

r = [ n∑XY - ∑X ∑Y ] / √[n∑X^{2} - (∑X)^{2}] [n∑Y^{2} - (∑Y)^{2}]

where

r = Pearson correlation coefficient

n = number of paired values of X and Y

∑X = sum of all X values

∑Y = sum of all Y values

∑X^{2} = sum of all the squares of X

∑Y^{2} = sum of all the squares of Y

∑(XY) = sum of all the products of X and Y

Pearson r | Interpretation |
---|---|

1 | Perfect Linear Relationship |

0 | No Linear Relationship |

-1 | Perfect Linear Relationship |

0 < r < 1 | Positive Correlation |

-1 < r < 0 | Negative Correlation |

There are different interpretations for different values of Pearson correlation coefficient.

- If r = 0, the two sets of data has no linear relationship. Usually, there is no relationship between the points in the scatter graph. The dispersed dots in the diagram reveal no conformity at all.
- If r = 1, the two sets of data signifies a perfect positive correlation. The graph shows a trendline with a positive slope.
- If r = -1, the two sets of data signifies a perfect negative relationship. The graph shows a trendline with a negative slope.
- If r is greater than 0 but less than 1, the two sets of data signify a positive linear relationship. The small x values paired with small y values and large x values paired with large y values.
- If r is between -1 and 0, the two sets of data imply a negative linear relationship. The small x values paired with large y values and large x values paired with small y-values.

## What Is Spearman Rank Correlation?

Spearman rank-difference method is a method of estimating the linear correlation between two sets of ranks without any involvement of the complicated computation of the Pearson product moment correlation coefficient. The formula for calculating the Spearman rank correlation coefficient is:

r_{s} = 1 - [ ( 6∑d^{2} ) / (n(n^{2} - 1)) ]

where

r_{s}* = *Spearman rank correlation coefficient

n = number of pairs in ranks

∑d^{2}* = *sum of the squared differences between ranks

Spearman r | Interpretation |
---|---|

1 | Perfectly Monotone Increasing |

0 | No Monotone Relationship |

-1 | Perfectly Monotone Decreasing |

close to 1 or -1 | Strong Monotone Relationship |

close to 0 | Weak Monotone Relationship |

There are different interpretations for different values of Spearman rank correlation coefficient.

- If r = 0, the two sets of data have no monotone relationship. Usually, there is no relationship between the points in the scatter graph. Probably, the relation is non-monotonic. Non-monotonic graphs explicate as x values increase, y values decrease, but suddenly begins to rise again. An example of a non-monotonic diagram is below.
- If r = 1, the two sets of data signifies a perfectly monotone increasing. Just like in Pearson correlation, the graph shows a trendline with a positive slope.
- If r = -1, the two sets of data signifies a perfectly monotone decreasing. Just like in Pearson correlation, the graph shows a trendline with a negative slope.
- If the value of r is close to 1 or -1, the two sets of data signify a strong tendency to have monotone increasing relationship. The trend of the graph can be increasing or decreasing.
- If the value of r is close to 0, the two sets of data imply an extremely monotone decreasing. Perhaps, it indicates nonexistent.

## Similarities and Differences Between Pearson Correlation and Spearman Rank Correlation

Category | Pearson | Spearman |
---|---|---|

Variables | Measured values | Ranks |

Linear relationship between two variables | Applicable | Not applicable |

Monotone relationship | Applicable | Applicable |

Nonmonotone relationship | Not applicable | Not applicable |

Value of correlation coeffcient | -1 < r < 1 | -1 < r < 1 |

r = 1 | Perfect positive correlation | Perfectly monotone increasing |

r = 0 | No correlation | No monotone relationship |

r = -1 | Perfect negative correlation | Perfectly monotone decreasing |

There are few differences between Pearson Correlation and Spearman Rank Correlation when it comes to measuring the correlation between two sets of data. The two differ in the form of data needed to identify the relationship between two sets of data. The Pearson correlation uses data that is in the type of measurements while Spearman rank correlation uses data in a ranking type. Since the Spearman rank correlation only uses the numbers for ranks, examining the occurrence of the linear relationship between two sets of data is not possible. Pearson correlation measures the linear relationship while Spearman rank correlation only analyses the monotonic relationship between two sets of ranking data.

A monotonic relationship is a relationship which only means two things. It is a relationship in which as X increases, Y increases (monotone increasing) and as X increases, Y decreases (monotone decreasing). On the other hand, a linear relationship means the variables X and Y moves in the same direction at a fixed frequency. Linear relationships show a straight line connecting the variables and monotonic relationships show both straight and curvy lines as long as it satisfies the two conditions.

The value of correlation coefficient for both Pearson and Spearman is always in between -1 and +1. A value of +1 implies a perfect positive relationship while a value of -1 signifies perfect decreasing relationship for both. If the value of the correlation coefficient is 0, the sets of data imply no relationship at all.

## Example 1: Spearman Rank Correlation

A civil engineering professor has ranked eight students on their "social responsiveness" and "conversational abilities" as part of the university's student council project. Given only the ranking, determine if there is a relationship between the two variables using the Spearman rank correlation method.

Student | Social Rank | Skills Rank |
---|---|---|

A | 3 | 6 |

B | 6 | 4 |

C | 1 | 2 |

D | 8 | 8 |

E | 2 | 1 |

F | 5 | 5 |

G | 7 | 7 |

H | 4 | 3 |

**Solution**

a. Create a table and solve for the values of d and d^{2}. Remember that d is the absolute value of the difference between the X and Y ranks.

Student | Social Rank | Skills Rank | d | d^2 |
---|---|---|---|---|

A | 3 | 6 | 3 | 9 |

B | 6 | 4 | 2 | 4 |

C | 1 | 2 | 1 | 1 |

D | 8 | 8 | 0 | 0 |

E | 2 | 1 | 1 | 1 |

F | 5 | 5 | 0 | 0 |

G | 7 | 7 | 0 | 0 |

H | 4 | 3 | 1 | 1 |

b. Solve for the summation of d^{2}. Given n = 8, solve the Spearman rank correlation coefficient using the formula provided.

**Final Answer:** The value of *r** _{s} = *0.81 would indicate that the relationship between the social responsiveness and conversational skills among the students is monotone increasing.

## Example 2: Pearson Correlation

An English Language Test is part of the entrance exam in Malayan Colleges Laguna. The data shows the test scores (X), and final grades (Y) for five randomly selected examinees who took the entrance exam.

a. Draw a scatter diagram for the data.

b. Compute and interpret the Pearson correlation coefficient r.

Examinee | English Language Test Scores (X) | Final Grade (Y) |
---|---|---|

A | 18 | 3.00 |

B | 47 | 2.00 |

C | 36 | 1.75 |

D | 42 | 1.50 |

E | 12 | 5.00 |

### Solution

a. Create a scatter diagram from the given X and Y values. Then, draw the best fit line.

b. Create a table and solve for the values of X^{2}, Y^{2}, and XY.

Examinee | Test Scores (X) | Final Grade (Y) | X^2 | Y^2 | XY |
---|---|---|---|---|---|

A | 18 | 3.00 | 324 | 9.00 | 54 |

B | 47 | 2.00 | 2209 | 4.00 | 94 |

C | 36 | 1.75 | 1296 | 3.0625 | 63 |

D | 42 | 1.50 | 1764 | 2.25 | 63 |

E | 12 | 5.00 | 144 | 25.00 | 60 |

Total | 155 | 13.25 | 5737 | 43.3125 | 334 |

c. Solve for the summation of X, Y, X^{2}, Y^{2}, and XY. Given n = 5, solve the Pearson correlation coefficient using the formula provided.

**Final Answer:** The correlation coefficient is *r *= -0.88. To conclude, there is a high negative correlation between test scores and final grade among the examinees of Malayan Colleges Laguna.

## Example 3: Spearman Rank Correlation and Pearson Correlation

The president of Malayan Colleges Laguna chose ten students from the college of engineering at random and tests their proficiency in Differential Equations and Numerical Methods. As a process for the Accreditation Program, they want to examine the relationship between the two courses. Using the Pearson Correlation and Spearman Correlation methods, identify if there is any relationship between the proficiency in Differential Equations and Numerical Methods.

a. Draw the scatter diagram for these data

b. Compute the Pearson correlation coefficient r.

c. Compute the Spearman rank correlation coefficient.

Student | Differential Equations (X) | Numerical Methods (Y) |
---|---|---|

A | 13 | 25 |

B | 15 | 24 |

C | 16 | 26 |

D | 12 | 22 |

E | 12 | 21 |

F | 13 | 24 |

G | 13 | 24 |

H | 9 | 20 |

I | 8 | 19 |

J | 9 | 15 |

**Solution**

a. Create a scatter diagram from the given X and Y values. Then, draw the best fit line.

b. Create a table and solve for the values of X^{2}, Y^{2}, and XY.

Student | Differential Equations (X) | Numerical Methods (Y) | X^2 | Y^2 | XY |
---|---|---|---|---|---|

A | 13 | 25 | 169 | 625 | 325 |

B | 15 | 24 | 225 | 576 | 360 |

C | 16 | 26 | 256 | 676 | 416 |

D | 12 | 22 | 144 | 484 | 264 |

E | 12 | 21 | 144 | 441 | 252 |

F | 13 | 24 | 169 | 576 | 312 |

G | 13 | 24 | 169 | 576 | 312 |

H | 9 | 20 | 81 | 400 | 180 |

I | 8 | 19 | 64 | 361 | 152 |

J | 9 | 15 | 81 | 225 | 135 |

Total | 120 | 220 | 1502 | 4940 | 2708 |

c. Solve for the summation of X, Y, X^{2}, Y^{2}, and XY. Given n = 10, solve the Pearson correlation coefficient using the formula provided.

To conclude, with *r *= 0.86, there is a high positive correlation between the two subjects Differential Equations and Numerical Methods.

d. Create a table and solve for the values of d and d^{2}. Remember that d is the absolute value of the difference between the X and Y ranks.

Student | Differential Equations (X) | Numerical Methods (Y) | Rank X | Rank Y | d | d^2 |
---|---|---|---|---|---|---|

A | 13 | 25 | 4 | 2 | 2 | 4 |

B | 15 | 24 | 2 | 4 | 2 | 4 |

C | 16 | 26 | 1 | 1 | 0 | 0 |

D | 12 | 22 | 6.5 | 6 | 0.5 | 0.25 |

E | 12 | 21 | 6.5 | 7 | 0.5 | 0.25 |

F | 13 | 24 | 4 | 4 | 0 | 0 |

G | 13 | 24 | 4 | 4 | 0 | 0 |

H | 9 | 20 | 8.5 | 8 | 0.5 | 0.25 |

I | 8 | 19 | 10 | 9 | 1 | 1 |

J | 9 | 15 | 8.5 | 10 | 1.5 | 2.25 |

e. Solve for the summation of d^{2}. Given n = 10, solve the Spearman rank correlation coefficient using the formula provided.

The value of *r** _{s}* = 0.93 would indicate that the relationship between Differential Equations and Numerical Methods among the students is monotone increasing.

**Final Answer:** The Pearson correlation coefficient value is 0.86 while the Spearman rank correlation coefficient value is 0.93. The two answers show that the relationship for the subjects Differential Equations and Numerical Methods is positive and monotone increasing. The results also imply that if a person has a high level of knowledge in Differential Equations, he or she also excels in Numerical Methods.

**© 2018 Raycaptiosus**

## Comments

**Raycaptiosus (author)** from Philippines on June 24, 2018:

Hey, Draco. Not really, I just started to love Mathematics when I entered college. Thank you for taking time to look at my article. Have a nice day!

**Draco** from United Kingdom on June 24, 2018:

WOW GREAT article. Very informative and extremely detailed. I assume you are a mathematician?