Cox Regression with Time-Varying Covariates

Statistics
Introduced by
Cox, D. R. (extended formulation by Therneau & Grambsch)
Year
1972
Type
Semi-parametric hazard regression model

What does it do?

Time-dependent Cox regression extends the Cox proportional hazards model so that one or more covariates can take different values at different points in a subject's follow-up.

It is fitted in a counting-process (start–stop) data format, which Therneau and Grambsch (2000) describe in detail. It is relevant when a covariate such as a laboratory value, a dose or a severity score changes during follow-up and cannot be represented adequately by its baseline value.

The intuition behind the method

In standard Cox regression every covariate is measured once, usually at baseline, and is assumed to remain constant throughout follow-up. That is reasonable for fixed characteristics such as sex or genotype, but it misrepresents a patient whose biomarker fluctuates, whose treatment is changed mid-study, or whose exposure accumulates over time. Time-dependent Cox regression splits each subject's follow-up into intervals, records the covariate value active during each interval, and fits the Cox model across all intervals together. The hazard at any moment is therefore modelled as a function of the covariate value at that moment rather than its baseline value.

History

The Cox proportional hazards model was introduced by David R. Cox in 1972. Therneau and Grambsch (2000) treat the extension of this model to time-varying covariates in counting-process form, the data structure used by this method, and give practical implementation guidance.

When to use it

Use time-dependent Cox regression when covariates change value during follow-up and cannot be reduced to a single baseline summary without losing information that bears on the hazard. Typical cases include repeated laboratory measurements, time-varying treatment or drug exposure, cumulative exposure metrics, and disease activity scores recorded at visits. If every covariate is fixed at baseline, standard Cox regression is the simpler choice. The data must be restructured into long format, with one row per interval per subject. Adequacy of the model depends on the number of events relative to the number of parameters being estimated and on the number of intervals, not on the number of subjects alone. An events-per-parameter heuristic is commonly used to guide this, but it is not a formal threshold, so the precision and stability of the estimates should be checked for the specific design. The non-informative censoring assumption of standard Cox regression carries over. Do not interpret the coefficient of a covariate causally if that covariate is itself driven by the disease process leading to the event; in that case a joint longitudinal–survival model is usually more appropriate.

Limitations and considerations

  • The model needs start–stop long-format data. Overlapping intervals, misplaced event indicators or misaligned covariate timing can bias the estimates, and the fitting procedure will not necessarily flag these errors.
  • With few subjects or few events relative to the number of parameters estimated, or with many intervals relative to the number of events, the coefficient estimates become unstable. No fixed minimum sample size applies; the events-per-parameter ratio and the stability of the estimates should be examined for the specific design.
  • If a covariate is endogenous, meaning it is generated by the disease process that also drives the event, the estimated hazard ratio does not have a straightforward causal reading and a joint longitudinal–survival model is generally more appropriate.
  • The proportional-hazards assumption for the coefficient β still has to be checked after fitting, for example with Schoenfeld residuals.
  • The model rests on assumptions beyond proportional hazards. The covariate values within each interval must be known from the start of that interval and must not depend on future events. Measurement timing must be aligned with the interval boundaries. The covariate effect must be correctly specified on the log-hazard scale, which can be checked. Censoring must be non-informative.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Each event time is compared against the risk set using the covariate values current at that time, so a covariate that changes during follow-up is not collapsed into a single baseline value.
  • The baseline hazard is left unspecified, as in standard Cox regression, so no parametric shape is imposed on the hazard over time.
  • Right-censoring is handled by the (start, stop] structure: a censored subject contributes risk-set time up to the end of its last interval.
  • Fixed covariates can be included in the same model as time-varying ones by repeating their values in every interval.

Applications

  • Clinical pharmacology: modelling the effect of drug concentration or dose changes occurring during a trial rather than relying on the baseline prescription.
  • Cardiology and oncology: relating time-varying biomarkers (troponin, CA-125, CD4 count) to the risk of a clinical event.
  • Epidemiology: estimating the effect of time-varying occupational exposures or cumulative environmental doses on mortality or disease incidence.
  • Health services research: examining how a change in treatment or care pathway during follow-up affects outcomes.

How it works

How it works

1

The hazard at time t for subject i is modelled as the product of a baseline hazard h₀(t), shared by all subjects and left unspecified, and an exponential function of the covariates measured at time t: h(t | x(t)) = h₀(t) exp(β⊤ x(t)). The coefficients β are estimated by maximising a partial likelihood. At each event time it compares the subject who experienced the event with all subjects still at risk, using each covariate's value current at that event time.

Formula
h(t \mid x(t)) = h_0(t)\exp\!\bigl(\beta^\top x(t)\bigr)
2

To accommodate covariates that change over time, each subject's record is expanded into several rows in long format. Each row covers a time interval (start, stop] during which the covariates are constant. The event indicator is 1 only in the final row, and only if the subject had the event at that stop time; all other rows carry 0. This structure, written as Surv(start, stop, event) in common software syntax, ensures that the correct covariate value enters the partial likelihood at each event time.

Formula
\text{Surv}(\text{start},\, \text{stop},\, \text{event})

Common pitfalls

  • Building the long-format dataset incorrectly (overlapping intervals, wrong event indicators, or covariate values attached to the wrong interval) produces results that look valid but are wrong.
  • Treating an endogenous covariate as exogenous and reading its hazard ratio causally. This requires a joint longitudinal–survival model.
  • Skipping the proportional-hazards check after fitting. Schoenfeld residuals are the standard diagnostic here.
  • Confusing time-varying covariates with time-varying coefficients. The standard model keeps β fixed over time; if a coefficient itself changes with time, a stratified or covariate-by-time interaction approach is needed.
  • Reporting one covariate's effect without stating whether that covariate is internal (endogenous) or external (exogenous) to the outcome process.

Frequently asked questions

What is a time-varying covariate?

A time-varying (or time-dependent) covariate is a predictor whose value is not fixed at study entry but changes during follow-up. Examples include laboratory values measured at each clinic visit, changes in medication, and accumulating exposure levels. Fixed covariates, such as sex or baseline age, take a single value for the whole follow-up.

How does this differ from standard Cox regression?

Standard Cox regression uses one covariate value per subject, measured at baseline, and assumes it stays constant. Time-dependent Cox regression uses the covariate value current at each event time in the partial likelihood. This requires restructuring the data into several rows per subject, one for each interval over which the covariates are constant.

When should I prefer a joint model over time-dependent Cox?

When the time-varying covariate is endogenous, meaning it is part of the biological or disease process that leads to the event, the estimated effect of that covariate can be biased and does not support a straightforward causal reading. A joint model describes the longitudinal trajectory of the biomarker and the survival process together, accounting for their dependence, and is generally the better choice in that situation.

How do I structure my data for this model?

Expand each subject's follow-up into one row per interval during which all covariates remain constant. Each row needs a start time (the left endpoint, excluded from the interval), a stop time (the right endpoint, included), and an event indicator. The indicator is 1 only in the last row if the subject had the event at the stop time; all other rows have 0.

Related methods

Sources

  1. Therneau, T. M. & Grambsch, P. M. (2000). Modeling Survival Data: Extending the Cox Model. Springer.

    Open DOI reference