0

I am having difficulty making predictions using coxph.

I wish to learn a Cox PH model on in-sample data and then use the parameters derived on out of sample data as follows:

# learn IS params
model.PH <- coxph(Surv(days.IS, outcome.IS) ~ predictor.IS)

# apply IS params to OOS data to make predictions
predictions.raw <- predict(model.PH, newdata = predictor.OS)

# binarise predictions
predictions.OS <- rep(0,length(predictions.raw))    
predictions.OS[which(predictions.raw>0)]<- 1 

# fit survival model
fittedModel <- survdiff(Surv(days.OS, outcome.OS) ~ predictions.OS)

predictor.IS is of dimensionality Y_1 x D, predictor.OS is of dimensionality Y_2 x D

However, this does not work as the number of elements in predictions.OS is Y_1 NOT Y_2.

What am I doing wrong?

4

1 に答える 1