Skip to contents

Kaplan-Meier plots of (repeated) time-to-event data. Includes VPCs.

Usage

kaplan.plot(
  x = "TIME",
  y = "DV",
  id = "ID",
  data = NULL,
  evid = "EVID",
  by = NULL,
  xlab = "Time",
  ylab = "Default",
  object = NULL,
  events.to.plot = "All",
  sim.data = NULL,
  sim.zip.file = NULL,
  VPC = FALSE,
  nsim.lab = "simNumber",
  sim.evct.lab = "counter",
  probs = c(0.025, 0.975),
  add.baseline = T,
  add.last.area = T,
  subset = NULL,
  main = "Default",
  main.sub = "Default",
  main.sub.cex = 0.8,
  nbins = NULL,
  real.type = "l",
  real.lty = 1,
  real.lwd = 1,
  real.col = "blue",
  real.se = if (!is.null(sim.data)) F else T,
  real.se.type = "l",
  real.se.lty = 2,
  real.se.lwd = 0.5,
  real.se.col = "red",
  cens.type = "l",
  cens.lty = 1,
  cens.col = "black",
  cens.lwd = 1,
  cens.rll = 0.02,
  inclZeroWRES = TRUE,
  onlyfirst = FALSE,
  samp = NULL,
  poly.alpha = 1,
  poly.fill = "lightgreen",
  poly.line.col = "darkgreen",
  poly.lty = 2,
  censor.lines = TRUE,
  ylim = c(-5, 105),
  cov = NULL,
  cov.fun = "mean",
  ...
)

Arguments

x

The independent variable.

y

The dependent variable. event (>0) or no event (0).

id

The ID variable in the dataset.

data

A dataset can be used instead of the data in an Xpose object. Must have the same form as an xpose data object xpdb@Data.

evid

The EVID data item. If not present then all rows are considered events (can be censored or an event). Otherwise, EVID!=0 are dropped from the data set.

by

A vector of conditioning variables.

xlab

X-axis label

ylab

Y-axis label

object

An Xpose object. Needed if no data is supplied.

events.to.plot

Vector of events to be plotted. "All" means that all events are plotted.

sim.data

The simulated data file. Should be a table file with one header row and have, at least, columns with headers corresponding to x, y, id, by (if used), nsim.lab and sim.evct.lab.

sim.zip.file

The sim.data can be in \.zip format and xpose will unzip the file before reading in the data. Must have the same structure as described above in sim.data.

VPC

TRUE or FALSE. If TRUE then Xpose will search for a zipped file with name paste("simtab",object@Runno,".zip",sep=""), for example "simtab42.zip".

nsim.lab

The column header for sim.data that contains the simulation number for that row in the data.

sim.evct.lab

The column header for sim.data that contains the individual event counter information. For each individual the event counter should increase by one for each event (or censored event) that occurs.

probs

The probabilities (non-parametric percentiles) to use in computation of the prediction intervals for the simulated data.

add.baseline

Should a (x=0,y=1) baseline measurement be added to each individual in the dataset. Otherwise each plot will begin at the first event in the dataset.

add.last.area

Should an area be added to the VPC extending the last PI?

subset

The subset of the data and sim.data to use.

main

The title of the plot. Can also be NULL or "Default".

main.sub

The title of the subplots. Must be a list, the same length as the number of subplots (actual graphs), or NULL or "Default".

main.sub.cex

The size of the title of the subplots.

nbins

The number of bins to use in the VPC. If NULL, the the number of unique x values in sim.data is used.

real.type

Type for the real data.

real.lty

Line type (lty) for the curve of the original (or real) data.

real.lwd

Line width (lwd) for the real data.

real.col

Color for the curve of the original (or real) data.

real.se

Should the standard errors of the real (non simulated) data be plotted? Calculated using survfit.

real.se.type

Type for the standard errors.

real.se.lty

Line type (lty) for the standard error lines.

real.se.lwd

Line width (lwd) for the standard error lines.

real.se.col

Color for the standard error lines.

cens.type

Type for the censored lines.

cens.lty

Line type (lty) for the censored lines.

cens.col

Color for the censored lines.

cens.lwd

Line width for the censored lines.

cens.rll

The relative line length of the censored line compared to the limits of the y-axis.

inclZeroWRES

Include WRES=0 rows from the real data set in the plots?

onlyfirst

Include only the first measurement for the real data in the plots?

samp

Simulated data in the xpose data object can be used as the "real" data. samp is a number selecting which simulated data set to use.

poly.alpha

The transparency of the VPC shaded region.

poly.fill

The fill color of the VPC shaded region.

poly.line.col

The line colors for the VPC region.

poly.lty

The line type for the VPC region.

censor.lines

Should censored observations be marked on the plot?

ylim

Limits for the y-axes

cov

The covariate in the dataset to plot instead of the survival curve.

cov.fun

The summary function for the covariate in the dataset to plot instead of the survival curve.

...

Additional arguments passed to the function.

Value

returns an object of class "xpose.multiple.plot".

Author

Andrew C. Hooker

Examples


if (FALSE) {
library(xpose4)

## Read in the data
runno <- "57"
xpdb <- xpose.data(runno)

####################################
# here are the real data plots
####################################

kaplan.plot(x="TIME",y="DV",object=xpdb)
kaplan.plot(x="TIME",y="DV",object=xpdb,
            events.to.plot=c(1,2),
            by=c("DOSE==0","DOSE!=0"))
kaplan.plot(x="TIME",y="DV",object=xpdb,
            events.to.plot=c(1,2),
            by=c("DOSE==0","DOSE==10",
            "DOSE==50","DOSE==200"))

## make a PDF of the plots
pdf(file=paste("run",runno,"_kaplan.pdf",sep=""))
kaplan.plot(x="TIME",y="DV",object=xpdb,
            by=c("DOSE==0","DOSE==10",
            "DOSE==50","DOSE==200"))
dev.off()

####################################
## VPC plots
####################################

kaplan.plot(x="TIME",y="DV",object=xpdb,VPC=T,events.to.plot=c(1))
kaplan.plot(x="TIME",y="DV",object=xpdb,VPC=T,
            events.to.plot=c(1,2,3),
            by=c("DOSE==0","DOSE!=0"))
kaplan.plot(x="TIME",y="DV",object=xpdb,VPC=T,
            events.to.plot=c(1),
            by=c("DOSE==0","DOSE==10","DOSE==50","DOSE==200"))

## make a PDF of all plots
pdf(file=paste("run",runno,"_kaplan.pdf",sep=""))
kaplan.plot(x="TIME",y="DV",object=xpdb,VPC=T,
            by=c("DOSE==0","DOSE==10","DOSE==50","DOSE==200"))
dev.off()
}