vokey588
2012-Jul-17 14:13 UTC
[R] Building a web risk calculator based on Cox PH--definitive method for calculating probability?
Hello all, I am a medical student and as a capstone for my summer research project I am going to create a simple online web "calculator" for users to input their relevant data, and a probability of relapse within 5 years will be computed and returned based on the Cox PH model I have developed. The issue I'm having is finding a definitive method/function to feed the user's "newdata" and return the probability of relapse within 5 years. I have googled this and the answers seems to be inconsistent; I have variously seen people recommend survest(), survfit(), and predict.coxph(). Terry had a useful answer r.789695.n4.nabble.com/how-to-calculate-predicted-probability-of-Cox-model-td4515265.html here but I didn't quite understand what he meant in his last sentence. Here is some code for you to quickly illustrate what you suggest. library(rms) library(survival) library(Hmisc) data(veteran) dd=datadist(veteran) options(datadist='dd') options(digits=4) obj=with(veteran,Surv(time,status)) vetcoxph=coxph(obj~celltype+trt,data=veteran) #I will fit models from both the survival and rms packages so you can #use what you like vetcph=cph(obj~celltype+trt,data=veteran,surv=TRUE,time.inc=5*365,x=T,y=T) #let's say the user inputted that their cell type was smallcell and their treatment was "1". userinput=data.frame(celltype='smallcell',trt=factor(1)) I really appreciate your recommendations Best, Jahan -- View this message in context: r.789695.n4.nabble.com/Building-a-web-risk-calculator-based-on-Cox-PH-definitive-method-for-calculating-probability-tp4636749.html Sent from the R help mailing list archive at Nabble.com.