順序尺度 × 順序尺度(ランキング)に対して使われる相関指標で、順位の一致/不一致ペア数に基づいて計算される
kendalltau — SciPy v1.15.2 Manual
:一致順(concordant)のペアの数
:不一致順(discordant)のペアの数
すべてのペアの総数
:Xで順位が同じぺアの数の補正(ties in X)
:Yで順位が同じぺアの数の補正(ties in Y)
x = [1, 1, 2, 2, 3, 3]
y = [0, 0, 0, 1, 1, 1]
from scipy.stats import kendalltau
print(f"{kendalltau(x, y).statistic=:.3f}")
from ordinalcorr import polychoric
print(f"{polychoric(x, y)=:.3f}")kendalltau(x, y).statistic=0.770
polychoric(x, y)=0.999