Bootstrap ROC curve

Share:

Description

boot.roc calculates the ROC curve, initializes the settings and calculates the bootstrap results for the true and false positive rate at every relevant threshold. Missing values are removed with a warning prior to bootstrapping.

Usage

1
2
boot.roc(pred, true.class, stratify = TRUE, n.boot = 1000,
  use.cache = FALSE, tie.strategy = NULL)

Arguments

pred

A numeric vector. Contains predictions. boot.roc assumes that a high prediction is evidence for the observation belonging to the positive class.

true.class

A logical vector. TRUE indicates the sample belonging to the positive class.

stratify

Logical. Indicates whether we use stratified bootstrap. Default to TRUE. Non-stratified bootstrap is not yet implemented.

n.boot

A number that will be coerced to integer. Specified the number of bootstrap replicates. Defaults to 1000.

use.cache

If true the bootstrapping results for the ROC curve will be pre-cached. This increases speed when the object is used often, but also takes up more memory.

tie.strategy

How to handle ties. See details below.

Value

A list of class fbroc.roc, containing the elements:

prediction

Input predictions.

true.class

Input classes.

roc

A data.frame containing the thresholds of the ROC curve and the TPR and FPR at these thresholds.

n.thresholds

Number of thresholds.

n.boot

Number of bootstrap replicates.

use.cache

Indicates if cache is used for this ROC object

tie.strategy

Used setting how to handle ties in predictors.

n.pos

Number of positive observations.

n.neg

Number of negative observations.

auc

The AUC of the original ROC curve.

boot.tpr

If the cache is enabled, a matrix containing the bootstrapped TPR at the thresholds.

boot.fpr

If the cache is enabled, a matrix containing the bootstrapped FPR at the thresholds.

Caching

If you enable caching, boot.roc calculates the requested number of bootstrap samples and saves the TPR and FPR values for each iteration. This can take up a sizable portion of memory, but it speeds up subsequent operations. This can be useful if you plan to use the ROC curve multiple fbroc functions.

Ties

You can set this parameter to either 1 or 2. If your numerical predictor has no ties, both settings will produce the same results. If you set tie.strategy to 1 the ROC curve is built by connecting the TPR/FPR pairs for neighboring thresholds. A tie.strategy of 2 indicates that the TPR calculated at a specific FPR is the best TPR at a FPR smaller than or equal than the FPR specified. Defaults to 2.

See Also

http://www.epeter-stats.de/roc-curves-and-ties/, plot.fbroc.roc, print.fbroc.roc

Examples

1
2
3
y <- rep(c(TRUE, FALSE), each = 500)
x <- rnorm(1000) + y
result.boot <- boot.roc(x, y)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.