我正在尝试调整计算模糊数据的一致性系数的公式。描述它的论文在https://www.researchgate.net/publication/4738093_The_coefficient_of_concordance_for_vague_data
我感兴趣的具体方程是(22)
有四个观察者(即k = 4)和八个物体(即n = 8)。答案应该是0.7485
我可以用R中的公式来计算肯德尔W的标准方程,但不是这个。我想我只是搞乱了操作的顺序。
在R中,我认为输入值应为:
u <- c(6/7, 4/7, 1, 1/7, 2/7, 3/7, 5/7, 0,
5/7, 4/7, 6/7, 1/7, 2/7, 3/7, 0, 0,
1, 5/7, 2/7, 0, 2/7, 4/7, 6/7, 1/7,
5/7, 3/7, 4/7, 0, 2/7, 0, 6/7, 1/7)
v<-c(1/7, 3/7, 0, 6/7, 5/7, 4/7, 2/7, 1,
1/7, 2/7, 0, 5/7, 4/7, 3/7, 0, 6/7,
0, 2/7, 4/7, 1, 4/7, 3/7, 1/7, 6/7,
1/7, 3/7, 2/7, 6/7, 4/7, 0, 0, 5/7)
您可以在第320页底部和第321页顶部看到这些值
希望你能帮忙
答案 0 :(得分:2)
您的矢量是正确的,k = 4和n = 8的值也是正确的。这意味着肯德尔的一致性计算系数存在误差。如果没有显示除here之外的代码,我就无法帮助你。我把执行此计算的电子表格kendall_concordance.ods放进去,所以希望它能为你完成这项工作。我按预期得到了0.7485的结果。
你应该做的是:
1. Build u, v vectors (you have done this)
2. Calculate averages of each column in u and v (2n averages).
3. Subtract 0.5 from all averages and square them (for all av in u:
av = (av - 1/2)^2, same for v) so they are now distances from
ideal concordance for each column
4. Sum all 16 distances and multiply by 6(n-1)/(n(n+1))
答案 1 :(得分:0)
我在R中为公式构建了函数,如下所示:
vagueKendall<-function(u,v,n){
u<-matrix (u, ncol=n, byrow = TRUE)
v<-matrix (v, ncol=n, byrow = TRUE)
## divide by n-1
uColNo<-u/(n-1)
vColNo<-v/(n-1)
## take the averages
colMeansU<-colMeans(uColNo)
colMeansV<-colMeans(vColNo)
## measure the distances from the averages
au = (colMeansU - 1/2)^2
av = (colMeansV - 1/2)^2
## calculate component before sum
outside<-6*(n-1)/(n*(n+1))
## sum of squared distances from averages
sumSqdDiff<-sum(au+av)
## The product of these gives the modified Kendall's W
W<-outside*sum(au+av)
return(W)
}
第二个函数将计算此值的p值(我希望):
## Extract p-value function
vagueKendallP<-function(W,k,n){
## Calculate correlation coefficient
r<-(k*W-1)/(k-1)
## Calculate Chi Squared
Chi<-k*(n-1)*W
## degrees of freedom
df<-n-1
## p-value
pValue<-pchisq(Chi,df, lower.tail = FALSE)
return(pValue)
}