I have two independent datasets one with 5421 and the other 1000 subjects. What I would like to do is validate the Cox model obtained from the main dataset (main_dat, n=5421) using the external dataset (test_dat, n=1000). However, I get an error message using both rcorr.cens() in the Hmisc package and val.surv in rms. Here is what I have been doing:
library(rms)
surv.obj=with(main_dat,Surv(survival,surv_cens)) ## to use with rcorr.cens
phmodel=cph(surv.obj~sex+age+treatment, x=TRUE, y=TRUE, surv=T, time.inc=10, data=main_dat, se.fit=T)
estimates=survest(phmodel, newdata=test_dat, times=10)
rcorr.cens(x=estimates, S=surv.obj)
Error in rcorr.cens(x = estimates, S = surv.obj) : y must have same length as x
w=val.surv(phmodel ,newdata=test_dat, u=10)
Error in val.surv(phmodel, newdata = test_dat, u = 10) : dims [product 1000] do not match the length of object [5421] In addition: Warning message: In est.surv + S[, 1] : longer object length is not a multiple of shorter object length
Am I doing something wrong or the two datasets must have same number of observations?
Any help will be greatly appreciated.