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?

  • $\begingroup$ "𝛽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. $\endgroup$
    – DWin
    Aug 21, 2019 at 18:57

2 Answers 2


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.

  • $\begingroup$ Ah. You are correct. In both examples, the data is in person-period format. That makes sense. $\endgroup$
    – SlowLoris
    May 10, 2016 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.