set.seed(12345)
stime <- rexp(100) * 10
cens <- runif(100,.5,2) * 10
sevent <- as.numeric(stime <= cens)
stime <- pmin(stime, cens)
strat <- sample(1:3, 100, replace=TRUE)
dd <- data.frame("surv.time"=stime, "surv.event"=sevent, "strat"=strat)
ddweights <- array(1, dim=nrow(dd))
km.coxph.plot(formula.s=Surv(surv.time, surv.event) ~ strat, data.s=dd,
weight.s=ddweights, x.label="Time (years)", y.label="Probability of survival",
main.title="", leg.text=paste(c("Low", "Intermediate", "High"), " ", sep=""),
leg.pos="topright", leg.inset=0, .col=c("darkblue", "darkgreen", "darkred"),
.lty=c(1,1,1), show.n.risk=TRUE, n.risk.step=2, n.risk.cex=0.85, verbose=FALSE)
Run the code above in your browser using DataLab