Here is an example taken from this article .
url <- "http://socserv.mcmaster.ca/jfox/Books/Companion/data/Rossi.txt" Rossi <- read.table(url, header=TRUE) Rossi[1:5, 1:10]
Note that the model uses fin, age, race, wexp, mar, paro, prio to predict arrest . As mentioned in this document , the survfit() function uses the Kaplan-Meyer score for survival.
plot(survfit(mod.allison), ylim=c(0.7, 1), xlab="Weeks", ylab="Proportion Not Rearrested")

We get a graph (with a 95% confidence interval) for survival. For the cumulative risk norm, you can do
# plot(survfit(mod.allison)$cumhaz)
but this does not give confidence intervals. However, do not worry! We know that H (t) = -ln (S (t)), and we have confidence intervals for S (t). All we need to do is
sfit <- survfit(mod.allison) cumhaz.upper <- -log(sfit$upper) cumhaz.lower <- -log(sfit$lower) cumhaz <- sfit$cumhaz
Then just sketch these
plot(cumhaz, xlab="weeks ahead", ylab="cumulative hazard", ylim=c(min(cumhaz.lower), max(cumhaz.upper))) lines(cumhaz.lower) lines(cumhaz.upper)

You want to use survfit(..., conf.int=0.50) to get bands at 75% and 25% instead of 97.5% and 2.5%.
nathanesau
source share