Learn R Programming

fbroc (version 0.2.0)

boot.roc: Bootstrap ROC curve

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

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:
  • predictionInput predictions.
  • true.classInput classes.
  • rocA data.frame containing the thresholds of the ROC curve and the TPR and FPR at these thresholds.
  • n.thresholdsNumber of thresholds.
  • n.bootNumber of bootstrap replicates.
  • use.cacheIndicates if cache is used for this ROC object
  • n.posNumber of positive observations.
  • n.negNumber of negative observations.
  • aucThe AUC of the original ROC curve.
  • boot.tprIf the cache is enabled, a matrix containing the bootstrapped TPR at the thresholds.
  • boot.fprIf 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

Run this code
y <- rep(c(TRUE, FALSE), each = 500)
x <- rnorm(1000) + y
result.boot <- boot.roc(x, y)

Run the code above in your browser using DataLab