1
$\begingroup$

I try to calculate the Kendall tau-b rank correlation for a huge number of paired sets. Some of those sets contain only ties, e.g.,

x1 = [1,1,1,1,1,1]

which is compared to another set

x2 = [1,1,1,1,2,2]

Python's Kendall tau-b module

import scipy.stats as stats
stats.kendalltau(x1, x2)

results in

KendalltauResult(correlation=nan, pvalue=nan)

I guess this is because one of the factors in the denominator is zero. Is there any solution to get an approximate tau-b coefficient for such situations. Does anybody know what the limit would be? Or which value one usually would assign in such situations?

$\endgroup$
  • $\begingroup$ Try tau-c maybe. $\endgroup$ – Carl May 12 '18 at 4:47
1
$\begingroup$

Your x1 variable exhibits no variation in its values (in other words, all of its values are the same), which is why you are not able to get an answer.

As explained at https://statistics.laerd.com/spss-tutorials/kendalls-tau-b-using-spss-statistics.php:

"Kendall's tau-b determines whether there is a monotonic relationship between your two variables. As such, it is desirable if your data would appear to follow a monotonic relationship, so that formally testing for such an association makes sense, but it is not a strict assumption or one that you are often able to assess."

If you plot your x2 versus x1, you will notice that all of the observations are stacked on top of each other, rather than following a monotonic relationship.

I am afraid that there is not much you can do in this case, other than to report that your data did not satisfy the assumptions required for the computation of Kendall's tau b, hence you weren't able to compute this quantity.

From a programming perspective, you can compute the standard deviatio of x1 and the standard deviation of x2. If either standard deviation is 0, then perhaps don't proceed with the computation of Kendall's tau b.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.