auc {BuyseTest} | R Documentation |
Estimation of the Area Under the ROC curve, possibly after cross validation, to assess the discriminant ability of a biomarker regarding a disease status.
auc( labels, predictions, fold = NULL, observation = NULL, direction = ">", null = 0.5, conf.level = 0.95, transformation = FALSE )
labels |
[integer/character vector] the disease status (should only take two different values). |
predictions |
[numeric vector] A vector with the same length as |
fold |
[character/integer vector] If using cross validation, the index of the fold.
Should have the same length as |
observation |
[integer vector] If using cross validation, the index of the corresponding observation in the original dataset. Necessary to compute the standard error when using cross validation. |
direction |
[character] |
null |
[numeric, 0-1] the value against which the AUC should be compared when computing the p-value. |
conf.level |
[numeric, 0-1] the confidence level of the confidence intervals. |
transformation |
[logical] should a log-log transformation be used when computing the confidence intervals and the p-value. |
Compared to other functions computing the AUC (e.g. the auc fonction of the ROCR package), the AUC is defined here as P[Y>X] with a strict inequality sign (i.e. not P[Y>=X]).
A data.frame containing for each fold the AUC value with its standard error (when computed). The last line of the data.frame contains the global AUC value with its standard error.
Erin LeDell, Maya Petersen, and Mark van der Laan (2015). Computationally efficient confidence intervals for cross-validated area under the ROC curve estimates. Electron J Stat. 9(1):1583–1607.
library(data.table) n <- 200 set.seed(10) X <- rnorm(n) dt <- data.table(Y = as.factor(rbinom(n, size = 1, prob = 1/(1+exp(1/2-X)))), X = X, fold = unlist(lapply(1:10,function(iL){rep(iL,n/10)}))) ## compute auc auc(labels = dt$Y, predictions = dt$X, direction = ">") ## compute auc after 10-fold cross-validation auc(labels = dt$Y, prediction = dt$X, fold = dt$fold, observation = 1:NROW(dt))