Hello I would like to perform restricted cubic spline (Cox adjusted) after multiple imputation with mice.I use rms package. but after imputation when I use the function datadist
I get this message (Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 'x' must be atomic.)
I'm using the following code.
Multiple imputation
`Mydata<- mice::mice(cohort,seed = 123, print = FALSE,m=5)
# Converting data and performing restricted cubic spline
d<-datadist(Mydata)
options(datadist="d")
k<-with(Mydata,quantile(tg,c(.05,0.25,0.75,0.95)))
fit<- cph(Surv(time, cvd) ~ rcs(tg, k)+covariates, data=Mydata)
myplot <- Predict(fit,tg, ref.zero = TRUE, fun=exp)
ggplot(dataplot,aes(tg, yhat)) + geom_line(colour="blue", linetype="solid", size=1)+geom_hline(yintercept =1, linetype="dashed")`
Any guidance.
Thank you in advance.