roc: Receiver Operating Characteristic (ROC) Curves

Description Usage Arguments Details Value References See Also Examples

View source: R/MAMSE.R

Description

Computes the ROC curve (nonparametric or parametric based on likelihood) for single populations or a weighted ROC curve for lists of populations. The MAMSE weights are used by default for the multiple populations case.

Usage

1
2
roc(healthy, diseased, wh=NULL, wd=NULL, FPR=NULL, method="np", 
   smalldiseased=TRUE, AUC=FALSE, nFPR=201)

Arguments

healthy

A single numeric vector with the values of the diagnostic variable for the healthy group, or a list of m samples (each a numeric vector) from healthy subjects from different populations. When relevant (when MAMSE weights are used), the first sample (healthy[[1]]) is deemed to come from the population of interest and the m-1 other samples are used to borrow strength.

diseased

A single numeric vector with the values of the diagnostic variable for the diseased group, or a list of m samples (each a numeric vector) from diseased subjects from different populations. The number of populations in healthy and diseased must match, and it is assumed that they are presented in the same order (i.e. the j^{th} element of both lists are from the same population. When relevant (when MAMSE weights are used), the first sample (healthy[[1]]) is deemed to come from the population of interest and the m-1 other samples are used to borrow strength.

wh

Weights for the healthy population. If healthy is a vector, wh is a numeric vector of the same length that sums to one and if wh is NULL, equal weights are given to each datum. If healthy is a list, wh is a numeric vector of length m that sums to one and if wh is NULL, MAMSE weights are calculated.

wd

Weights for the diseased population. If healthy is a vector, wd is a numeric vector of the same length that sums to one and if wd is NULL, equal weights are given to each datum. If healthy is a list, wh is a numeric vector of length m that sums to one and if wh is NULL, MAMSE weights are calculated.

FPR

Numeric vector giving the values of FPR (the x-axis) where the ROC curve should be computed. If FPR is NULL, the default is to keep every step in the nonparametric settings, or to split the [0,1] interval in nFPR steps (keeping both 0 and 1).

method

Allowed values are "np" for nonparametric ROC curves, "lognormal" for a parametric curve based on the log-normal distribution or "normal" for a parametric curve based on the normal distribution. In the parametric cases, plug-in estimates are used with the (possibly weighted) likelihood.

smalldiseased

By default, it is assumed that diseased subjects tend to have smaller values than healthy ones, but smalldiseased=FALSE can be used when diseased present large values of the diagnostic variable.

AUC

If AUC=TRUE, the Area Under the Curve will be calculated and returned. Note that AUC will not be calculated if a manually provided FPR does not start at 0 and end at 1.

nFPR

If FPR is not provided in the parametric setting, it will be generated with equal steps between 0 and 1 (including those bounds).

Details

This function returns the ROC curve based on the provided data sets. The method can be either parametric (normal or log-normal) or nonparametric. Multiple samples can be used and weighted. MAMSE weights are used by default. The first sample appearing in the lists of data is then deemed to come from the population of interest. The function returns a list of point (FPR,TPR) that can be plotted to see the ROC curve. The points where the function is evaluated can be controlled by specifying FPR manually. By default, it is assumed that small values of the diagnostic variable indicate a disease, but the option smalldiseased can be used if small values are for healthy subjects.

Value

S3 object of type roc which is a list with the values TPR (vector with true positive rates for different thresholds), FPR (false positive rate for the corresponding threshold) and AUC (Area under the ROC curve). A method for plot has been defined for easier display (see exemples below).

References

J.-B. Débordès & J.-F. Plante (2009). Combining ROC curves using MAMSE weighted distributions. Cahier du GERAD G-2015-69.

See Also

MAMSE-package, MAMSE.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(Progesterone)
healthy=lapply(Progesterone,function(x){x$viable})
diseased=lapply(Progesterone,function(x){sort(c(x$ecto,x$abort))})

par(mfrow=c(2,2))

plot(roc(healthy[[1]],diseased[[1]],AUC=TRUE))
title("Empirical ROC curve based on Ledger (1994)")
plot(roc(healthy[[1]],diseased[[1]],AUC=TRUE,method="lognormal"))
title("Parametric ROC curve based on Ledger (1994)")

plot(roc(healthy,diseased,AUC=TRUE))
title("MAMSE-weighted empirical ROC curve")
plot(roc(healthy,diseased,AUC=TRUE,method="lognormal"))
title("MAMSE-weighted parametric ROC curve")

MAMSE documentation built on May 1, 2019, 10:15 p.m.