Kendall の は観測値の全ペアの数に対する順序が一致(concordant)/ 不一致(discordant)のペアの数の比率のように定義される相関係数
定義式¶
:一致ペア数
:不一致ペア数
:全ペア数
順位が完全に一致している(すなわち)なら
順位が完全に不一致(すなわち)なら
特徴¶
単調関係を捉える
ノイズが強い場合に Spearman より安定する場合がある
値域は
Source
from scipy.stats import kendalltau
import matplotlib.pyplot as plt
import numpy as np
fig, axes = plt.subplots(figsize=[10, 2.5], ncols=3)
true_r = 0.75
mu = np.array([0.0, 0.0])
Sigma = np.array([[1.0, true_r], [true_r, 1.0]])
samples = np.random.multivariate_normal(mu, Sigma, size=100)
x = samples[:, 0]
y = samples[:, 1]
axes[0].scatter(x, y)
axes[0].set_title(f"Kendall's τ = {kendalltau(x, y).statistic:.3f}")
x = np.linspace(-10, 10, 15)
y = 1 / (1 + np.exp(-x))
axes[1].scatter(x, y)
axes[1].set_title(f"Kendall's τ = {kendalltau(x, y).statistic:.3f}")
x = np.linspace(-3.14,3.14, 100)
y = x**2 + np.random.random(len(x))
axes[2].scatter(x, y)
axes[2].set_title(f"Kendall's τ = {kendalltau(x, y).statistic:.3f}")
%matplotlib inline