Time-varying covariates are variables whose values change during follow-up — blood pressure readings, biomarker levels, treatment switches, or disease progression markers. The standard Cox model assumes covariates are fixed at baseline, but extending it to time-varying covariates uses the counting process formulation, where each subject contributes multiple intervals of observation with updated covariate values. The hazard at any moment depends on the current covariate value at that moment: h(t|X(t)) = h_0(t) × exp(beta × X(t)). This extension raises the critical issue of immortal time bias when the time-varying covariate is defined by a future event (e.g., receiving a transplant), and requires careful distinction between external covariates (determined outside the failure process) and internal covariates (generated by the subject, potentially informative about prognosis).
The standard Cox model treats all covariates as measured once at baseline and fixed throughout follow-up. But many clinically important variables change over time: a patient's blood pressure is monitored repeatedly, treatment may be switched, biomarkers rise and fall. Ignoring these changes means the model uses stale information — a patient whose cholesterol was 200 at baseline but rose to 350 by year 3 is still modeled as having cholesterol 200. The extended Cox model with time-varying covariates addresses this by allowing covariate values to update during follow-up.
The implementation uses the counting process formulation. Instead of one row per subject with a single entry-to-event time, the data are restructured so each subject contributes multiple rows, one per interval during which their covariates are constant. A patient observed from 0 to 5 years whose treatment changes at year 2 contributes two intervals: (0, 2] with the original treatment and (2, 5] with the new treatment. At each event time in the partial likelihood, the risk set includes all subjects under observation with their current covariate values. The mechanics of partial likelihood maximization are unchanged — only the data structure differs.
The most important pitfall is immortal time bias, which arises when a time-varying covariate is defined by a future event that requires survival. The classic example is organ transplantation: patients who eventually receive a transplant must survive the waiting period. If these patients are classified as "transplanted" from study entry, their pre-transplant survival is guaranteed (immortal time) and incorrectly attributed to the transplant's benefit. The correct analysis treats transplant as a time-varying covariate that switches from 0 to 1 at the actual transplant date, ensuring that the waiting period contributes to the untransplanted group.
A subtler issue is the distinction between external and internal time-varying covariates. External covariates (ambient temperature, policy changes, calendar time) exist independently of the subject. Internal covariates (biomarkers, symptoms, disease stage) are generated by the subject's own biological process and are informative about prognosis in ways that create feedback loops. A rising tumor marker both predicts and is part of the disease process leading to death. When internal covariates are measured with error or at irregular intervals, the extended Cox model can produce biased estimates, motivating the development of joint longitudinal-survival models.