Kendall Rank Correlation Coefficient

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Kendall rank correlation coecient

Tau coecient redirects here. It is not to be confused If the agreement between the two rankings is perfect
with Tau distribution. (i.e., the two rankings are the same) the coecient
has value 1.
In statistics, the Kendall rank correlation coecient, If the disagreement between the two rankings is per-
commonly referred to as Kendalls tau coecient (af- fect (i.e., one ranking is the reverse of the other) the
ter the Greek letter ), is a statistic used to measure the coecient has value 1.
ordinal association between two measured quantities. A
tau test is a non-parametric hypothesis test for statistical If X and Y are independent, then we would expect
dependence based on the tau coecient. the coecient to be approximately zero.
It is a measure of rank correlation: the similarity of the
orderings of the data when ranked by each of the quanti-
ties. It is named after Maurice Kendall, who developed it
2 Hypothesis test
[1]
in 1938, though Gustav Fechner had proposed a similar
measure in the context of time series in 1897.[2] The Kendall rank coecient is often used as a test statis-
tic in a statistical hypothesis test to establish whether two
Intuitively, the Kendall correlation between two variables variables may be regarded as statistically dependent. This
will be high when observations have a similar (or identi- test is non-parametric, as it does not rely on any assump-
cal for a correlation of 1) rank (i.e. relative position la- tions on the distributions of X or Y or the distribution of
bel of the observations within the variable: 1st, 2nd, 3rd, (X,Y).
etc.) between the two variables, and low when observa-
tions have a dissimilar (or fully dierent for a correlation Under the null hypothesis of independence of X and Y, the
of 1) rank between the two variables. sampling distribution of has an expected value of zero.
The precise distribution cannot be characterized in terms
Both Kendalls and Spearmans can be formulated as of common distributions, but may be calculated exactly
special cases of a more general correlation coecient. for small samples; for larger samples, it is common to use
an approximation to the normal distribution, with mean
zero and variance
1 Denition
2(2n+5) [4]
9n(n1) .
Let (x1 , y1 ), (x2 , y2 ), , (xn, yn) be a set of observations
of the joint random variables X and Y respectively, such
that all the values of ( xi ) and ( yi ) are unique. Any 3 Accounting for ties
pair of observations (xi , yi ) and (xj , yj ) , where i = j ,
are said to be concordant if the ranks for both elements
A pair {(xi , yi ), (xj , yj )} is said to be tied if xi = xj or
agree: that is, if both xi > xj and yi > yj ; or if both
yi = yj ; a tied pair is neither concordant nor discordant.
xi < xj and yi < yj . They are said to be discordant, if
When tied pairs arise in the data, the coecient may be
xi > xj and yi < yj ; or if xi < xj and yi > yj . If
modied in a number of ways to keep it in the range [1,
xi = xj or yi = yj , the pair is neither concordant nor
1]:
discordant.
The Kendall coecient is dened as:
3.1 Tau-a
(pairs concordant of number)(pairs discordant of number)
= n(n1)/2 .
[3] The Tau-a statistic tests the strength of association of the
cross tabulations. Both variables have to be ordinal. Tau-
a will not make any adjustment for ties. It is dened as:
1.1 Properties
nc nd
The denominator is the total number of pair combina- A =
n0
tions, so the coecient must be in the range 1
1. where nc, nd and n0 are dened as in the next section.

1
2 5 ALGORITHMS

3.2 Tau-b same distribution as the B distribution, and is again ap-


proximately equal to a standard normal distribution when
The Tau-b statistic, unlike Tau-a, makes adjustments for the quantities are statistically independent:
ties.[5] Values of Tau-b range from 1 (100% negative
association, or perfect inversion) to +1 (100% positive
association, or perfect agreement). A value of zero indi- nc nd
zB =
cates the absence of association. v
The Kendall Tau-b coecient is dened as: where

nc nd
B = v = (v0 vt vu )/18 + v1 + v2
(n0 n1 )(n0 n2 ) v0 = 1)(2n + 5)
n(n
where
vt = i ti (ti 1)(2ti + 5)
vu = u (u 1)(2uj + 5)
j j j
v1 = t (t 1) j uj (uj 1)/(2n(n 1))
i i i
n0 = n(n 1)/2
v2 = i ti (ti 1)(ti 2) j uj (uj 1)(uj 2)/(9n(n 1)(n

n1 = ti (ti 1)/2 pvrank[6] is a very recent R package that computes rank
i correlations and their p-values with various options for

n2 = uj (uj 1)/2 tied ranks. It is possible to compute exact Kendall coef-
j cient test p-values for n 60.
nc = pairs concordant of Number
nd = pairs discordant of Number
5 Algorithms
ti = the in values tied of Numberith quantity rst the for ties of group
uj = the in values tied of Numberj th quantity second the for
Theties of group
direct computation of the numerator nc nd , in-
volves two nested iterations, as characterized by the fol-
lowing pseudo-code:
3.3 Tau-c
numer := 0 for i:=2..N do for j:=1..(i-1) do numer :=
Tau-c (also called Stuart-Kendall Tau-c) diers from numer + sign(x[i] - x[j]) * sign(y[i] - y[j]) return numer
Tau-b as in being more suitable for rectangular tables than Although quick to implement, this algorithm is O(n2 ) in
for square tables. complexity and becomes very slow on large samples. A
more sophisticated algorithm[7] built upon the Merge Sort
algorithm can be used to compute the numerator in O(n
4 Signicance tests log n) time.
Begin by ordering your data points sorting by the rst
When two quantities are statistically independent, the quantity, x , and secondarily (among ties in x ) by the sec-
distribution of is not easily characterizable in terms ond quantity, y . With this initial ordering, y is not sorted,
of known distributions. However, for A the following and the core of the algorithm consists of computing how
statistic, zA , is approximately distributed as a standard many steps a Bubble Sort would take to sort this initial y
normal when the variables are statistically independent: . An enhanced Merge Sort algorithm, with O(n log n)
complexity, can be applied to compute the number of
swaps, S(y) , that would be required by a Bubble Sort
3(nc nd ) to sort yi . Then the numerator for is computed as:
zA =
n(n 1)(2n + 5)/2

Thus, to test whether two variables are statistically depen- nc nd = n0 n1 n2 + n3 2S(y),


dent, one computes zA , and nds the cumulative prob-
ability for a standard normal distribution at |zA | . For where n3 is computed like n1 and n2 , but with respect
a 2-tailed test, multiply that number by two to obtain the to the joint ties in x and y .
p-value. If the p-value is below a given signicance level,
A Merge Sort partitions the data to be sorted, y into two
one rejects the null hypothesis (at that signicance level)
roughly equal halves, yleft and yright , then sorts each half
that the quantities are statistically independent. recursive, and then merges the two sorted halves into a
Numerous adjustments should be added to zA when ac- fully sorted vector. The number of Bubble Sort swaps is
counting for ties. The following statistic, zB , has the equal to:
3

8 Further reading
S(y) = S(yleft ) + S(yright ) + M (Yleft , Yright ) Abdi, H. (2007). Kendall rank correlation (PDF).
In Salkind, N.J. Encyclopedia of Measurement and
where Yleft and Yright are the sorted versions of yleft and
Statistics. Thousand Oaks (CA): Sage.
yright , and M (, ) characterizes the Bubble Sort swap-
equivalent for a merge operation. M (, ) is computed as Daniel, Wayne W. (1990). Kendalls tau. Applied
depicted in the following pseudo-code: Nonparametric Statistics (2nd ed.). Boston: PWS-
function M(L[1..n], R[1..m]) i := 1 j := 1 nSwaps := 0 Kent. pp. 365377. ISBN 0-534-91976-6.
while i <= n and j <= m do if R[j] < L[i] then nSwaps := Kendall, M. (1948) Rank Correlation Methods,
nSwaps + n - i + 1 j := j + 1 else i := i + 1 return nSwaps Charles Grin & Company Limited
A side eect of the above steps is that you end up with
both a sorted version of x and a sorted version of y . With Bonett, DG & Wright, TA (2000) Sample size re-
these, the factors ti and uj used to compute B are easily quirements for Pearson, Kendall, and Spearman cor-
obtained in a single linear-time pass through the sorted relations, Psychometrika, 65, 2328.
arrays.

9 External links
6 See also
Tied rank calculation
Correlation Software for computing Kendalls tau on very large
datasets
Kendall tau distance
Online software: computes Kendalls tau rank cor-
Kendalls W
relation
Spearmans rank correlation coecient
The CORR Procedure: Statistical Computations
Goodman and Kruskals gamma McDonough School of Business

TheilSen estimator

7 References
[1] Kendall, M. (1938). A New Measure of Rank
Correlation. Biometrika. 30 (12): 8189.
doi:10.1093/biomet/30.1-2.81. JSTOR 2332226.

[2] Kruskal, W.H. (1958). Ordinal Measures of Associ-


ation. Journal of the American Statistical Association.
53 (284): 814861. doi:10.2307/2281954. JSTOR
2281954. MR 100941.

[3] Nelsen, R.B. (2001), Kendall tau metric, in Hazewinkel,


Michiel, Encyclopedia of Mathematics, Springer, ISBN
978-1-55608-010-4

[4] Prokhorov, A.V. (2001), Kendall coecient of rank cor-


relation, in Hazewinkel, Michiel, Encyclopedia of Math-
ematics, Springer, ISBN 978-1-55608-010-4

[5] Agresti, A. (2010). Analysis of Ordinal Categorical Data


(Second ed.). New York: John Wiley & Sons.

[6] Amerise, I.L.; Marozzi, M.; Tarsitano, A. R package


pvrank.

[7] Knight, W. (1966). A Computer Method for Calcu-


lating Kendalls Tau with Ungrouped Data. Journal of
the American Statistical Association. 61 (314): 436439.
doi:10.2307/2282833. JSTOR 2282833.
4 10 TEXT AND IMAGE SOURCES, CONTRIBUTORS, AND LICENSES

10 Text and image sources, contributors, and licenses


10.1 Text
Kendall rank correlation coecient Source: https://en.wikipedia.org/wiki/Kendall_rank_correlation_coefficient?oldid=761817212
Contributors: Michael Hardy, Piotrus, Rich Farmbrough, Bender235, Pt, O18, Arcadian, NickSchweitzer, 3mta3, Stevelihn, Aaron McDaid,
Intgr, RussBot, Schmock, Maechler, Fmccown, Icedwater, Arthur Rubin, SmackBot, Jtneill, Mcld, G716, NickPenguin, Cronholm144,
Vigna, Cydebot, Barticus88, Headbomb, Nick Number, Dryke, Ldc, Olaf, Ph.eyes, Magioladitis, David Eppstein, As530, Edurant, Pen-
pen~enwiki, JamesHAndrews, TXiKiBoT, Seb144, Melcombe, Digisus, Squeakywae, Qwfp, Sasikedi, Addbot, Fgnievinski, Nasa-verve,
SassoBot, Monty669, Dger, Ichbin-dcw, Citation bot 1, MastiBot, WikitanvirBot, Yikes2000, Dcirovic, Thecheesykid, Jacwa01, Win-
erFresh, TimBock, Marcocapelle, Chafe66, Piguy101, Adilapapaya, Jerry Hintze, 7804j, GVpep, Vermelhomaraj, I am grungy, Hel-
pUsStopSpam, Ike982003 and Anonymous: 54

10.2 Images
File:Commons-logo.svg Source: https://upload.wikimedia.org/wikipedia/en/4/4a/Commons-logo.svg License: PD Contributors: ? Origi-
nal artist: ?
File:Fisher_iris_versicolor_sepalwidth.svg Source: https://upload.wikimedia.org/wikipedia/commons/4/40/Fisher_iris_versicolor_
sepalwidth.svg License: CC BY-SA 3.0 Contributors: en:Image:Fisher iris versicolor sepalwidth.png Original artist: en:User:Qwfp (origi-
nal); Pbroks13 (talk) (redraw)
File:Folder_Hexagonal_Icon.svg Source: https://upload.wikimedia.org/wikipedia/en/4/48/Folder_Hexagonal_Icon.svg License: Cc-by-
sa-3.0 Contributors: ? Original artist: ?
File:People_icon.svg Source: https://upload.wikimedia.org/wikipedia/commons/3/37/People_icon.svg License: CC0 Contributors: Open-
Clipart Original artist: OpenClipart
File:Portal-puzzle.svg Source: https://upload.wikimedia.org/wikipedia/en/f/fd/Portal-puzzle.svg License: Public domain Contributors: ?
Original artist: ?
File:Question_book-new.svg Source: https://upload.wikimedia.org/wikipedia/en/9/99/Question_book-new.svg License: Cc-by-sa-3.0
Contributors:
Created from scratch in Adobe Illustrator. Based on Image:Question book.png created by User:Equazcion Original artist:
Tkgd2007

10.3 Content license


Creative Commons Attribution-Share Alike 3.0

You might also like