plot.prodlim {prodlim}R Documentation

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, percent=FALSE,...)

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 incidence function in competing risk models
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 Details.
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 Details.
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.
percent If true the y-axis is labeled in percent.
... graphical parameters that are passed to function plot.

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 resolveSmartArgs. Documentation of these arguments can be found in the help pages of the corresponding functions.

Value

The (invisible) object.

Note

Similar functionality is provided by the function plot.survfit of the survival library

Author(s)

Thomas Alexander Gerds <tag@biostat.ku.dk>

See Also

prodlim,plot.Hist,summary.prodlim, neighborhood, AtRisk, ConfInt, MarkTime

Examples


## 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=c(0,2,5),axis1.pos=0,axis2.pos=0)

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


[Package prodlim version 1.1.3 Index]