I'm trying to understand how to interpret the hazard ratio of time-varying covariates, returned by lifelines.CoxTimeVaryingFitter.

Following the example on their page, I have the following data:

   start  var1  var2  stop  id  event
0      0   0.1   0.0   5.0   1  False
1      5   0.1   1.4   9.0   1  False
2      9   0.1   1.2  10.0   1   True
3      0   0.5   0.0   5.0   2  False
4      5   0.5   1.6  12.0   2   True

and then I fit the CoxTimeVaryingFitter and print the summary:

ctv = CoxTimeVaryingFitter(penalizer=0.1)
ctv.fit(base_df, id_col="id", event_col="event", start_col="start", stop_col="stop", show_progress=True)

And I get:

model   lifelines.CoxTimeVaryingFitter
event col   'event'
penalizer   0.1
number of subjects  2
number of periods   5
number of events    2
partial log-likelihood  -0.36
time fit was run    2024-02-29 17:47:28 UTC

         coef   exp(coef)   se(coef)    coef lower 95%  coef upper 95%  exp(coef) lower 95% exp(coef) upper 95% cmp to  z   p   -log2(p)
var1    -3.27   0.04    4.60    -12.28  5.74    0.00    312.29  0.00    -0.71   0.48    1.07
var2    -0.26   0.77    1.78    -3.74   3.23    0.02    25.20   0.00    -0.15   0.88    0.18

Partial AIC 4.71
log-likelihood ratio test   0.67 on 2 df
-log2(p) of ll-ratio test   0.49

My question is how to interpret the HR of each covariate. Why is it a single value? Shouldn't the hazard ratios be a function of time? If it is indeed a single value, how to interpret it, given that the covariate is changing over time?

Thank you


1 Answer 1


A standard Cox survival regression model, even with time-varying covariate values, makes the implicit assumption that the hazard of an event at any time is related only to the values of the covariates in place at that time. The association of a covariate's values with outcome is assumed independent of time.

That's why you only have single coefficient estimates and HRs for each of your 2 variables: their associations with outcome are assumed to be constant in time. As the variables are modeled linearly in terms of log-hazard, each coefficient is the change in log-hazard for a 1-unit change in the variable. The corresponding HRs are just the exponentiations of the coefficients.

It is possible to model time-varying coefficients (and hazard ratios) in an extension of Cox model, but that's not what's done in the function you cite.


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.