I’m currently undertaking individual participant data meta-analysis evaluating the predictive performance of a continous variable (X) and incidence of tuberculosis.
The goal is to plot the predicted cumulative risk of TB vs levels of X so that to show how quantitative values of X predict the risk of TB.
I would like to use mixed effects cox-regression with time-to TB incidence as an outcome and X as exporsure using restricted cubic splines with random effects.
I found mlrcs package but it cannot be used for Cox and it seems rcs in Hmisc cannot be used with mixed effects cox regression.
How can I use RCS for for a continous variable with random effects in cox regression with R?
For random effects Cox models use the coxme function in the R survival package.
Functions like rcs for regression splines generate a matrix of basis functions, and all regression modeling packages in R that I know of will let you put matrix effects into models. You’ll get the right coefficients and standard errors. If not using the rms package you just won’t get easy predicted values, effect measures, and plots for the splined predictor.
Thank you! Is it then OK to write the code as follows by using rcs only for the fixed term?
fit<-coxme(Surv(studytime, activetb) ~ rcs(X,c(a,b,c))+(0+X|study), data = df)
Is it possible to use rms for multi-level regression models? It doesn’t seem so as far as I understand from the manual.