## S3 method for class 'pec':
plot(x,
what,
models,
xlim=c(x$start,x$minmaxtime),
ylim=c(0,0.3),
xlab="Time",
ylab,
axes=TRUE,
col,
lty,
lwd,
type,
smooth=FALSE,
add.refline=FALSE,
add=FALSE,
legend=ifelse(add,FALSE,TRUE),
special=FALSE,
...)
pec
obtained with function pec
.x
. Defauls to PredErr
Other choices are AppErr
, BootCvErr
, Boot632
, Boot632plus
.x$models
for which the prediction
error curves are drawn. Defaults to all models.FALSE
no axes are drawn.models
in the order
determined by models
.models
in the order
determined by models
.models
in the order
determined by models
."l"
or "s"
, see lines
.TRUE
the plotting values are smoothed with the
function smooth
kind="3R".TRUE
a dotted horizontal line is drawn as a
symbol for the naive rule that predicts probability .5 at all
cutpoints (i.e. time points in survival analysis).TRUE
only lines are added to an existing devicelegend
can be given in the
form legend.x=val
where x is the name of the argument and
val the desired value. See also DetaTRUE
the bootstrap curves of models
are
plotted together with predErr
of models
by invoking the function
Special
. Optional arguments of the
function Special
plot
.legend
, axis
, Special
are simply specified as legend.lty=2
. The specification is not
case sensitive, thus
Legend.lty=2
or LEGEND.lty=2
will have the same effect.
The function axis
is called twice, and arguments of the form
axis1.labels
, axis1.at
are used for the time axis
whereas axis2.pos
, axis1.labels
, etc. are used for the
y-axis. These arguments are processed via ...
of plot.pec
and inside by using the function resolveSmartArgs
.
Documentation of these arguments can be found
in the help pages of the corresponding
functions.
pec
{summary.pec
}{Special
}{prodlim
}# simulate an artificial data frame
# with survival response and two predictors
set.seed(280180)
N <- 300
X1 <- rnorm(N,mean=10,sd=5)
X2 <- rbinom(N,1,.4)
linPred <- .00001+0.2*X1+2.3*X2
T <- sapply(linPred,function(lp){rexp(n=1,exp(-lp))})
C <- rexp(n=300,exp(-mean(linPred)))
dat <- data.frame(time=pmin(T,C),status=as.numeric(T<=C),X1=X1,X2=X2)
# fit some candidate Cox models and compute the Kaplan-Meier estimate
Models <- list("Kaplan.Meier"=survfit(Surv(time,status)~1,data=dat),
"Cox.X1"=coxph(Surv(time,status)~X1,data=dat),
"Cox.X2"=coxph(Surv(time,status)~X2,data=dat),
"Cox.X1.X2"=coxph(Surv(time,status)~X1+X2,data=dat))
# compute the .632+ estimate of the generalization error
set.seed(17100)
PredError.632plus <- pec(object=Models,
formula=Surv(time,status)~X1+X2,
data=dat,
exact=TRUE,
cens.model="marginal",
splitMethod="boot632plus",
B=10,
keep.matrix=TRUE,
verbose=TRUE)
# plot the .632+ estimates of the generalization error
plot(PredError.632plus,xlim=c(0,30))
# plot the bootstrapped curves, .632+ estimates of the generalization error
# and Apparent error for the Cox model 'Cox.X1' with the 'Cox.X2' model
# as benchmark
plot(PredError.632plus,xlim=c(0,30), models="Cox.X1", special=TRUE, special.bench="Cox.X2", special.benchcol=2, special.addprederr="AppErr")
Run the code above in your browser using DataLab