I am trying to get the concordance for my testing dataset using the following code:
library(survival)
s=1116
set.seed(s)
train = sample.int(N, trainsize, replace = F)
traindata = mor_survey_com3[train, ]
test = mor_survey_com3[-train, ]
fit_test_w = coxph(as.formula(Surv(permth_exm, other_Death) ~ BMI_c + BMI_c_2 +
as.factor(smoke) + lspline(Hgb,14)),data=traindata)
concordance(object = fit_test_w, newdata = test)
However, I got the following error:
Error in (function (y, x, strata, weights, ymin = NULL, ymax = NULL, timewt = c("n", : x and y are not the same length
Does anyone know what is going on here?