Learn R Programming

prodlim (version 1.2.1)

plot.prodlim: Plotting event probabilities over time

Description

Function to plot survival and cumulative incidence curves against time.

Usage

## S3 method for class 'prodlim':
plot(x,
     type,
     cause = 1,
     newdata,
     add = FALSE,
     col,
     lty,
     lwd,
     ylim,
     xlim,
     xlab = "Time",
     ylab,
     legend = TRUE,
     marktime = FALSE,
     confint = TRUE,
     automar,
     atrisk=ifelse(add,FALSE,TRUE),
     timeOrigin,
     axes=TRUE,
     background=TRUE,
     percent=TRUE,
     minAtrisk=0,
     ...)

Arguments

x
an object of class `prodlim' as returned by the prodlim function.
type
controls what part of the object is plotted. Defaults to "survival" for the Kaplan-Meier estimate of the survival function in two state models and to "incidence" for the Aalen-Johansen estimate of the cumulative i
cause
determines the cause of the cumulative incidence function. Currently one cause is allowed at a time, but you may call the function again with add=TRUE to add the lines of the other causes.
newdata
a data frame containing strata for which plotted curves are desired.
add
if 'TRUE' curves are added to an existing plot.
col
color for curves defaults to 1:number(curves)
lty
line type for curves defaults to 1
lwd
line width for all curves
ylim
limits of the y-axis
xlim
limits of the x-axis
ylab
label for the y-axis
xlab
label for the x-axis
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 Deta
marktime
if TRUE the curves are tick-marked at right censoring times by invoking the function markTime. Optional arguments of the function markTime can be given in the form confint.x=val as with legend. See also D
confint
if TRUE pointwise confidence intervals are plotted by invoking the function confInt. Optional arguments of the function confInt can be given in the form confint.x=val as with legend. See also Details.
automar
If TRUE the function trys to get good values for figure margins around the main plotting region.
atrisk
if TRUE display numbers of subjects at risk by invoking the function atRisk. Optional arguments of the function atRisk can be given in the form atrisk.x=val as with legend. See also Details.
timeOrigin
Start of the time axis
axes
If true axes are drawn. See details.
background
If TRUE the background color and grid color can be controlled using smart arguments SmartControl, such as background.bg="yellow" or background.bg=c("gray66","gray88"). The following defaults are passed to background
percent
If true the y-axis is labeled in percent.
minAtrisk
Integer. Show the curve only until the number at-risk is at least minAtrisk
...
Parameters that are filtered and then passed to the functions plot, legend, axis,

Value

  • The (invisible) object.

Details

From version 1.1.3 on the arguments legend.args, atrisk.args, confint.args are obsolete and only available for backward compatibility. Instead arguments for the invoked functions atRisk, legend, confInt, markTime, axis are simply specified as atrisk.cex=2. The specification is not case sensitive, thus atRisk.cex=2 or atRISK.cex=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.prodlim and inside by using the function SmartControl. Documentation of these arguments can be found in the help pages of the corresponding functions.

See Also

plot, legend, axis, prodlim,plot.Hist,summary.prodlim, neighborhood, atRisk, confInt, markTime, backGround

Examples

Run this code
## simulate right censored data from a two state model 
dat <- data.frame(time=rexp(100),status=rbinom(100,1,.3),X=rbinom(100,1,.5),Z=rnorm(100,10,3),patnr=sample(1:10,size=100,replace=TRUE))
with(dat,plot(Hist(time,status)))

### marginal Kaplan-Meier estimator
kmfit <- prodlim(Hist(time, status) ~ 1, data = dat)
plot(kmfit)
plot(kmfit,percent=TRUE)
plot(kmfit,percent=TRUE,axis1.at=seq(0,kmfit$maxtime,365.25/2),axis1.labels=seq(0,kmfit$maxtime/365.25,1/2),xlab="Years",axis2.las=2,atrisk.label="Patients")
plot(kmfit,confint.citype="shadow",col=4,background=TRUE,background.fg="yellow",background.horizontal=seq(0,1,.25/2),background.vertical=seq(0,kmfit$maxtime,1),background.bg=c("gray88"))
plot(kmfit,confint.citype="dots",col=4,background=TRUE,background.bg=c("white","gray88"),background.fg="gray77",background.horizontal=seq(0,1,.25/2),background.vertical=seq(0,kmfit$maxtime,1),background.bg=c("gray88","gray88"))

### Kaplan-Meier in discrete strata
kmfitX <- prodlim(Hist(time, status) ~ X, data = dat)
plot(kmfitX)
plot(kmfitX,legend.x="bottomleft",atRisk.cex=1.3)

### Kaplan-Meier in continuous strata
kmfitZ <- prodlim(Hist(time, status) ~ Z, data = dat)
plot(kmfitZ,newdata=data.frame(Z=c(5,7,12)))

### Cluster-correlated data
kmfitC <- prodlim(Hist(time, status) ~ cluster(patnr), data = dat)
plot(kmfitC,atrisk.labels=c("Units","Patients"))

## simulate right censored data from a competing risk model 
datCR <- data.frame(time=rexp(100),status=rbinom(100,2,.3),X=rbinom(100,1,.5),Z=rnorm(100,10,3))
with(datCR,plot(Hist(time,status)))

### marginal Aalen-Johansen estimator
ajfit <- prodlim(Hist(time, status) ~ 1, data = datCR)
plot(ajfit)

### conditional Aalen-Johansen estimator
ajfitXZ <- prodlim(Hist(time, status) ~ X+Z, data = datCR)
plot(ajfitXZ,newdata=data.frame(X=c(1,1,0),Z=c(4,10,10)))
plot(ajfitXZ,newdata=data.frame(X=c(1,1,0),Z=c(4,10,10)),cause=2)

Run the code above in your browser using DataLab