TABLE OF CONTENTS
methodsBiv/plotsurvivor [ Functions ]
NAME
plotsurvivor --- plot a survivor curve
FUNCTION
plots a survivor function
SYNOPSIS
464 plotsurvivor <- function(breaks, hazard, col = 1:10, lty = rep(1, 10), main = "survivor", 465 xlab = "Time", ylab = "Survivor function", xlim = NULL, ylim = NULL, 466 type = "s", add = FALSE, legend = NULL, ...)
INPUTS
breaks breakpoints in the hazard hazard baseline hazard in each interval ... other parameters matching plot.default
SOURCE
469 { 470 interlength <- t(apply(breaks, 1, diff)) 471 survival <- cbind(1, exp(-t(apply(hazard[, -dim(hazard)[2], drop = FALSE] * interlength, 1, cumsum)))) 472 if(is.null(xlim)) xlim = c(0, max(breaks)) 473 if(is.null(ylim)) ylim = c(max(0, min(survival-.05)), 1) 474 if(!add) plot(-1e5, -1e5, xlim = xlim, ylim = ylim, main = main, xlab = xlab, ylab = ylab, ...) 475 for(r in 1:dim(breaks)[1]){ 476 lines(breaks[r, ], survival[r, ], col = col[r], lty = lty[r], type = type, ...) 477 } 478 if(!is.null(legend)) legend("bottomleft", rownames(hazard), col = col, lty = lty, ...) 479 }