R: Plotting prediction error curves

plot.pec {pec} | R Documentation

## Plotting prediction error curves

### Description

Plotting prediction error curves for one or more prediction models.

### Usage

    ## 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, ...)

### Arguments

`x` | Object of class `pec` obtained with function `pec`.
`what` | The name of the entry in `x`. Defauls to `PredErr` Other choices are `AppErr`, `BootCvErr`, `Boot632`, `Boot632plus`.
`models` | Specifies models in `x$models` for which the prediction error curves are drawn. Defaults to all models.
`xlim` | Plotting range on the x-axis.
`ylim` | Plotting range on the y-axis.
`xlab` | Label given to the x-axis.
`ylab` | Label given to the y-axis.
`axes` | Logical. If `FALSE` no axes are drawn.
`col` | Vector of colors given to the curves of `models` in the order determined by `models`.
`lty` | Vector of lty's given to the curves of `models` in the order determined by `models`.
`lwd` | Vector of lwd's given to the curves of `models` in the order determined by `models`.
`type` | Plotting type: either `"l"` or `"s"`, see `lines`.
`smooth` | Logical. If `TRUE` the plotting type for lines is `'l'` else `'s'`.
`add.refline` | Logical. If `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).
`add` | Logical. If `TRUE` only lines are added to an existing device
`legend` | if TRUE a legend is plotted by calling the function legend. Optional arguments of the function `legend` can be given in the form `legend.x=val` where x is the name of the argument and val the desired value. See also Details.
`special` | Logical. If `TRUE` the bootstrap curves of `models` are plotted together with `predErr` of `models` by invoking the function `Special`. Optional arguments of the function `Special` can be given in the form `special.x=val` as with legend. See also Details.
`...` | Extra arguments that are passed to `plot`.

### Details

From version 2.0.1 on the arguments legend.text, legend.args, lines.type, lwd.lines, specials are obsolete and only available for backward compatibility. Instead arguments for the invoked functions `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.

### Value

The (invisible) object.

### Author(s)

Ulla B. Mogensen ulmo@biostat.ku.dk, Thomas A. Gerds tag@biostat.ku.dk

### See Also

`pec` `summary.pec` `Special` `prodlim`

### Examples

    # simulate data
    # with a survival response and two predictors
    library(prodlim)
    library(survival)
    set.seed(280180)
    dat <- SimSurv(100)

    # 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,x=TRUE,y=TRUE),
                   "Cox.X2"=coxph(Surv(time,status)~X2,data=dat,x=TRUE,y=TRUE),
                   "Cox.X1.X2"=coxph(Surv(time,status)~X1+X2,data=dat,x=TRUE,y=TRUE))
    Models <- list("Cox.X1"=coxph(Surv(time,status)~X1,data=dat,x=TRUE,y=TRUE),
                   "Cox.X2"=coxph(Surv(time,status)~X2,data=dat,x=TRUE,y=TRUE),
                   "Cox.X1.X2"=coxph(Surv(time,status)~X1+X2,data=dat,x=TRUE,y=TRUE))

    # 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=5,
                             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")

[Package pec version 2019.11.03 Index]