I am trying to calculate Kendall’s tau coefficient for example given by Scipy in python. It is for tied ranks with tau-b version. The tau should be -0.47140452079103173 but I get a different result. I use formulas in "Handbook of Parametric and Nonparametric. Statistical Procedures. David J. Sheskin. Chapman & Hall/CRC." page 900.
$$x = [12, 2, 1, 12, 2]$$ $$y = [1, 4, 7, 1, 0]$$
rank the data: $$rank x = [4.5, 2.5, 1, 4.5, 2.5]$$ $$rank y = [2.5, 4, 5, 2.5, 1]$$
dimensions: $n=5, m=2 $ $$rank x+rank y = [7, 6.5, 6, 7, 3.5]$$ $$T=7+6.5+6+7+3.5=30$$ $$U=7^2+6.5^2+6^2+7^2+3.5^2=188.5$$
calculate the tie correlation(${\displaystyle\sum_{i=1}^m}{\displaystyle\sum_{a=1}^s}(t^3-t)$):
in x there are 2 tied groups each with 2 members: $(2^3-2)+(2^3-2)=12$
in y there is 1 tied group with 2 members: $(2^3-2)= 6$
total tie correlations: $12+6=18$
$$W=\frac{12U-3m^2n(n+1)^2}{m^2n(n^2-1)-m{\displaystyle\sum_{i=1}^m}{\displaystyle\sum_{a=1}^s}(t^3-t)}=\frac{12(188.5)-3\times 2^2\times 5(5+1)^2}{2^2\times5(5^2-1)-2(18)}=0.22973$$
Sorry for the low-quality question. there are not many numeric questions for tau-b. I hope this question can be helpful also for others who review python's example.