在Faraklas 等人的一篇论文中,研究人员创建了一个坏死性软组织感染死亡率风险计算器。他们使用逻辑回归创建一个以坏死性软组织感染死亡率为主要结果的模型,然后计算曲线下面积 (AUC)。他们使用 bootstrap 方法找到“bootstrap optimism-corrected ROC area”。
如果我要这样做R,它会是什么样子?我一直在玩弄的代码如下所示:
library(boot)
library(ROCR)
auc_calc <- function(data, indices, outcomes) {
d <- data[indices,]
# Using glm for logistic regression
# Do I recreate the glm model for each dataset?
fit <- glm(outcomes[indices,] ~ X1 + X2 + X3, data=d, family=binomial)
fit.predict <- predict(fit, type="response")
# Using ROCR to calculate AUC
pred <- prediction(fit.predict, outcomes[indices,])
perf <- performance(pred, "auc")
# Returning the AUC
return(perf@y.values[[1]])
}
boot.results <- boot(data=my.data, statistic=auc_calc, R=10000, outcomes=my.outcomes)
这个对吗?还是我做错了什么 - 即我应该传入一个 glm 模型而不是每次都重新计算它?一如既往地感谢您的帮助。