Function for a receiver operating characteristic curve (ROC) plot and area under the ROC curve (AUC) value.

Description

The function produces ROC curve and corresponding AUC value with 95% CI. The function can plot one or multiple ROC curves in a single plot.

Usage

1
2
plotROC(data, cOutcome, predrisk, labels, plottitle, xlabel, ylabel, 
fileplot, plottype)

Arguments

data

Data frame or matrix that includes the outcome and predictors variables.

cOutcome

Column number of the outcome variable.

predrisk

Vector of predicted risk. When multiple curves need to be presented in one plot, specify multiple vectors of predicted risks as predrisk=cbind(predrisk1, predrisk2,...,predriskn).

labels

Label(s) given to the ROC curve(s). Specification of labels is optional. When specified, the labels should be in the same order as specified in predrisk.

plottitle

Title of the plot. Specification of plottitle is optional. Default is "ROC plot".

xlabel

Label of x-axis. Specification of xlabel is optional. Default is "1- Specificity".

ylabel

Label of y-axis. Specification of ylabel is optional. Default is "Sensitivity".

fileplot

Name of the output file that contains the plot. The file is saved in the working directory in the format specified under plottype. Example: fileplot="plotname". Note that the extension is not specified here. When fileplot is not specified, the plot is not saved.

plottype

The format in which the plot is saved. Available formats are wmf, emf, png, jpg, jpeg, bmp, tif, tiff, ps, eps or pdf. For example, plottype="eps" will save the plot in eps format. When plottype is not specified, the plot will be saved in jpg format.

Details

The function requirs predicted risks or risk scores and the outcome of interest for all individuals. Predicted risks can be obtained using the functions fitLogRegModel and predRisk or be imported from other methods or packages.

Value

The function creates ROC plot and returns AUC value with 95% CI.

References

Hanley JA, McNeil BJ. The meaning and use of the area under a receiver operating characteristic (ROC) curve. Radiology 1982;143:29-36.

Tobias Sing, Oliver Sander, Niko Beerenwinkel, Thomas Lengauer. ROCR: visualizing classifier performance in R. Bioinformatics 2005;21(20):3940-3941.

See Also

predRisk, plotRiskDistribution

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# specify the arguments in the function to produce ROC plot
# specify dataset with outcome and predictor variables
data(ExampleData)
# specify column number of the outcome variable
cOutcome <- 2

# fit logistic regression models
# all steps needed to construct a logistic regression model are written in a function
# called 'ExampleModels', which is described on page 4-5
riskmodel1 <- ExampleModels()$riskModel1
riskmodel2 <- ExampleModels()$riskModel2

# obtain predicted risks
predRisk1 <- predRisk(riskmodel1)
predRisk2 <- predRisk(riskmodel2)

# specify label of the ROC curve
labels <- c("without genetic factors", "with genetic factors")

# produce ROC curve
plotROC(data=ExampleData, cOutcome=cOutcome, 
predrisk=cbind(predRisk1,predRisk2), labels=labels)