Learn R Programming

riskRegression (version 1.3.7)

plotROC: Plot ROC curves

Description

Plot ROC curve

Usage

plotROC(x, models, times, xlab = "1-Specificity", ylab = "Sensitivity", col,
  lwd = 3, lty = 1, cex = 1, pch = 1, legend = TRUE, add = FALSE,
  ...)

Arguments

x

Object obtained with function Score

models

Choice of models to plot

times

A single time point specifying the prediction horizon

xlab

Label for x-axis

ylab

Label for y-axis

col

line color

lwd

line width

lty

line style

cex

point size

pch

point style

legend

logical. If 1L draw a legend with the values of AUC.

add

logical. If 1L add lines to an existing plot.

...

Used for additional control of the subroutines: plot, axis, lines, legend. See SmartControl.

Examples

Run this code
## binary
set.seed(18)
library(randomForest)
library(survival)
bdl <- sampleData(40,outcome="binary")
bdt <- sampleData(58,outcome="binary")
bdl[,y:=factor(Y)]
bdt[,y:=factor(Y)]
fb1 <- glm(y~X1+X2+X3+X4+X5+X6+X7+X8+X9+X10,data=bdl,family="binomial")
fb2 <- randomForest(y~X1+X2+X3+X4+X5+X6+X7+X8+X9+X10,data=bdl)
xb <- Score(list("glm"=fb1,"rf"=fb2),y~1,data=bdt,
            plots="roc",metrics="auc")
plotROC(xb)
## survival
set.seed(18)
sdl <- sampleData(40,outcome="survival")
sdt <- sampleData(58,outcome="survival")
fs1 <- coxph(Surv(time,event)~X3+X5+X6+X7+X8+X10,data=sdl,x=TRUE)
fs2 <- coxph(Surv(time,event)~X1+X2+X9,data=sdl,x=TRUE)
xs <- Score(list(model1=fs1,model2=fs2),Hist(time,event)~1,data=sdt,
            times=5,plots="roc",metrics="auc")
plotROC(xs)
## competing risks
data(Melanoma)
f1 <- CSC(Hist(time,status)~age+sex+epicel+ulcer,data=Melanoma)
f2 <- CSC(Hist(time,status)~age+sex+logthick+epicel+ulcer,data=Melanoma)
x <- Score(list(model1=f1,model2=f2),Hist(time,status)~1,data=Melanoma,
            cause=1,times=5*365.25,plots="roc",metrics="auc")
plotROC(x)

Run the code above in your browser using DataLab