# Cox plot “spline fit is singular” warning

Hi I get a warning "spline fit is singular, try a small degrees of freedom" when I try to plot the Schoenfeld residuals.

fit <- coxph(Surv(time, status) ~ sex, data)
plot(cox.zph(fit))


and I realize that this might be because a lot of my events (death) occur on the same waves? (I have 5000 participants, 1500 deaths, and the time variable is from 1 to 8)

And as suggested by some people, I tried

plot(cox.zph(fit), df=3)


and this works, but I'm not sure how much I can trust the plot I see here then ...?

The df parameter only sets the complexity of the smooth spline curve drawn on the plot. For example, if you had chosen df=2 you would have obtained a straight line, according to the R manual page for plot.cox.zph; the default is df=4. So your setting of df just gave you the least complicated non-linear smoothed fit of the residuals versus time. To that extent the plot is trustworthy.
First, it looks like your spline curve does show an upward tilt, suggesting that hazards aren't proportional. You don't show the numeric values returned by cox.zph(), but I would guess that for sex the correlation of scaled residuals versus Kaplan-Meier-transformed time is significantly different from the value of 0 expected when proportional hazards holds. (Note that this numeric test provided by cox.zph() is independent of the df value chosen for your display.)