I made a model with a splined variable.
coxph(Surv(time, DEATH_EVENT) ~ age+anaemia+creatinine_phosphokinase+
ns(ejection_fraction, knots=c(15))+serum_creatinine+hypertension, data=HF)
This is the code I used to check ejection_fraction
's linearity. How can I check its linearity after I've applied a spline?
X <- HF$ejection_fraction
Y <- resid(reducedMod, type = "martingale")
plot(X, Y, pch = 20, col = "darkgray",
xlab = "Ejection Fraction", ylab = "Martingale Residual")+
abline(h = 0) +
lines(smooth.spline(X, Y, df = 7), lty = 2, lwd = 2)