plot.rocit: Plot ROC Curve

Description Usage Arguments Value Note Examples

View source: R/plotROC.R

Description

This function generates receiver operating characteristic (ROC) curve. This is an S3 method for object of class "rocit", returned by rocit function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## S3 method for class 'rocit'
plot(
  x,
  col = c("#2F4F4F", "#BEBEBE"),
  legend = TRUE,
  legendpos = "bottomright",
  YIndex = TRUE,
  values = TRUE,
  ... = NULL
)

Arguments

x

An object of class "rocit", returned by rocit function.

col

Colors to be used in the plot. If multiple specified, the first color is used for the ROC curve, and the second color is used for the chance line (y = x line), otherwise single color is used.

legend

A logical value indicating whether legends to appear in the plot.

legendpos

Position of the legend. A single keyword from "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right" and "center", as in legend. Ignored if legend is FALSE.

YIndex

A logical value indicating whether optimal Youden Index (i.e where |TPR - FPR| is maximum) to be marked in the plot.

values

A logical value, indicating whether values to be returned.

...

NULL. Used for S3 generic/method consistency.

Value

If values = TRUE, then AUC, Cutoff, TPR, FPR, optimal Youden Index with associated TPR, FPR, Cutoff are returned silently.

Note

Customized plots can be made by using the returned values of the function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data("Loan")
score <- Loan$Score
class <- ifelse(Loan$Status == "FP", 0, 1)
rocit_emp <- rocit(score = score, class = class)
# -----------------------
plot(rocit_emp)
plot(rocit_emp, col = c(2,4), legendpos = "bottom",
     YIndex = FALSE, values = FALSE)
# -----------------------
rocit_bin <- rocit(score = score, class = class, method = "bin")
# -----------------------
plot(rocit_emp, col = c(1,"gray50"), legend = FALSE, YIndex = FALSE)
lines(rocit_bin$TPR~rocit_bin$FPR, col = 2, lwd = 2)
legend("bottomright", col = c(1,2),
       c("Empirical ROC", "Binormal ROC"), lwd = 2)

ROCit documentation built on July 1, 2020, 11:28 p.m.