1)
Spearman
correlation coefficient:
The content below is from the following source:
o
Original Source: https://statistics.laerd.com/statistical-guides/spearmans-rank-order-correlation-statistical-guide.php
The Spearman
correlation coefficient, S can take
values from +1 to -1. A S of +1
indicates a perfect association of ranks, a S
of zero indicates no association between ranks and a S of -1 indicates a perfect negative association of ranks. The
closer S is to zero, the weaker the
association between the ranks. Ranks are computed by sorting the input values
in descending order. The highest value will have a rank of 1, the next highest
value will have a rank of 2 etc. The following example illustrates the steps in
computing the Spearman correlation coefficient, S.
To calculate a
Spearman rank-order correlation on data without any ties we will use the
following data (indicates scores):
English |
56 |
75 |
45 |
71 |
62 |
64 |
58 |
80 |
76 |
61 |
Math |
66 |
70 |
40 |
60 |
65 |
56 |
59 |
77 |
67 |
63 |
We
then complete the following table:
English (scores) |
Math (scores) |
Rank (English) |
Rank (Math) |
d |
d2 |
56 |
66 |
9 |
4 |
5 |
25 |
75 |
70 |
3 |
2 |
1 |
1 |
45 |
40 |
10 |
10 |
0 |
0 |
71 |
60 |
4 |
7 |
3 |
9 |
62 |
65 |
6 |
5 |
1 |
1 |
64 |
56 |
5 |
9 |
4 |
16 |
58 |
59 |
8 |
8 |
0 |
0 |
80 |
77 |
1 |
1 |
0 |
0 |
76 |
67 |
2 |
3 |
1 |
1 |
61 |
63 |
7 |
6 |
1 |
1 |
We then calculate
the following:
·
∑ d2 = 25 + 1 + 0 + 9
+ 1 + 16 + 0 + 0 + 1 + 1 = 54
We then substitute
this into the main equation with the other information as follows:
·
S
= (1 – (6 * ∑ d2 )/ (n * (n2-1))) = (1
– (6 * 54)/ (10*(102-1))) = (1 – 324/990) = 1-0.33 = 0.67
Hence, we have a S of 0.67. This indicates a
strong positive relationship between the ranks individuals obtained in the Math
and English scores. That is, the higher you ranked in Math, the higher you
ranked in English also, and vice versa.
2) Kendall
correlation coefficient
The content below is from the following
source:
The Kendall
correlation coefficient, τ, can take
values from +1 to -1. A τ of +1
indicates a perfect association of ranks, a τ,
of zero indicates no association between ranks and a τ, of -1 indicates a perfect negative association of ranks.
The closer τ, is to zero, the weaker
the association between the ranks. The following example illustrates the steps
in computing the Kendall correlation coefficient, τ.
The following data
represent an art critic’s ranking of ten paintings and the rankings of the same
paintings by an art student.
Painting# #1 #2 #3 #4 #5 #6 #7 #8 #9 #10
Art Critic: 4 10 3 1 9 2 6 7 8 5
Art Student: 5 8 6 2 10 3 9 4 7 1
By computing the
Kendall’s correlation coefficient, τ,
we will be able to measure the degree of similarity between the rankings of the
art critic and that of the art student. Write a program which computes the
Kendall’s correlation coefficient for the above data.
Follow
the steps as described below:
Step 1: Sort the rankings of the art critic
in ascending order. Wile sorting the art critic rankings, your program should
ensure that the rankings of the art student are also swapped accordingly:
Painting# #1 #2 #3 #4 #5 #6 #7 #8 #9 #10
Art Critic: 1
2 3 4 5 6 7 8 9 10
Art Student: 2 3 6 5 1 9
4 7 10 8
Step 2:
For every rating of the art student, compute the concordance and the
discordance scores. A concordance score for a rating, X is the number of rating
values that occur after X that are greater than X. A discordance score for a
rating, X is the number of rating values that occur after X that are less than
X. Also, compute the sum of the
concordance and discordance scores.
Example:
Painting# #1 #2 #3 #4 #5 #6 #7 #8 #9 #10
Art Critic: 1
2 3 4 5 6 7 8 9 10
Art Student: 2 3 6 5 1 9
4 7 10 8
Concordance: 8 7 4 4 5 1 3 2 0
Discordance: 1 1 3 2 0 3 0 0 1
Sum of
Concordance = 34
Sum of
Discordance = 11
Step 3:
Compute the Kendall correlation coefficient, τ using the formula below:
·
τ = ((Sum
of Concordance) – (Sum of Discordance)) / ((Sum
of Concordance) + (Sum of Discordance)) =
= (34-11)/ (34+11) = 23/45 = 0.511