Time-varying covariates are predictor variables in a regression model whose values are not fixed at baseline but change over the follow-up period. Unlike fixed covariates such as sex or birth year, these dynamic predictors—like repeated blood pressure readings, cumulative drug dosage, or disease progression markers—require extended Cox models or landmark analysis to correctly capture their temporal relationship with the event of interest.
Glossary
Time-Varying Covariates

What is Time-Varying Covariates?
Predictor variables whose values change over the observation period, requiring specialized statistical methods to avoid immortal time bias in survival analysis.
Standard survival models that treat time-dependent variables as fixed introduce immortal time bias, a critical flaw where future exposure status is incorrectly assigned to past survival time. Proper handling requires structuring data in a counting process format with (start, stop] intervals, enabling the hazard at time t to depend only on covariate values observed up to that moment, preserving the causal temporal ordering essential for valid inference.
Key Characteristics of Time-Varying Covariates
Time-varying covariates are predictor variables whose values change over the observation period, requiring specialized statistical methods to avoid immortal time bias and accurately capture dynamic risk relationships.
Definition and Core Mechanism
A time-varying covariate is a predictor whose value is not fixed at baseline but can change during follow-up. Unlike time-fixed covariates (e.g., sex, birth year), these variables capture dynamic patient states such as repeated lab measurements, medication adherence patterns, or disease progression markers. In survival analysis, they require data restructuring into a counting process format where each subject contributes multiple rows corresponding to intervals where covariate values remain constant. The hazard at time t is modeled as a function of the covariate value at that exact moment, not its baseline value.
Internal vs. External Covariates
Time-varying covariates are classified into two fundamental types that dictate analytical approach:
-
Internal (Endogenous) Covariates: Generated by the subject themselves and require the subject to be alive to be measured. Examples include CD4 count in HIV patients, tumor size in cancer studies, or blood pressure readings. Their existence is conditional on survival, creating complex dependencies.
-
External (Exogenous) Covariates: Determined independently of the subject's survival status. Examples include air pollution levels, calendar time, or treatment assignment in a crossover trial. These can be further subdivided into fixed, defined, and ancillary external covariates.
Immortal Time Bias
Immortal time bias is a critical error that occurs when time-varying exposures are mishandled as fixed baseline variables. Consider a study comparing survival between patients who receive a transplant versus those who do not. Patients must survive long enough to receive the transplant—this waiting period is immortal time. If the transplant variable is coded as a fixed baseline characteristic, the survival time before transplantation is incorrectly attributed to the transplant group, artificially inflating its apparent benefit. Proper handling using time-dependent Cox models or landmark analysis eliminates this bias by classifying person-time before and after the exposure separately.
Extended Cox Model Specification
The extended Cox proportional hazards model accommodates time-varying covariates by modifying the hazard function:
h(t|X(t)) = h₀(t) × exp(β₁X₁ + β₂X₂(t))
Where X₂(t) represents a covariate that changes over time. The model assumes that the effect of the covariate is instantaneous and that the proportional hazards assumption holds for the time-varying effect. Implementation requires data in counting process (start, stop] format, where each row represents an interval with constant covariate values. Software implementations in R (survival::coxph) and Python (lifelines) support this structure natively.
Landmark Analysis Approach
Landmark analysis is an alternative to time-dependent Cox models that avoids complex data restructuring. The method:
- Selects a specific landmark time (e.g., 6 months after diagnosis)
- Excludes patients who experienced the event or were censored before the landmark
- Uses covariate values measured at the landmark to predict subsequent survival
- Treats all predictors as fixed from that point forward
This approach is intuitive for clinicians and avoids immortal time bias by conditioning on survival to the landmark. However, it discards information from patients who die early and is sensitive to the choice of landmark time. Dynamic landmarking extends this by updating predictions at multiple landmarks.
Joint Modeling Alternative
When time-varying covariates are measured with error or at irregular intervals, joint models for longitudinal and survival data provide a superior framework. These models simultaneously estimate:
- A longitudinal submodel (e.g., linear mixed effects) describing the trajectory of the time-varying biomarker
- A survival submodel (e.g., Cox model) linking the true unobserved trajectory to the hazard
This approach accounts for measurement error and handles endogenous covariates naturally. The association is typically parameterized through the current value, current slope, or cumulative effect of the longitudinal process. Software includes R packages JM and joineRML.
Frequently Asked Questions
Clear answers to common questions about predictor variables that change over time in survival analysis, including how to avoid immortal time bias and choose the right modeling approach.
A time-varying covariate is a predictor variable whose value changes over the observation period for a given subject, in contrast to a time-fixed covariate (like sex or baseline age) which remains constant. Examples include repeated laboratory measurements (e.g., CD4 counts in HIV studies), cumulative drug exposure, or a patient's transplant status that changes mid-study. Standard Cox proportional hazards models assume covariates are fixed at baseline; using a time-varying covariate requires restructuring the dataset into a counting process format where each subject contributes multiple rows corresponding to intervals where the covariate remains constant. This allows the hazard at time t to depend on the covariate value at that exact moment, reflecting the dynamic nature of disease progression and treatment response.
Common Examples in Clinical Research
In longitudinal clinical studies, many patient characteristics change over the observation period. Treating these as static values introduces immortal time bias and distorts hazard ratios. Below are key examples requiring extended Cox models or landmark analysis.
Repeated Laboratory Measurements
Serial biomarker values such as CD4+ T-cell counts, serum creatinine, or tumor marker levels are classic time-varying covariates. A patient's risk profile changes with each new lab result. Using only the baseline value ignores disease progression or treatment response. In the extended Cox model, these are formatted in counting process style with (start, stop] intervals, updating the hazard at each measurement time. This allows the model to capture the dynamic relationship between biomarker trajectory and event risk.
Cumulative Drug Exposure
In pharmacoepidemiology, cumulative dose or duration of treatment changes continuously. A patient on a 6-month course of a cardiotoxic agent has a different risk at month 1 versus month 6. Treating exposure as a baseline binary variable creates immortal time bias—patients must survive long enough to receive the full course. Time-varying analysis segments follow-up into pre-exposure, during-exposure, and post-exposure intervals, accurately attributing events to the correct exposure window.
Disease Progression Status
In oncology trials, disease progression is both a time-varying covariate and a potential endpoint. When analyzing overall survival, progression status acts as an internal time-dependent covariate—it only exists because the patient survived to experience it. Standard Cox regression fails here. Landmark analysis or joint models for longitudinal and survival data are required to avoid conditioning on the future. The covariate is updated at the progression date, splitting the patient's timeline into pre- and post-progression intervals.
Treatment Crossover and Switching
In randomized trials where patients in the control arm may cross over to the experimental treatment upon progression, the actual treatment received becomes time-varying. An intent-to-treat analysis preserves randomization but underestimates the treatment effect. Rank-preserving structural failure time models or marginal structural models with inverse probability weighting are used to estimate the causal effect of treatment while accounting for the time-dependent confounding introduced by crossover decisions.
Transplant or Surgical Intervention
A solid organ transplant or surgical procedure occurring during follow-up fundamentally alters the hazard. In survival analysis of end-stage disease, receiving a transplant is a time-varying covariate. The challenge is that patients must survive to the transplant date, creating waiting-time bias. The covariate is coded as 0 before the procedure and 1 after, with the timeline split at the surgery date. This allows estimation of the post-transplant hazard ratio relative to the pre-transplant baseline.
Adherence and Compliance Metrics
Medication possession ratio (MPR) or proportion of days covered (PDC) are dynamic adherence measures that fluctuate over a study period. A patient with 90% adherence in month 1 may drop to 40% by month 6. Treating adherence as a fixed baseline average misclassifies exposure. Time-varying analysis updates the adherence metric at each refill or assessment window, allowing the model to capture the true relationship between current adherence behavior and clinical outcomes.
Time-Varying vs. Time-Fixed Covariates
Comparison of predictor variable types in survival analysis based on their temporal behavior and modeling requirements
| Feature | Time-Varying Covariates | Time-Fixed Covariates | Mixed Covariates |
|---|---|---|---|
Definition | Predictors whose values change during the observation period | Predictors measured once at baseline and assumed constant | Models incorporating both static and dynamic predictors |
Measurement timing | Repeated assessments at multiple time points | Single measurement at study entry | Baseline plus scheduled follow-up assessments |
Primary model type | Extended Cox model with counting process format | Standard Cox proportional hazards model | Joint models or landmark analysis |
Data structure | Multiple rows per subject (start-stop intervals) | Single row per subject | Combination of wide and long formats |
Handles immortal time bias | |||
Examples | Blood pressure, CD4 count, tumor size, medication adherence | Sex, race, baseline age, genetic variants | Baseline age plus longitudinal biomarker trajectories |
Proportional hazards assumption | Can be assessed via Schoenfeld residuals per interval | Standard Schoenfeld residual test | Requires careful interval-specific diagnostics |
Missing data complexity | High (intermittent missingness, dropout) | Low (single observation) | Moderate to high |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Master the core concepts surrounding time-varying covariates to build robust longitudinal models and avoid common statistical pitfalls.
Immortal Time Bias
A critical source of systematic error that occurs when a period of follow-up time is misclassified or excluded, during which the event of interest cannot occur. In studies with time-varying covariates, subjects who survive long enough to receive a treatment or reach a certain exposure level accrue 'immortal' time. If this time is incorrectly assigned to the treatment group rather than the control group, the treatment appears artificially beneficial. Proper handling via extended Cox models or landmark analysis is essential to prevent this distortion.
Landmark Analysis
A straightforward alternative to complex joint modeling for handling time-varying effects. The method selects a specific landmark time point and analyzes only the subset of subjects still at risk at that moment. Baseline covariates and updated measurements at the landmark are used to predict future survival. This avoids complex mathematical integration but requires careful selection of the landmark and discards events occurring before it. It is particularly useful for evaluating the predictive power of a biomarker measured mid-study.
Counting Process Data Format
The specific data structure required to fit an extended Cox model with time-varying covariates. Instead of one row per subject, the data is split into multiple intervals defined by start and stop times. Each interval captures the constant covariate values during that specific window. This format allows the model to 'check' the status of predictors at every event time, ensuring that the risk assessment is based on the most current information. It is the fundamental engineering prerequisite for dynamic survival analysis.
Internal vs. External Covariates
A fundamental distinction in survival analysis. Internal covariates are generated by the subject themselves and require the subject to be alive to be measured (e.g., CD4 count, blood pressure). Their existence implies survival. External covariates are defined independently of the subject's survival status (e.g., air pollution level, a randomized treatment assignment). This distinction dictates the analytical approach; standard survival models struggle with internal time-varying covariates without specialized techniques like joint modeling to handle their stochastic nature.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us