I am working on the Cox survival analysis model with time-dependent covariate, which is a very very common model.

However, in most papers and R packages, I noticed they estimate the parameters of survival model by expanding the time-dependent data as long data (there are multiple rows (time intervals) for each subject), and predict the new data with pre-determined time-dependent path in the same way (as the first answer shown in this link).

My question is, if the time-dependent covariate is a function of time and is predictable, why can't we directly use the analytical method to estimate the parameters. For instance, if $h_i(t)=h_0(t)\exp(\beta_0w+\beta_1X(t))$, where h_0(t) following a specific distribution and X(t) is predetermined, then $S_i(t)=\exp(-\int_0^t h_i(s)ds)$ and the log-likelihood is $\sum_1^n f(t_i)^ {\sigma_i} S(t_i)^{1-\sigma_i}$, where $\sigma_i$ is whether the individual i is right censored. And we use the death or censored time $t_i$ for each individual to estimate. This estimation looks like joint model with longitudinal data and survival data without the random effect, but our longitudinal data is external not internal.

I am sorry for this naive question, but it has been confusing me for a long time.


1 Answer 1


In principle, what you suggest is possible if the functional form of the baseline hazard is known.

A Cox model, however, is fit without any knowledge of the baseline hazard. The fitting just uses the covariate values in place for all individuals at risk at each event time in the data set. It doesn't even take the event times into account except for their order. After fitting the model you can estimate a baseline hazard from the model's results, but that's not available during the initial fitting.

The most practical way to deal even with a predictable time-varying covariate is thus to extend the data set with multiple rows for an individual representing each event time at which the individual is at risk, with the value of the predictable time-varying covariate at that time included. Section 5 of the R time-dependence vignette discusses this situation and shows how to use a tt() function to build this extended data set.

  • $\begingroup$ Thanks for your reply! But I want to analyze the baseline model (as it is important for predict), so, I still have two questions: 1. can I assume the baseline distribution in the above Cox model? as I used to see some papers considering the weibull-cox or loglogistic-cox model. 2. If the answer is no for the previous one, can I switch to AFT model with time-dependent covariate where $S_i(t)=S_0(\int_0^t exp(\beta_0w + \beta_1 X(s))ds)$ and estimate parameters using the same MLE way in the question. $\endgroup$
    – Ellen1230
    Jul 10, 2023 at 13:27
  • $\begingroup$ @Ellen1230 technically, if you assume a baseline hazard function then you aren't building a "Cox model" but rather a parametric proportional hazards (PH) model. I suppose that it should be possible to fit parametric PH or AFT models with a specified functional form for a defined time-varying covariate, but I'm not sure what software implelements that. For a parametric PH model you can always use the long-data format as a fallback, as covariate values in a PH model only matter at event times in the data set. $\endgroup$
    – EdM
    Jul 10, 2023 at 13:53

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.