0

我在我的文章中分析了几种不同的 ROC 分析。因此,我正在调查我的样本量是否合适。我创建了一个数据框,其中包含用于 ROC 分析的所有可能样本大小的组合。

str(auc)
'data.frame':   93 obs. of  2 variables:
 $ cases   : int  10 11 12 13 14 15 16 17 18 19 ...
     $ controls: int  102 101 100 99 98 97 96 95 94 93 ...

我的目标是创建线图案例/对照(即 kappa)与最佳 AUC

因此,我想使用 power.roc.test 创建第三个变量来计算最佳 AUC

我跑到上面的问题,问题出在哪里?

auc$auc<-power.roc.test(sig.level=.05,power=.8,ncases=auc$cases,ncontrols=auc$controls)$auc
Error in value[[3L]](cond) : AUC could not be solved:
Error in uniroot(power.roc.test.optimize.auc.function, interval = c(0.5, : invalid function value in 'zeroin'
In addition: Warning messages:
1: In if (is.na(f.lower)) stop("f.lower = f(lower) is NA") :
  the condition has length > 1 and only the first element will be used
2: In if (is.na(f.upper)) stop("f.upper = f(upper) is NA") :
  the condition has length > 1 and only the first element will be used
3: In if (f.lower * f.upper > 0) stop("f() values at end points not of opposite sign") :
  the condition has length > 1 and only the first element will be used
4

1 回答 1

0

我相信您正在使用该pROC软件包。错误消息在这里并不是特别有用,但您基本上需要传递标量值,包括 toncasesncontrols.

power.roc.test(sig.level=.05,power=.8,ncases=10, ncontrols=102)

您可以将其包装在一些应用循环中:

auc$auc<- apply(auc, 1, function(line) {
   power.roc.test(sig.level=.05, power=.8, ncases=line[["cases"]], ncontrols=line[["controls"]])$auc
})

然后,您将能够随心所欲地绘制它:

plot(auc$cases / auc$controls, auc$auc, type = "l")

请注意,此处的 AUC 不是“最佳 AUC”,而是在给定样本量下,您可以在给定显着性水平上预期给定功效的 AUC,以测试 AUC 的显着性(H0:AUC = 0.5) . pROC请注意,无论如何您都无法执行此测试。

于 2014-03-01T18:35:43.913 回答