# Textbook approach to modeling non-proportional hazards in the Cox model

In Cox models with time varying coefficients, the effect of covariates on the hazard is allowed to change through time. In cases where a coefficient has a linear relationship with time, I am aware of at least two text books (this one and an Appendix to that one) that advocate for the following model, first in R code:

coxph(Surv(time, death) ~ disease + disease:time)


And now in mathematical notation: $$h(t|X) = h_0(t) \exp(\beta_1X + \beta_2X_T)$$ Where $h(t|X)$ is the instantaneous hazard rate at time $t$ given covariates $X$; $h_0(t)$ is the baseline hazard rate; and $T$ is the censoring or event times. $\beta_1$ represents the log hazard ratio for individuals with $T=0$ (which is sort of nonsensical since you can't have $T=0$ in the data), while $\beta_2$ is harder to interpret... $\beta_2$ shows how the log hazard ratio depends on censoring/event times, but that is circular because event times are also the response variable (this point is made in Terry Therneau’s vignette “Using Time Dependent Covariates and Time Dependent Coefficients in the Cox Model”).

According to Therneau's vignette, to correctly specify a time varying coefficient, you need to use the following model, first in R code:

coxph(Surv(time, death) ~ disease + tt(disease), tt=function(x,t,...){x*t})


And now in mathematical notation: $$h(t|X) = h_0(t) \exp(\beta_1X + \beta_2X_T)$$

The difference is that the time interaction is with $t$ in the model rather than with the event times $T$ in the data. The resulting parameters are easy to interpret: they are the intercept and slope of the linear relationship between the log hazard ratio of $X$ and time. This approach seems like the proper way to model a time varying effect.

Can anyone justify or advocate for the first approach to modeling non-proportional hazards in the Cox model? If it is really incorrect (as I suspect it is), what are the practical consequences of using this approach?

• "𝛽1 represents the log hazard ratio for individuals with 𝑇=0" being "nonsense" is a point that Therneau repeatedly makes. That is why when he made a basehaz function to deliver a baseline hazard, he use the hazard for a case with covariates at their mean value. – DWin Aug 21 '19 at 18:57

Like Maarten said, Therneau's explanation is correct and probably the first book refers to what he mentioned. It is though an interesting thought experiment to see what would happen in the wrong model (with $T$ in it).

If $T$ is indeed the final time, that is completely wrong, as the hazard at time $t<T$ would depend on a future censoring time. By conditioning on the future, the model is pretty much nonsensical, because the probability of dying at a time $t<T$ is 0, so the estimated hazard rate is not really a hazard rate, it is something more complicated. It is a nice thought exercise though.

But say you believe that what you estimate is indeed the hazard, and include $T$ in the expression for the hazard. We can agree that, on average, individuals who live longer (large $T$) are at a lower risk than individuals who live less (low $T$). So it is likely that $T$ itself will explain a large part of the randomness in the model which is in fact not explained.

Imagine that the real hazard function is always increasing in time. Because those who die later have larger values of $T$, the estimated hazard will be "dragged down" towards 0.

Now imagine a 0/1 covariate which increases the hazard (individuals with 1 are at a higher risk than those with 0). Since $T$ depends on this covariate, we can reverse this relationship and think that the covariate value depends on $T$. The effect of the two is then confounded, and it is likely that the regression coefficient for our covariate is biased towards 0.

The fallacies of including covariates which depend on the future and treat them as known at $t=0$ are numerous. A popular term for this is immortality bias and there are many interesting reads out there about it.

I have neither book here, but I suspect that the authors first split their data at each time point where an observation experienced the event. So they have multiple rows per observation, and that $T$ refers to the end of these spells, not the final time in which the observation either experienced the event or not.

• Ah. You are correct. In both examples, the data is in person-period format. That makes sense. – Slow loris May 10 '16 at 14:10
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.8985595703125, "perplexity": 558.4698778084986}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-16/segments/1585371876625.96/warc/CC-MAIN-20200409185507-20200409220007-00318.warc.gz"}