Case study: Fitting a penalized one-dimensional spline as random effect in coxme

A colleague recently asked me how to fit a spline with a point constraint in a Cox proportional hazards (PH) model for left-truncated data (i.e., with delayed entry). I found that mgcv::cox.ph cannot be used for this, as it requires the response to be specified as a time variable and a 0/1 event/weight variable (for right censoring), rather than a multi-column Surv object that describes interval censoring. I quickly looked into other ways to estimate a penalized spline from the mgcv framework, and since a penalized spline can be rewritten as a random effect I needed to find another package that could estimate mixed Cox PH models, with a Surv object describing the response (which allows for left-truncation). One package fulfilling those criteria is coxme, which also support a ridge regression shrinkage for variables, which we will see is especially well suited for estimating penalized splines in a random effect setting. This case study will show how to replicate a standard right-censored mgcv::cox.ph model using coxme. The same coxme code can then be applied to interval-censored data by simply changing the Surv object.

Read More