热线电话:13121318867

登录
2019-03-08 阅读量: 1040
Kendall秩相关

Kendall秩相关以Maurice Kendall命名。它也被称为Kendall相关系数,通常用小写希腊字母tau(t)表示。所以,它也被称为Kendall’s tau。这种检验是计算两个样本之间匹配或一致排名的标准化分数。因此,也称为Kendall’s concordance test。在Python中,Kendall秩相关系数可以使用SciPy函数kendalltau()计算。它将两个数据样本作为参数,并返回相关系数和p值。作为统计假设检验,该方法假设(H0)两个样本之间没有关联。我们可以在测试数据集上演示计算结果,我们预计会报告强正相关。下面列出了完整的示例:

from numpy.random import rand

from numpy.random import seed

from scipy.stats import kendalltau

# seed random number generator

seed(1)

# prepare data

data1 = data['x']

data2 = data['price']

# calculate kendall's correlation

coef, p = kendalltau(data1, data2)

print('Kendall correlation coefficient: %.3f' % coef)

# interpret the significance

alpha = 0.05

if p > alpha:

print('Samples are uncorrelated (fail to reject H0) p=%.3f' % p)

else:

print('Samples are correlated (reject H0) p=%.3f' % p)

Kendall correlation coefficient: 0.831

Samples are correlated (reject H0) p=0.000

运行该示例,Kendall相关系数为 0.8,这是高度相关。与Spearman一样,p值接近零(打印为零),这意味着我们可以放心地驳回样本不相关的零假设。

30.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子