roc_curves: Receiver Operating Characteristic (ROC) Curves

Description Usage Arguments Details Value Author(s) Examples

Description

Functions to calculate and plot Receiver Operating Characteristic (ROC) curves for one or more sets of predictions, and for one or more objects of class mixmod or mdmixmod.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Default S3 method:
rocinfo(x, labels, quasi=FALSE, ...)
## S3 method for class 'mixmod'
rocinfo(x, labels, quasi=FALSE, ...)
## S3 method for class 'rocinfo'
plot(x, legend="x", cex.legend=1, auc=TRUE, dca=TRUE,
    col=1, lty=1, lwd=1, ylab="true positive rate",
    xlab=ifelse(x$quasi, "all positive rate", "false positive rate"),
    grid=FALSE, gridres=0.1, gridcol="lightgray", gridlty="dashed", ...)
## Default S3 method:
rocauc(x, labels, quasi=FALSE, ...)
## S3 method for class 'mixmod'
rocauc(x, labels, quasi=FALSE, ...)

multiroc(x, labels, quasi=FALSE)
## S3 method for class 'multiroc'
plot(x, legend=names(x), cex.legend=1, auc=TRUE, dca=FALSE, bw=FALSE,
    col=(if(bw) rep(1, length(x)) else 1:length(x)),
    lty=(if(bw) 1:length(x) else rep(1, length(x))),
    lwd=rep(1, length(x)), ylab="true positive rate",
    xlab=ifelse(x[[1]]$quasi, "all positive rate", "false positive rate"),
    grid=FALSE, gridres=0.1, gridcol="lightgray", gridlty="dashed", ...)

Arguments

x

for rocinfo and rocauc, a vector of probabilities, or an object of class mixmod or mdmixmod; for multiroc, a list of objects suitable to be passed as arguments to rocinfo; for plotting methods, an object of the appropriate class.

labels

a vector of logical values of the same length as the probabilities, in which a value of TRUE indicates a true positive; for multiroc, optionally a list of such vectors of the same length, with the same element names, as x.

quasi

logical; if TRUE, the x-axis of the ROC curve denotes the total positive rate rather than the false positive rate.

legend

character or FALSE; if character, a legend will be drawn with the name(s) in legend; if FALSE, no legend will be drawn.

cex.legend

magnification to be used for legend text.

auc

logical; if TRUE, AUC, or Area Under the Curve, will be shown in the legend. Larger AUC indicates better performance. No effect if legend is FALSE.

dca

logical; if TRUE, DCA, or Distance of Closest Approach of the curve to (0,1), will be shown in the legend. Smaller DCA indicates better performance. No effect if legend is FALSE.

bw

logical; if TRUE, a black-and-white version of the plot will be drawn. Convenience function for drawing multiple ROC curves on the same plot.

col, lty, lwd, ylab, xlab

as the equivalent arguments to plot.default or lines.default. For plot.multiroc, col, lty, and lwd should be vectors of the same length as x.

grid

logical; if TRUE, draw a grid on the plot.

gridres, gridcol, gridlty

resolution, color, and line type for the grid. No effect if grid is FALSE.

...

further arguments to plot.default or lines.default for the plotting methods, no effect for the other functions.

Details

rocinfo calculates the ROC curve x coordinates (false positive rate, or all positive rate if quasi is TRUE), y coordinates (true positive rate), AUC, and DCA for the given probabilities and labels. multiroc performs the same function for multiple probabilities, and optionally multiple labels.

Value

For rocinfo, a list of class rocinfo having the following elements:

tpr

the true positive rate in ascending order of the probabilities.

fpr

the false positive rate in ascending order of the probabilities.

apr

the all positive rate in ascending order of the probabilities.

auc

the Area Under the Curve.

dca

the Distance of Closest Approach.

quasi

logical; the same as the argument to rocinfo.

For rocauc, the numerical value of the AUC.

For multiroc, a list of class multiroc having elements of class rocinfo.

The plot and lines methods are used for their side effects.

Author(s)

Daniel Dvorkin

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 

### multiple ROC curves for a single set of labels

data(CiData)
data(CiGene)
CiJoint <- lapply(namedList("layered", "chained"), function(top)
    mdmixmod(CiData, c(2,3,2), family=c("pvii", "norm", "pvii"),
    topology=top))
CiMarginal <- marginals(CiJoint$layered) # same for $layered and $chained
CiFits <- c(CiJoint, CiMarginal)
sapply(CiFits, rocauc, labels=CiGene$target)
#     layered      chained      binding   expression conservation 
#   0.8507258    0.8913765    0.8596395    0.7943286    0.7479479
plot(multiroc(CiFits, CiGene$target), grid=TRUE)

### multiple ROC curves for multiple labels

DlFits <- mdmixmod(DlData, c(2,2,2), family=c("norm", "norm", "pvii"))
AllFits = list(Ci=CiJoint$chained, Dl=DlFits)
plot(multiroc(AllFits, list(Ci=CiGene$target, Dl=DlGene$target)))

## End(Not run)

lcmix documentation built on May 2, 2019, 6:49 p.m.