plot.Roc: ROC curves for risk prediction models

Description Usage Arguments Details Value Author(s) See Also Examples

Description

ROC curves for risk prediction models

Usage

1
2
3
4
5
## S3 method for class 'Roc'
plot(x, ylab = "Sensitivity", xlab = "1-Specificity", models,
  type = "l", shadow = FALSE, simu = FALSE, control, grid = FALSE,
  diag = TRUE, box = FALSE, lwd = 2, lty, col, add = FALSE,
  axes = TRUE, legend, auc, percent = TRUE, ...)

Arguments

x

object obtained with Roc

ylab

Label y-axis

xlab

Label x-axis

models

Selection of models to plot. Should be a subset of names(x$models). Makes sense when x contains multiple ROC curves.

type

The line type

shadow

Experimental. Show results of cross-validation.

simu

Experimental. Show noinformation results.

control

Control which estimates of the ROC curves to draw.

grid

If TRUE add a grid in the background of the graph.

diag

If TRUE add a diagonal line.

box

If TRUE add a box around the graph.

lwd

Vector of line widths for the ROC curves.

lty

Vector of line types for the ROC curves.

col

Vector of colours for the ROC curves.

add

If TRUE add ROC curves to existing plot.

axes

If TRUE draw axes.

legend

If TRUE draw a legend.

auc

If TRUE add the area under the curve to the legend.

percent

If TRUE show percent axes.

...

Use for smart control of some plot elements.

Details

Multiple ROC curves are shown in one graph.

Value

ROC curves

Author(s)

Thomas A. Gerds <tag@biostat.ku.dk>

See Also

Roc

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# generate som data
set.seed(40)
N=40
Y=rbinom(N,1,.5)
X1=rnorm(N)
X1[Y==1]=rnorm(sum(Y==1),mean=rbinom(sum(Y==1),1,.5))
X2=rnorm(N)
X2[Y==0]=rnorm(sum(Y==0),mean=rbinom(sum(Y==0),1,.5))
dat <- data.frame(Y=Y,X1=X1,X2=X2)

# fit two logistic regression models
lm1 <- glm(Y~X1,data=dat,family="binomial")
lm2 <- glm(Y~X2+X1,data=dat,family="binomial")
plot(Roc(list(lm1,lm2),data=dat))

# add the area under the curves

plot(Roc(list(lm1,lm2),data=dat),auc=TRUE)

# alternatively, one can directly work with formula objects:
plot(Roc(list(LR.X1=Y~X1,LR.X1.X2=Y~X2+X1),data=dat),auc=TRUE)

# beyond the logistic regression model.
# the following example is optimized for speed
# illustrating the syntax,
# and not for optimized for performance of the
# randomForest or elastic net
library(randomForest)
library(glmnet)
dat$Y=factor(dat$Y)
rf <- randomForest(Y~X1+X2,data=dat,ntree=10)
en <- ElasticNet(Y~X1+X2,data=dat,nfolds=10,alpha=0.1)
set.seed(6)
rocCV=Roc(list(RandomForest=rf,ElasticNet=en,LogisticRegression=lm2),
  data=dat,
  verbose=FALSE,
  splitMethod="bootcv",
  B=4,
  cbRatio=1)
plot(rocCV,yaxis.las=2,legend.title="4 bootstrap-crossvalidation steps")

Example output

randomForest 4.6-14
Type rfNews() to see new features/changes/bug fixes.
Loading required package: Matrix
Loading required package: foreach
Loaded glmnet 2.0-16

ModelGood documentation built on May 2, 2019, 5 p.m.