目标:如何计算 r 中 Light 的 kappa 的引导置信区间?
问题:虽然我已成功提取统计信息,但我尝试了以下代码,但不确定我哪里出错了......
以下是数据集的示例:
head(event_judge)
judge1 judge 2 judge3
0 1 1
0 0 0
1 1 1
这是我用来计算统计数据和 95% CI 的代码:
library(psy)
lkappa(event_judge) # Light's kappa for binary diagnosis
#to obtain a 95%confidence interval:
# ATTEMPT 1
library(boot)
lkappa.boot <- function(data,x) {lkappa(data[x,], type="weighted")}
res <- boot(event_judge[,1:3],lkappa.boot,1000)
#quantile(res$t,c(0.025,0.975)) # Bootstrapped confidence interval of Light's kappa
#boot.ci(res,type="bca") # adjusted bootstrap percentile (BCa) confidence interval (better)
在开始 res 的行之后,我收到以下错误: if ((sum(dim1[i] == dimi1) == 1) & (sum(dim2[j] == dimi2) == 中的错误:缺少值 where TRUE /FALSE 需要
# ATTEMPT 2
if (requireNamespace("psy")) {
## example comparable to that when called ?lkappa
data("event_judge", package = "psy")
set.seed(1)
confIntKappa(dat = event_judge, type = "not Cohen", weights = "absolute",
M = 200, conf.level = 0.95)