Beruflich Dokumente
Kultur Dokumente
Note that, when used inappropriately, statistical models may give rise to
misleading conclusions. Therefore, it’s important to check that a given
model is an appropriate representation of the data.
Contents
Here, we’ll disscuss three types of diagonostics for the Cox model:
install.packages(c("survival", "survminer"))
library("survival")
library("survminer")
We’ll use the lung data sets and the coxph() function in the survival
package.
Call:
coxph(formula = Surv(time, status) ~ age + sex + wt.loss, data = lung)
coef exp(coef) se(coef) z p
age 0.02009 1.02029 0.00966 2.08 0.0377
sex -0.52103 0.59391 0.17435 -2.99 0.0028
wt.loss 0.00076 1.00076 0.00619 0.12 0.9024
Likelihood ratio test=14.7 on 3 df, p=0.00212
n= 214, number of events= 152
(14 observations deleted due to missingness)
For each covariate, the function cox.zph() correlates the corresponding set
of scaled Schoenfeld residuals with time, to test for independence between
residuals and time. Additionally, it performs a global test for the model as
a whole.
Call:
coxph(formula = Surv(time, status) ~ age + sex + wt.loss, data = lung)
coef exp(coef) se(coef) z p
age 0.02009 1.02029 0.00966 2.08 0.0377
sex -0.52103 0.59391 0.17435 -2.99 0.0028
wt.loss 0.00076 1.00076 0.00619 0.12 0.9024
Likelihood ratio test=14.7 on 3 df, p=0.00212
n= 214, number of events= 152
(14 observations deleted due to missingness)
rho chisq p
age -0.0483 0.378 0.538
sex 0.1265 2.349 0.125
wt.loss 0.0126 0.024 0.877
GLOBAL NA 2.846 0.416
From the output above, the test is not statistically significant for each of
the covariates, and the global test is also not statistically significant.
Therefore, we can assume the proportional hazards.
ggcoxzph(test.ph)
In the figure above, the solid line is a smoothing spline fit to the plot, with
the dashed lines representing a +/- 2-standard-error band around the fit.
For example:
Martingale residuals may present any value in the range (-INF, +1):
Summary
We described how to assess the valididy of the Cox model assumptions
using the survival and survminer packages.
Infos
This analysis has been performed using R software (ver. 3.3.2).
Enjoyed this article? I’d be very grateful if you’d help it spread by emailing
it to a friend, or sharing it on Twitter, Facebook or Linked In.
Show me some love with the like buttons below... Thank you and please
don't forget to share and comment below!!
Get involved :
Click to follow us on Facebook and Google+ :
Machine Learning Essentials:
Practical Guide in R Comment this article by clicking on
"Discussion" button (top-right position of this
page)