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 . The baseline hazard stays unspecified and the coefficient keeps its usual meaning. For a single covariate the model is
where is the hazard rate for patient at time , is the baseline hazard, is the covariate value for patient at time , and is the log hazard ratio for a one-unit difference in the current value. Therneau, Crowson and Atkinson give the partial likelihood as
where is the set of patients with an event, is the event time of patient , equals 1 if patient is at risk at and 0 otherwise, and is the value patient held just before . 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.
| Patient | Start (years) | Stop (years) | Event | On drug |
|---|---|---|---|---|
| 1 | 0 | 0.5 | 0 | 0 |
| 1 | 0.5 | 1.8 | 1 | 1 |
| 2 | 0 | 2.0 | 0 | 0 |
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.
where is a covariate whose value changes with time, is a covariate fixed at baseline, is a constant coefficient and 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 equals . 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.
- 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.
- 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.
- 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.
- 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
- Fisher LD, Lin DY. Time-dependent covariates in the Cox proportional-hazards regression model. Annual Review of Public Health. 1999;20:145-157. https://doi.org/10.1146/annurev.publhealth.20.1.145
- Hernán MA, Brumback B, Robins JM. Marginal structural models to estimate the causal effect of zidovudine on the survival of HIV-positive men. Epidemiology. 2000;11(5):561-570. https://doi.org/10.1097/00001648-200009000-00012
- Ibrahim JG, Chu H, Chen LM. Basic concepts and methods for joint models of longitudinal and survival data. Journal of Clinical Oncology. 2010;28(16):2796-2801. https://pmc.ncbi.nlm.nih.gov/articles/PMC4503792/
- Latimer NR, Abrams KR. NICE DSU Technical Support Document 16: Adjusting survival time estimates in the presence of treatment switching. NICE Decision Support Unit; July 2014. https://doi.org/10.15131/shef.data.33847621
- Bell Gorrod H, Latimer NR, Abrams KR. NICE DSU Technical Support Document 24: Adjusting survival time estimates in the presence of treatment switching, an update to TSD 16. NICE Decision Support Unit; April 2024. https://doi.org/10.15131/shef.data.33850897
- Rizopoulos D. JM: an R package for the joint modelling of longitudinal and time-to-event data. Journal of Statistical Software. 2010;35(9):1-33. https://doi.org/10.18637/jss.v035.i09
- Suissa S. Immortal time bias in pharmaco-epidemiology. American Journal of Epidemiology. 2008;167(4):492-499. https://doi.org/10.1093/aje/kwm324
- Therneau T, Crowson C, Atkinson E. Using time dependent covariates and time dependent coefficients in the Cox model. Vignette in the survivalVignettes R package; May 2026. https://github.com/bethatkinson/survivalVignettes/blob/main/vignettes/timedep.qmd
Related Concepts (3)
Library
Tools & Resources
1
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.
Software (R package)View source →
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
