How to calculate the correlation coefficient?[1]
In class, we introduced five types of correlation coefficient. Among them, researchers use Pearson product-moment and Spearman rank correlation coefficient more frequently than other correlation types. The following are the procedure of calculating them and some notes.
Pearson product-moment correlation coefficient
It measures the linear relationship between X and Y, X and Y should be continuous variables: interval or ratio variables.
CovXY is called covariance, equal to . Its format is very similar to variance we learned before: . It measures how two variables go together, or co-vary.
Here is an example:
ID / X / / / Y / / /1 / 8 / 5.14 / 2.86 / 10 / 6.00 / 4.00 / 11.44
2 / 7 / 5.14 / 1.86 / 8 / 6.00 / 2.00 / 3.72
3 / 3 / 5.14 / -2.14 / 2 / 6.00 / -4.00 / 8.56
4 / 5 / 5.14 / -.14 / 6 / 6.00 / .00 / .00
5 / 7 / 5.14 / 1.86 / 9 / 6.00 / 3.00 / 5.58
6 / 2 / 5.14 / -3.14 / 2 / 6.00 / -4.00 / 12.56
7 / 4 / 5.14 / -1.14 / 5 / 6.00 / -1.00 / 1.14
By the standard deviation formula we used in variability, , we can get SX = 2.27, SY=3.21.
Finally,
Spearman rank correlation coefficient
It is used for ordinal variables. When a nonlinear, monotonically increasing or decreasing function describe the relation between X and Y, we can convert the continuous variables to ranks (ordinal variables) to get linear relationship between X and Y. With X and Y's rank scores, Spearman’s correlation coefficient can be computed with the Pearson formula.
ID / X / Y / Rank on X / / / Rank on Y / / /1 / 1 / 4 / 1.5 / 5 / -3.5 / 1 / 5 / -4 / 14
2 / 1 / 8 / 1.5 / 5 / -3.5 / 2 / 5 / -3 / 10.5
3 / 2 / 10 / 3 / 5 / -2 / 3 / 5 / -2 / 4
4 / 3 / 14 / 4 / 5 / -1 / 4 / 5 / -1 / 1
5 / 4 / 15 / 5 / 5 / 0 / 5 / 5 / 0 / 0
6 / 5 / 16 / 6 / 5 / 1 / 6 / 5 / 1 / 1
7 / 6 / 17 / 7 / 5 / 2 / 7 / 5 / 2 / 4
8 / 7 / 18 / 8 / 5 / 3 / 8.5 / 5 / 3.5 / 10.5
9 / 8 / 18 / 9 / 5 / 4 / 8.5 / 5 / 3.5 / 14
[1] Yue Yin cited from <Statistical Reasoning for Behavioral Sciences>, Shavelson, R. J (1996)