Dear R-help, I am using R 2.14.1 on Windows 7.
I would like to produce a plot like the attached - although simplified to actual vs. Predicted survival time with distinguishing marks for censored and observed points. I have a dataset and have fitted a Cox model to it. In an attempt to visualise how accurate the model is it would be ideal if I could plot the actual survival times against the predicted survival times. I have been looking on the internet to see if there are ways to do this in R. The only post I found (https://stat.ethz.ch/pipermail/r-help/2009-February/189888.html) that seemed directly relevant suggested that I shouldn't be generating survival times at all. Given that, I was concerned about proceeding but I would like to have access to a plot to make a decision on its usefulness. I appreciate that there are predict.coxph and predict.cph options available to me. My first attempt was as follows: # fit Cox model # coxfita = coxph(Surv(tsecond,seccens)~stroke(smess)+rels(smess)+asleep(smess)+eeg1(smess)+eeg2(smess)+ct1(smess)+ct2(smess)+treat(smess),data=smess) # Find censored and observed groups # messcens <- subset(smess,seccens==1) messobs <- subset(smess,seccens==0) # Obtain predicted survival times # explp <- exp(predict(coxfita,type="lp")) explp2 <- mean(ssmess$tsecond,na.rm=TRUE)*explp smess2 <- data.frame(ssmess,explp2) # Find censored and observed groups # smesscens <- subset(smess2,seccens==1) smessobs <- subset(smess2,seccens==0) # Produce plot # plot(smesscens$explp2,messcens$tsecond,pch=4,col="blue",ylab="Actual Survival Time",xlab="Predicted Survival Time",main="Survival Times",xlim=c(0,3500),ylim=c(0,3500)) points(smessobs$explp2,messobs$tsecond,pch=4,col="red") This leads to the attached plot. It doesn't seem correct though as the predicted times all start over 500 days. Any suggestions would be very welcome. Many thanks, Laura
Actual vs. Survival LJB.pdf
Description: Actual vs. Survival LJB.pdf
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.