我对 R psych 包中加权 kappa 的行为感到有些困惑。我有五个类(1、2、3、4、5)和三个注释器的数据。似乎每当一个特定的类(比如 1)只被一个注释器使用(导致该类的一致性矩阵的对角线上的空值)时,心理抱怨:
library(psych);
df2 <- read.table('classes/WB/mcrae.quants.features.time.numeric', sep='\t');
cohen.weights <- matrix(c(0,5,35,95,100,5,0,30,90,95,35,5,0,60,65,95,90,60,0,5,100,95,65,5,0),ncol=5);
cohen.kappa(df2,cohen.weights)
Error in `rownames<-`(`*tmp*`, value = c("2", "3", "4", "5")) :
length of 'dimnames' [1] not equal to array extent
Calls: cohen.kappa -> cohen.kappa1 -> rownames<-
Execution halted
我的数据如下所示:
5 3 3
5 3 3
5 4 3
5 4 3
3 3 3
5 4 4
3 4 4
3 3 3
2 3 2
...
1 3 4
有人可以告诉我我做错了什么吗?当所有类都被至少两个注释器使用时,上面的代码才有效。谢谢!
dput(df2) 的输出:
structure(list(V1 = c(5L, 5L, 5L, 5L, 3L, 5L, 3L, 3L, 2L, 4L,
3L, 4L, 3L, 4L, 5L, 3L, 5L, 5L, 3L, 5L, 3L, 5L, 3L, 5L, 4L, 5L,
5L, 5L, 5L, 3L, 4L, 4L, 5L, 5L, 5L, 3L, 3L, 5L, 5L, 5L, 5L, 3L,
3L, 5L, 5L, 3L, 4L, 3L, 4L, 3L, 5L, 5L, 4L, 3L, 5L, 5L, 5L, 5L,
5L, 3L, 3L, 5L, 5L, 5L, 5L, 5L, 4L, 3L, 5L, 5L, 5L, 5L, 4L, 4L,
4L, 5L, 4L, 4L, 3L, 3L, 5L, 3L, 4L, 3L, 5L, 1L), V2 = c(3L, 3L,
4L, 4L, 3L, 4L, 4L, 3L, 3L, 4L, 4L, 4L, 3L, 3L, 3L, 3L, 4L, 4L,
3L, 5L, 4L, 4L, 5L, 5L, 3L, 3L, 3L, 4L, 4L, 3L, 4L, 3L, 3L, 4L,
4L, 3L, 4L, 5L, 4L, 4L, 3L, 4L, 3L, 3L, 4L, 3L, 4L, 3L, 4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