Open bgreenwell opened 7 years ago
And for "coxph" objects:
invest.coxph <- function(object, prob = 0.5, level = 0.95, ...) {
sf <- survfit(object, conf.int = level, ...)
est <- minmin(sf$surv, sf$time, prob = prob)
upr <- minmin(sf$upper, sf$time, prob = prob)
lwr <- minmin(sf$lower, sf$time, prob = prob)
plot(sf, conf.int = TRUE)
abline(h = prob, v = c(lwr, est, upr))
c("est" = est, "lwr" = lwr, "upr" = upr)
}
# Example
fit <- coxph(Surv(futime, fustat) ~ age, data = ovarian)
invest.coxph(fit, prob = 0.9)
invest.coxph(fit, prob = 0.9, newdata = data.frame(age = 60))
Here's a good start for single Kaplan-Meier curves: