#### suppose wt.loss is the marker of interest
if(requireNamespace("survival")) {
library(survival)
dat=subset(lung, !is.na(wt.loss) & !is.na(ph.ecog))
f1=Surv(time, status) ~ ph.ecog + age + sex
ss=quantile(dat$wt.loss, seq(.05,.95,by=0.01))
t0=1000
prob = marginalized.risk.threshold(f1, "wt.loss", dat, t = t0, ss=ss)
plot(ss, prob, type="l", xlab="Weight loss (S>=s)",
ylab=paste0("Probability of survival at day ", t0))
}
Run the code above in your browser using DataLab