Reputation: 1441
I'm trying to adapt a formula that calculates the coefficient of concordance for vague data. The paper that describes it is here https://www.researchgate.net/publication/4738093_The_coefficient_of_concordance_for_vague_data
The specific equation I'm interested in is (22)
There are four observers (i.e.k=4) and eight objects (i.e.n=8). The answer should be 0.7485
I can work out the equation in R for the standard equation of Kendall's W but not this one. I think I'm just messing up the order of operations.
In R I think input values should be:
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)
You can see these values at the bottom of page 320 and top of page 321
Hope you can help
Upvotes: 1
Views: 134
Reputation: 1441
I've built the function for the formula in R as follows:
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)
}
The second function will calculate the p-value for this (I hope):
## 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)
}
Upvotes: 0
Reputation: 29724
Your vectors are correct and values of k = 4 and n = 8 are correct as well. This means there is an error in Kendall's coefficient of concordance computation. It is impossible to help you further without the code being shown other than here I put the spreadsheet kendall_concordance.ods that performs this computation so hopefully it'll do the job for you. I got 0.7485 result as expected.
What you should do is:
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))
Upvotes: 2