# Kendall’s Rank Correlation in R-Correlation Test

Kendall’s Rank Correlation in R, Kendall’s rank correlation coefficient is suitable for the paired ranks as in the case of Spearman’s rank correlation.

The condition is that both the variables X and Y be measured on at least an ordinal scale. The main application of Kendall rank correlation is to test the similarities in the ordering of data when it is ranked by quantities.

One advantage of Kendall Tau over Spearman’s rank correlation is that tau can be generalized to a partial correlation coefficient which is not possible in the case of rs.

What are the differences between Association and Correlation? »

## Procedure

The procedure of Kendall τ consists of the following steps.

Step1:- Arrange the rank of the first set (X) in ascending order and rearrange the ranks of the second set (Y) in such a way that n pairs of rank remain the same.

Step2:-The ranks of X are in the natural order. Now we are left to how many pairs of ranks in the set Y are in a natural order and how many are not.

Significance of Spearman’s Rank Correlation »

A number is said to be in natural order if it is smaller than the succeeding number and is coded as +1. And also if it is greater than its succeeding number then it will not be taken as a natural order and will be coded as -1.

Step3:-Find the sum of all coded values.

Step4:- The formula for Kendall tau is

τ=2S/n(n-1)

## Properties

Kendall’s tau range between -1 to 1.

If n is large Kendall’s τ equal to the 2/3 rd of Spearman’s rank correlation.

Correlation Analysis Different Types of Plots in R »

If τ=1 indicates the ranking of X is in the same order as the ranking of Y.

If τ=-1 indicates the ranking of X is in reverse order of the ranking of Y.

## Kendall’s Rank Correlation in R

Let’s see how to execute Kendall’s τ in R.

```x<-c(1,2,3,2,1,3,4,2,5,2,6,5,5)
y<-c(5,5,6,2,1,4,4,2,1,2,1,5,5)
res<-cor.test(x,y, method="kendall")
res```

Kendall’s rank correlation tau

```data:  x and y
z = 0.12931, p-value = 0.8971
alternative hypothesis: true tau is not equal to 0
sample estimates:
tau
0.03030651```

## Conclusion

The correlation coefficient between x and y is 0.03030651and the p-value is 0.8971.