肯德尔系数计算P>0.05该如何解决?
在别的网站上查询说有一个计算办法可以代替肯德尔, percent agreement,问题是这个该如何进行运用??
这个公式就是求一致评估在所有评估中所占的比例。P>0.05就是一致评估比例大于5%。
def kendall(x, y):
assert len(x) == len(y) > 0
c = 0 #concordant count
d = 0 #discordant count
t = 0 #tied count
for (i, j) in combinations(range(len(x)), 2):
s = (x[i] - x[j]) * (y[i] - y[j])
if s:
c += 1
d += 1
if s > 0:
t += 1
elif s < 0:
t -= 1
else:
if x[i] - x[j]:
c += 1
elif y[i] - y[j]:
d += 1
return t / math.sqrt(c * d)
GSM = [6,9,3,12,8,7,10,11,2,5,4,1]
LGC = [6,9,3,12,7,8,11,10,2,4,5,1]
kendall_test = kendall(GSM, LGC)