Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

ケンドールの順位相関係数(Kendall’s tau)

順序尺度 × 順序尺度(ランキング)に対して使われる相関指標で、順位の一致/不一致ペア数に基づいて計算される

kendalltau — SciPy v1.15.2 Manual

τ=ncnd(n0n1)(n0n2)\tau=\frac{n_c-n_d}{\sqrt{\left(n_0-n_1\right)\left(n_0-n_2\right)}}
  • ncn_c :一致順(concordant)のペアの数

  • ndn_d :不一致順(discordant)のペアの数

  • n0=n(n1)2:n_0=\frac{n(n-1)}{2}: すべてのペアの総数

  • n1=ti(ti1)/2n_1=\sum t_i\left(t_i-1\right) / 2 :Xで順位が同じぺアの数の補正(ties in X)

  • n2=uj(uj1)/2n_2=\sum u_j\left(u_j-1\right) / 2 :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