Author-reviewedEvidence: highv1.0.2

Time-Varying Covariate

A time-varying covariate is a predictor in a survival model, such as drug use or a biomarker level, whose value is updated during follow-up.

Status
Published, version 1.0.2
Last reviewed
1 Nov 2026, by Dr Darrin Baines
Report a problem
Tell us if something is wrong or out of date

Concept Architecture

Time-Varying Covariate in Survival Analysis and Economic Models

In a time-to-event analysis, a time-varying covariate lets the hazard at each moment depend on a patient's current value of a predictor, such as whether a drug has been started yet or the latest kidney function result, instead of the value recorded at entry. Also called time-dependent covariates, they suit the Cox proportional hazards model because its partial likelihood compares patients at each event time using the values they held just before it. Health economists meet them in observational estimates of drug benefit, in adjustment for treatment switching in cancer trials and in risk equations for patient-level simulation. Correct coding avoids immortal time bias. A model fitted with them does not give a survival curve by itself, which matters whenever the result has to feed a cost-effectiveness model.

How a changing covariate enters the hazard

The extended Cox model replaces each fixed covariate with its value at time tt. The baseline hazard stays unspecified and the coefficient keeps its usual meaning. For a single covariate the model is

hi(t)=h0(t)exp⁡{βXi(t)}h_i(t) = h_0(t)\exp\{\beta X_i(t)\}

where hi(t)h_i(t) is the hazard rate for patient ii at time tt, h0(t)h_0(t) is the baseline hazard, Xi(t)X_i(t) is the covariate value for patient ii at time tt, and β\beta is the log hazard ratio for a one-unit difference in the current value. Therneau, Crowson and Atkinson give the partial likelihood as

PL(β)=∏i∈Dexp⁡{βXi(ti)}∑jYj(ti)exp⁡{βXj(ti)}PL(\beta) = \prod_{i \in D} \frac{\exp\{\beta X_i(t_i)\}}{\sum_{j} Y_j(t_i)\exp\{\beta X_j(t_i)\}}

where DD is the set of patients with an event, tit_i is the event time of patient ii, Yj(ti)Y_j(t_i) equals 1 if patient jj is at risk at tit_i and 0 otherwise, and Xj(ti)X_j(t_i) is the value patient jj held just before tit_i. They liken each term to a lottery in which every patient at risk holds tickets in proportion to the risk score. The covariate must therefore be known for every patient at risk at every event time, and between measurements the last known level is carried forward. Therneau and colleagues state the underlying condition as none of the covariate, the at-risk indicator or the event count depending on the future, which they summarise as the rule that the analysis cannot look into the future.

Splitting follow-up into intervals

Software fits the model to data in counting-process form. Each row holds a start time, a stop time, an indicator for whether the interval ends in the event and the covariate values that apply over the interval, which is open on the left and closed on the right. A patient who starts a drug at 0.5 years and dies at 1.8 years contributes two rows, as in this illustrative layout.

PatientStart (years)Stop (years)EventOn drug
100.500
10.51.811
202.000

Therneau and colleagues note that the extra rows do not create correlated data, because the likelihood at any time point uses only one copy of each patient, and that overlapping intervals for one patient are almost always a data error.

External, internal and predictable covariates

The distinction drawn by Kalbfleisch and Prentice between external and internal covariates decides what such a model can be used for. Rizopoulos, citing them, states that standard time-to-event models require a time-dependent covariate to be external, meaning its value at a given time is not affected by an event that occurred earlier. A biomarker measured repeatedly on the patient usually fails that test, because such measurements are generated by the patient and directly related to the failure mechanism. A patient who has died has no further laboratory results.

Fisher and Lin warn that the interrelationships between outcome and covariate over time can lead to bias unless they are well understood. They add that a Cox model with time-dependent covariates cannot usually be used to predict the survival curve, because the probability of an event over time is not related to the hazard in the usual fashion. A survival curve then needs a model for how the covariate itself evolves, which is what a joint model supplies.

Some covariates have future values fixed in advance, and Therneau and colleagues give attained age and the cumulative dose of a drug taken on a fixed schedule as examples. When age enters a Cox model as a linear term, current age and age at baseline give the same partial likelihood because the shared increment cancels, although the cancellation fails if the effect of age is non-linear.

Covariates, coefficients and hazards that change over time

Three ideas share the words time-varying and are often confused. Therneau and colleagues write the two extensions of the Cox model side by side.

h(t)=h0(t)exp⁡{βX(t)}h(t)=h0(t)exp⁡{β(t)X}h(t) = h_0(t)\exp\{\beta X(t)\} \qquad h(t) = h_0(t)\exp\{\beta(t) X\}

where X(t)X(t) is a covariate whose value changes with time, XX is a covariate fixed at baseline, β\beta is a constant coefficient and β(t)\beta(t) is a coefficient that changes with time. In the second model a baseline covariate has an effect that changes over follow-up, which is one way to handle a failure of the proportional hazards assumption, since that assumption is precisely that β(t)\beta(t) equals β\beta. A time-varying hazard is a third idea, the event rate itself rising or falling with time whatever the covariates.

Immortal time and analyses by response or dose

The most damaging errors arise when a status reached during follow-up is treated as known at baseline. Suissa defines immortal time as a span of cohort follow-up during which, because of the exposure definition, the outcome could not occur, and traces the bias to 1970s cohort studies of the survival benefit of heart transplantation. A patient classed as a recipient at enrolment must have lived long enough to receive the organ. Therneau and colleagues show the remedy with the Stanford heart transplant data, coding transplant as a time-dependent covariate so that each patient counts as on medical treatment until the transplant.

Suissa reports that the bias in the rate ratio from misclassified or excluded immortal time increases in proportion to its duration and is more pronounced when the hazard of the outcome falls over time. Therneau and colleagues show its size by declaring a random 5% of lung cancer patients responders at each monthly visit. A Cox model comparing responders with non-responders gave a hazard ratio of 1.9 with a p-value below 1 in 1000, although response was pure chance.

Analysis by dose received fails in a similar way. In a breast cancer chemotherapy example the authors discuss, patients grouped by the share of planned dose they eventually received showed a strong dose effect because early deaths cannot finish their cycles, and the recommended approach codes cumulative dose to date as a time-dependent covariate. A landmark analysis is the other common remedy and gives a simple conditional comparison at a fixed time.

Worked example with a drug started during follow-up

All numbers in this example are illustrative. A registry follows patients with a chronic condition, and 300 of them start a new drug exactly 0.5 years after entry. The drug has no effect, and the death rate is 0.20 per person-year whether or not a patient is taking it.

1. Tabulate person-time. Before starting, the later users contribute 300 × 0.5 = 150 person-years with no deaths, since each had to survive to start. After starting they contribute 450 person-years and 90 deaths. Patients who never start contribute 1,500 person-years and 330 deaths, including patients who died too early to start.

2. Correct time-varying analysis. Untreated person-time is 1,500 + 150 = 1,650 person-years with 330 deaths, a rate of 330 / 1,650 = 0.200. Treated person-time gives 90 / 450 = 0.200. The rate ratio is 0.200 / 0.200 = 1.00, the true null effect.

3. Immortal time misclassified. Counting users as treated since entry puts all 150 + 450 = 600 of their person-years in the treated group, giving 90 / 600 = 0.150 against 330 / 1,500 = 0.220 for never-users. The rate ratio is 0.150 / 0.220 = 0.682, a spurious reduction of about 32%.

4. Immortal time excluded. Starting the users' clock at the drug start gives 90 / 450 = 0.200 against 0.220, a rate ratio of 0.200 / 0.220 = 0.909. The bias is smaller but remains, because the never-user group keeps the early deaths of patients who would have started had they lived.

5. Consequence in an economic model. With constant hazards the rate ratio equals the hazard ratio and mean survival is one divided by the hazard. On standard care the hazard of 0.20 gives 1 / 0.20 = 5.00 years. The misclassified ratio gives a hazard of 0.20 × 0.682 = 0.136 and mean survival of 7.33 years, a gain of 2.33 undiscounted life years per patient. The excluded-time ratio gives 0.20 × 0.909 = 0.182 and 5.50 years, a gain of 0.50.

6. Interpretation. Only the time-varying analysis finds no benefit. A model built on the misclassified estimate would credit an ineffective drug with more than two life years per patient, and every QALY and ICER derived from it would carry the same error.

Time-dependent confounding and treatment switching

Ordinary adjustment fails when a time-varying covariate predicts both the outcome and later treatment and is itself affected by earlier treatment. Hernán, Brumback and Robins state that the time-dependent Cox model may then give biased effect estimates, and they propose marginal structural models estimated by inverse probability of treatment weighting. In their study of zidovudine in HIV-positive men, CD4 count played both roles. The crude mortality rate ratio was 3.6, adjustment for baseline covariates gave 2.3, and the marginal structural Cox model, which also controlled for time-dependent confounding, gave 0.7 (95% conservative confidence interval 0.6 to 1.0).

The same structure appears in appraisals of cancer drugs when control-arm patients switch to the new treatment after progression. NICE Decision Support Unit Technical Support Document (TSD) 16 describes inverse probability of censoring weights as a type of marginal structural model, fitted to data recorded at regular intervals, that needs data on all baseline and time-dependent prognostic factors for mortality that independently predict switching. TSD 24, its 2024 update, asks analysts to state the portion of data used in the switching model, including time-varying predictors, and to describe how missing data on those predictors were handled. IPCW therefore depends on the trial recording these covariates at each visit, unlike the randomisation-based methods described under treatment switching.

Carrying the estimates into a decision model

A cost-effectiveness model needs lifetime survival curves, which a hazard ratio alone does not provide. For an external covariate with a known path, such as attained age, the hazard can be recomputed at each cycle or event. An internal covariate needs a model of its own path, and a joint model provides one by linking the marker trajectory and the event in a single likelihood.

A patient-level microsimulation or discrete event simulation can update each simulated patient's risk factors and recompute the hazard, provided the model also predicts how those risk factors change. In a partitioned survival model the curves are fitted directly, so time-varying covariates matter only through how those curves were estimated.

Limitations and common misreadings

Most errors come from information that was not yet available when the covariate value is used. Others come from reading the coefficient too broadly.

  1. Interpolating between visits. Therneau and colleagues class linear interpolation of a missing bilirubin value as immortal time bias, since it uses a later reading. A valid value is one that could have been filled in on the day.
  2. Reverse causality near the event. A value recorded just before death may mark an event already under way. The authors re-run analyses with a 7 to 14 day lag on key variables and investigate any substantial change.
  3. Reading the coefficient as a causal effect. When the covariate is affected by earlier treatment, conditioning on it can bias the treatment effect, as the zidovudine example shows. Confounding of this kind needs weighting or other causal methods.
  4. Treating measured values as exact. Ibrahim, Chu and Chen state that entering error-prone repeated measures directly into a Cox model gives highly biased, typically attenuated, and inefficient estimates of the treatment effect. Measurement error of this kind is one reason to fit a joint model.

Sources

Library

Tools & Resources

1
  • Other

    survHE — Survival Analysis for Health Economic Evaluation (R package) — Gianluca Baio, R package ed., 2023 (CRAN)

    An R package for fitting and comparing parametric survival models for health economic evaluation, including Bayesian estimation, and for extrapolating time-to-event data to inform cost-effectiveness models.

Frequently Asked Questions (7)

  • What is a time varying covariate?

    A time-varying covariate is a predictor in a survival model, such as drug use or a biomarker level, whose value is updated during follow-up.

    Source: Fisher & Lin 1999

  • What changing predictor variable is a time-varying covariate?

    Any predictor in a survival model can be treated this way when its value is allowed to change during a patient's follow-up, such as whether a drug has been started or the latest kidney function result. The hazard at each moment then depends on the current value of that time-varying covariate instead of the value recorded at entry. Fisher and Lin note that its form is more complex than that of a fixed covariate in a Cox model, because it involves constructing a function of time. They also warn that such covariates must be used with caution.

    Source: Fisher & Lin 1999

  • What is a time-varying covariate?

    In survival analysis, a time-varying covariate is an explanatory variable whose value is updated over follow-up and enters the hazard at its current value. Rizopoulos, citing Kalbfleisch and Prentice, separates external covariates, whose value at a given time is not affected by an earlier event, from internal ones generated by the patient and directly related to the failure mechanism. A repeatedly measured biomarker is usually internal, since a patient who has died has no further laboratory results. Standard time-to-event models require the external kind, and internal markers are often analysed with a joint model instead.

    Source: Rizopoulos 2010

  • How are time-varying covariates handled in survival models?

    In survival software, an extended Cox model replaces each patient's baseline value of a time-varying covariate with its value at time t, leaving the baseline hazard unspecified. Data are arranged in counting-process form, with one row per interval holding a start time, a stop time, an event indicator and the covariate values that apply over that interval. A patient who starts a drug partway through follow-up therefore contributes one row before starting and one after. Therneau and colleagues note that these extra rows do not create correlated data, and between measurements the last known value is carried forward.

    Source: Therneau et al. 2026

  • What are examples of time-varying covariates?

    Treatment status is the most frequent case, as when a registry patient starts a new drug months after entry or a heart transplant candidate later receives an organ. Repeated laboratory measures such as creatinine or bilirubin are another time-varying covariate, with the last known value carried forward between visits. Therneau and colleagues also give attained age and the cumulative dose of a drug taken on a fixed schedule as covariates whose future values are fixed in advance. Cumulative chemotherapy dose to date is the coding they recommend when patients are compared by the dose they received.

    Source: Therneau et al. 2026

  • Why use time-varying covariates?

    The main reason is that coding a status reached during follow-up as if it were known at baseline creates immortal time bias. Suissa defines immortal time as a span of follow-up during which, because of the exposure definition, the outcome could not occur, and traces the problem to early cohort studies of heart transplantation. He shows that the bias from misclassified or excluded immortal time grows in proportion to its duration and is larger when the hazard falls over time. Coding exposure as a time-varying covariate counts each patient as unexposed until exposure begins, which removes that spurious benefit.

    Source: Suissa 2008

  • What pitfalls arise with time-varying covariates?

    Fisher and Lin warn that the interrelationships between outcome and covariate over time can lead to bias unless they are well understood. A time-varying covariate that is itself affected by earlier treatment, such as CD4 count in HIV, is one source of that bias, because conditioning on it can distort the estimated treatment effect. They also note that a Cox model with time-dependent covariates cannot usually be used to predict the survival curve. That limit matters in cost-effectiveness work, because a decision model needs lifetime survival curves and a hazard ratio alone does not provide them.

    Source: Fisher & Lin 1999

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 1 Nov 2026

Content version: 1.0.2

Canonical Identity

Term code
HE-EM-SM-087

Stable URI · Machine-readable · Resolvable · CC BY 4.0