Skip to content
Prev 58444 / 398502 Next

time dependency of Cox regression

If you fit a Cox model with the fixed covariate, plot(cox.zph(model)) will 
show you an estimate of how the log hazard ratio changes over time, with 
pointwise confidence intervals.

If you want more precise estimates and confidence intervals you can split 
up your covariate into a set of time-dependent covariates.

If you wanted a time period for each year up to 6 years you would make 6 
time dependent covariates, looking like

  x 0 0 0 0 0
  0 x 0 0 0 0
  0 0 x 0 0 0
  0 0 0 x 0 0
  0 0 0 0 x 0
  0 0 0 0 0 x

and have (up to) six records per person.  The survSplit() function in the 
survival package will do the splitting, you then need to set the 
appropriate terms to zero and fit the model.

 	-thomas