When trying to fit a Cox model to a continuous term we have a problem interpreting the result. When fitting a linear model the hazard ratio is referenced to the mean of the predictor values, and at that point the SE is zero. In comparison, when fitting a spline model this is not the case, and the SE is non-zero at all points and it is therefore not clear what's the reference point for the hazard ratio.
The code below shows the problem -- on the right the linear model shows the SE becoming 0 at the mean (x=0 in this case). However on the left, the spline model has no point where the SE is zero
We think it may be due to the fact that the location of the means of the spline matrix do not coincide, however we couldn't find how to correct the spline matrix to have the means coincide and identify the reference point.
require("Hmisc")
require("survival")
N <- 50
x <- seq(from = -1, to = 1, length.out = N)
par(mfrow = c(1, 2))
# fitting a spline model
xx <- rcspline.eval(x, nk = 4, inclx = TRUE)
y <- rexp(N, exp(2 + 2 * xx[, 1] + 3 * xx[, 2] + 4 * xx[, 3]))
l <- (coxph(Surv(y) ~ xx))
y2 <- predict(l, se.fit = TRUE)
plot(y2$fit ~ xx[, 1], type = "l")
lines(y2$fit + y2$se ~ xx[, 1], type = "l")
lines(y2$fit - y2$se ~ xx[, 1], type = "l")
grid()
# fitting a linear model
y <- rexp(N, exp(2 + 2 * x))
l <- (coxph(Surv(y) ~ x))
y2 <- predict(l, se.fit = TRUE)
plot(y2$fit ~ x, type = "l")
lines(y2$fit + y2$se ~ x, type = "l")
lines(y2$fit - y2$se ~ x, type = "l")
grid()