Learn R Programming

BuyseTest (version 2.1.3)

auc: Estimation of the Area Under the ROC Curve

Description

Estimation of the Area Under the ROC curve, possibly after cross validation, to assess the discriminant ability of a biomarker regarding a disease status.

Usage

auc(
  labels,
  predictions,
  fold = NULL,
  observation = NULL,
  direction = ">",
  null = 0.5,
  conf.level = 0.95,
  transformation = FALSE
)

Arguments

labels

[integer/character vector] the disease status (should only take two different values).

predictions

[numeric vector] A vector with the same length as labels containing the biomarker values.

fold

[character/integer vector] If using cross validation, the index of the fold. Should have the same length as labels.

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] ">" lead to estimate P[Y>X], "<" to estimate P[Y<X], and "auto" to estimate max(P[Y>X],P[Y<X]).

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.

Value

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.

Details

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]).

References

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<U+2013>1607.

Examples

Run this code
# NOT RUN {
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))

# }

Run the code above in your browser using DataLab