Plots Survival Functions

Description

This function takes a vector of survival values and a vector of time values and either plots a survival function or adds the survival lines to an existing plot.

Usage

1
2
icplot(surv, time = as.numeric(names(surv)), xrange = NA, lines.only = FALSE,
XLAB = "Time", YLAB = "Probability", LTY = 1, ...)

Arguments

surv

a vector of survival values.

time

a vector of times. These are related to the vector of survival by Prob(X > time[i]) = surv[i]. If this vector is not given then the default is to use as.numeric(names(surv)).

xrange

the range of the x values. The default is c(0,max(time[time<Inf])). This value may need to be supplied when plotting more than one survival curve on a single plot (see lines.only).

lines.only

a logical value; default = FALSE. If lines.only = FALSE the function draws a new set of axes. If lines.only = TRUE the function adds lines to an existing plot. To print 2 lines on one plot, call the function twice, the first time with lines.only = FALSE and xrange = range(c(t1,t2)) where t1 and t2 are the (finite) times for the two survival curves, the second time with lines.only = TRUE.

XLAB

a character string denoting the x label. Default = "Time".

YLAB

a character string denoting the y label. Default = "Probability".

LTY

an integer denoting the line type (lty value).

...

additional plotting parameters (except xlab and ylab).

Details

See icplot details. This may not be the most accurate way to present the data. See Betensky, Lindsey, Ryan, and Wand (1999, p. 238) for an alternative method.

Value

Returns a plot or adds a line to an existing plot.

Note

The functions icfit, icplot, and ictest and documentation for these functions are from Michael P. Fay. You are free to distribute these functions to whomever is interested. They come with no warrantee however.

Author(s)

Michael P. Fay

References

Betensky, R. A., Lindsey, J. C., Ryan, L. M., and Wand, M. P. (1999), "Local EM Estimation of the Hazard Function for Interval-Censored Data," Biometrics, 55: 238-245.

See Also

icfit, ictest

Examples

1
2
3
4
5
6
# Plot two Survival curves on one plot.
#  need data set for this example
#   s1<- icfit(left[treatment==1],right[treatment==1])
#   s2<- icfit(left[treatment==2],right[treatment==2])
#   icplot(s1$surv,s1$time,xrange=range(c(s1$time,s2$time)))
#   icplot(s2$surv,s2$time,lines.only=TRUE,LTY=2)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.