1

I built a coxph model on training data and I am having trouble in using it for predictions on the validation dataset. I used Surv to build a survival object and used it as the response variable in coxph model. I then used predict to get predictions on both the training and test dataset but at both times it predicted using on training data.

my.surv<-Surv(train$time_to_event, train$event, type="right")

basic.coxph<-coxph(my.surv~train$basin+train$region+train$district_code)
prediction_train<-predict(basic.coxph,train,type="risk")

prediction_test<-predict(object=basic.coxph,newdata=validate,type="risk")

The results of both prediction_train and prediction_test have the same dimensions and are exactly the same, though the training and validation dataset have different dimensions but al the same columns. Any suggestion on what I am doing wrong here?

akrun
  • 874,273
  • 37
  • 540
  • 662
  • 1
    Dont use `$` formulas. Use `coxph(my.surv basin+region+district_code, train)`. If that doesn't work, please create a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – MrFlick Apr 25 '15 at 15:05

0 Answers0