Learn R Programming

PwePred (version 1.0.0)

plot_survival: Plot Survival Curve

Description

Plot KM curve with right censoring data or the survival curve of a fitted piecewise exponential model.

Usage

# S3 method for default
plot_survival(time, event, add=FALSE, conf.int=FALSE, mark.time=TRUE,
       lwd=2, xlab='Follow-up time', ylab='Survival function', ...)
# S3 method for pwexpm
plot_survival(time, add=TRUE, show_breakpoint=TRUE,
       breakpoint_par=NULL, ...)
# S3 method for boot.pwexpm
plot_survival(time, add=TRUE, alpha=0.1, show_breakpoint=TRUE,
       breakpoint_par=NULL, show_CI=TRUE, CI_par=NULL, ...)

Value

No return value.

Arguments

time

observed time from randomization or a pwexpm/ boot.pwexpm object.

event

the status indicator, normally 0=censor, 1=event. Other choices are TRUE/FALSE (TRUE = event).

add

logical; if TRUE add lines to current plot.

show_breakpoint

logical; if TRUE add vertial dashed lines to indicate breakpoints.

breakpoint_par

a list of parameters to control the apperance of vertical lines of breakpoionts. The values pass to abline.

alpha

the significance level of the confidence interval.

show_CI

logical; if TRUE add confidence interval of the estimated curve. For KM esitmator, use conf.int=TRUE to show CI band.

CI_par

a list of parameters to control the apperance of lines of confidence intervals. The values pass to lines.

conf.int

determines whether pointwise confidence intervals will be plotted. Passed over to plot.survfit.

mark.time

controls the labeling of the curves. Passed over to plot.survfit.

lwd

line width of the KM curve.

xlab

x label.

ylab

y label.

...

other arguments are passed over to plot.survfit (default method) or plot (for class pwexpm).

Author

Tianchen Xu zjph602xutianchen@gmail.com

Details

For the default method, this a wrapper of plot.survfit function to plot right censoring data.

For class pwexpm, parameters in ... are passed to plot function to control the appearance of the survival curve; parameters in breakpoint_par are passed to abline function to control the appearance of vertical lines of breakpoints. See examples for usage.

For class boot.pwexpm, parameters in ... are passed to plot function to control the appearance of the survival curve; parameters in breakpoint_par are passed to abline function to control the appearance of vertical lines of breakpoints; parameters in CI_par are passed to lines function to control the appearance of confidence intervals. See examples for usage.

See Also

plot_event

Examples

Run this code
event_dist <- function(n)rpwexpm(n, rate = c(0.1, 0.01, 0.2), breakpoint =  c(5,14))
dat <- simdata(rand_rate = 20, drop_rate = 0.03,  total_sample = 1000,
               advanced_dist = list(event_dist=event_dist),
               add_column = c('censor_reason','event','followT','followT_abs'))

plot_survival(dat$followT, dat$event, xlim=c(0,40))

fit_res <- pwexpm(Surv(followT, event), data = dat, nbreak = 2)
plot_survival(fit_res, col='red', lwd=3, breakpoint_par = list(col='grey', lwd=2.5))

Run the code above in your browser using DataLab