How can I determine whether one coding of a linear predictor leads to a better fit of the corresponding regression model than the other? In the following example, the restricted cubic spline coding of albumin leads to a higher chi-square value of the resulting model compared to the linear coding. However, it has also more degrees of freedom. As I understand it, I cannot use the log likelihood test in this case, since both models are not nested.
What should I do?
> library(rms) > > data(pbc) > d <- pbc > rm(pbc, pbcseq) > d$status <- ifelse(d$status != 0, 1, 0) > > dd = datadist(d) > options(datadist='dd') > > # linear model > m1 <- cph(Surv(time, status) ~ albumin, data=d) > anova(m1) Wald Statistics Response: Surv(time, status) Factor Chi-Square d.f. P albumin 73.51 1 <.0001 TOTAL 73.51 1 <.0001 > > # rcs model > m2 <- cph(Surv(time, status) ~ rcs(albumin, 4), data=d) > anova(m2) Wald Statistics Response: Surv(time, status) Factor Chi-Square d.f. P albumin 82.80 3 <.0001 Nonlinear 4.73 2 0.094 TOTAL 82.80 3 <.0001
I thought plotting both models would be a good way to decide whether a linear coding or a restricted cubic spline coding would be best. In this case (see below), I would think that the more complex coding is not better. However, the core of my question aimed to reinforce the eyeballing by a statistical test. But as I understand you correct, this is prone to over-fitting?