Model assumptions
You already had a look at the Cox PH model in the last coding exercise. In this exercise, you are going to find out if your model is appropriate at all. Your model is still stored in the object fitCPH
.
Este exercício faz parte do curso
Machine Learning for Marketing Analytics in R
Instruções do exercício
- Check the proportional hazard assumption of the model
fitCPH
usingcox.zph()
. Store the test result in an object calledtestCPH
and print it. - The assumption seems to be violated for one variable at the 0.05 alpha level. Which one? Plot the coefficient beta dependent on time for this variable.
- Validate the model using cross validation in the
validate()
function from therms
package.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Check proportional hazard assumption and print result
___ <- ___(fitCPH)
___(testCPH)
# Plot time-dependent beta
plot(___, var = "___")
# Load rms package
library(rms)
# Validate model
___(fitCPH, method = "___",
B = 10, dxy = TRUE, pr = FALSE)