Description Usage Arguments Details Value Author(s) See Also Examples
ROC curves for risk prediction models
1 2 3 4 5 |
x |
object obtained with |
ylab |
Label y-axis |
xlab |
Label x-axis |
models |
Selection of models to plot. Should be a
subset of |
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 |
diag |
If |
box |
If |
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 |
axes |
If |
legend |
If |
auc |
If |
percent |
If |
... |
Use for smart control of some plot elements. |
Multiple ROC curves are shown in one graph.
ROC curves
Thomas A. Gerds <tag@biostat.ku.dk>
Roc
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")
|
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.