简体   繁体   中英

restricted cubic spline for crr model (cmprsk)

I'm attempting to make a competing risk survival model using the crr function (cmprsk) in R and through preliminary analysis, I want to transform two of my continuous variables with a restricted cubic spline transformation. Does anyone know of a way to do this akin to the rcs function in the rms package?

You can use the splines package when generating your model.matrix

For example. where cov3 and cov4 are your continuous variables that you would like to transform:

covariates <- model.matrix(~cov1 + cov2 + bs(cov3, ...) + ns(cov4, ...), data = df)[,-1]

model <- with(df, crr(ftime, fstatus, covariates, failcode = 1, cencode = 0))

... can include the various options available to the bs (B-spline) or ns (natural cubic spline) functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM