data(GBSG2)
thsum <- function(x) {
ret <- c(median(x), quantile(x, 0.25), quantile(x,0.75))
names(ret)[1] <- "Median"
ret
}
t(apply(GBSG2[,c("age", "tsize", "pnodes",
"progrec", "estrec")], 2, thsum))
table(GBSG2$menostat)
table(GBSG2$tgrade)
table(GBSG2$horTh)
# pooled Kaplan-Meier
mod <- survfit(Surv(time, cens), data=GBSG2)
# integrated Brier score
sbrier(Surv(GBSG2$time, GBSG2$cens), mod)
# Brier score at 5 years
sbrier(Surv(GBSG2$time, GBSG2$cens), mod, btime=1825)
# Nottingham prognostic index
GBSG2 <- GBSG2[order(GBSG2$time),]
NPI <- 0.2*GBSG2$tsize/10 + 1 + as.integer(GBSG2$tgrade)
NPI[NPI < 3.4] <- 1
NPI[NPI >= 3.4 & NPI <=5.4] <- 2
NPI[NPI > 5.4] <- 3
mod <- survfit(Surv(time, cens) ~ NPI, data=GBSG2)
plot(mod)
pred <- c()
survs <- c()
for (i in sort(unique(NPI)))
survs <- c(survs, getsurv(mod[i], 1825))
for (i in 1:nrow(GBSG2))
pred <- c(pred, survs[NPI[i]])
# Brier score of NPI at t=5 years
sbrier(Surv(GBSG2$time, GBSG2$cens), pred, btime=1825)
Run the code above in your browser using DataLab