Ask Mallard
Analysis method

Cox regression with time-varying covariates

4 min read

Cox regression with time-varying covariates uses each person’s covariate value known just before each event time.

Fit

When to use it, and when not to

Use it when

  • Exposure or another predictor changes during follow-up, and dated measurements are available.
  • You want an association between the current recorded covariate and the event hazard.

Not when

Before you start

What you need

Decide these first
  1. Start-stop intervalsSplit follow-up where a covariate changes. Store the value known before each interval’s event.
  2. Dated covariates and eventsSpecify same-day ordering and any lag. Do not use future measurements.
  3. The target associationtargetState whether changing covariates are exposures, confounders or predictors.
It rests on these
  1. Loss to follow-up is unrelated to future events among people with the same recorded factors.How to check: Record why follow-up ended. Assess how results change if those lost have a worse outlook.
  2. Different people supply independent observations.How to check: For patients grouped within clinics or families, use inference that accounts for those groups.
  3. Missing covariates are handled under a stated assumption.How to check: Under missing at random, impute using observed predictors of missingness and outcome. If missingness is not at random, use delta or tipping-point sensitivity analyses.
  4. Covariate values do not use future outcome information.How to check: Audit treatment starts, measurement dates and interval endpoints.
  5. A constant coefficient describes the covariate effect on log hazard.How to check: Time-varying covariates do not remove proportionality assumptions. Model a time interaction if the coefficient itself changes.

Plain language

How it works

Represent follow-up as intervals whose covariate values stay fixed until the next update. At each event time, the Cox model compares current values among people still at risk. Rows are intervals, not extra participants. State the endpoint convention so a treatment recorded at the event cannot silently precede it.

The method in steps
Split follow-up at covariate changes. Then use value known before each event. Then estimate current-value hazard association.Cox regression with time-varying covariatesSplit follow-up atcovariate changesUse value known beforeeach eventEstimate current-valuehazard associationChanging covariate values does not make their coefficient vary with time. Ordinary adjustment can bebiased under treatment-confounder feedback. A Kaplan-Meier curve that censors a competing event overstatescumulative incidence when read as one minus survival.
Conceptual diagram. It shows the structure of the idea, not data from any study.
Reading and reporting the result

Fisher and Lin explain time-dependent covariates and their limits. Cortese and Andersen study the extra problems of prediction with internal covariates, such as changing health status. Future internal values are unknown, so a fitted hazard association does not automatically give a patient survival curve. Lee and colleagues develop an extension for nonlinear effects; ordinary time-varying Cox still requires a justified effect shape.

Worked example

A worked example

Invented for illustration
Setting
A patient enters at month 0, starts treatment at month 4 and has the event at month 12.
Question
Which exposure status belongs to each part of follow-up?
Approach
Create one untreated interval ending at month 4 and one treated interval ending at month 12. Mark the event only on the treated interval.
Result
The patient contributes 4 untreated months and 8 treated months, for 12 months in total.
What it means
Counting all 12 months as treated would assign treatment to time before it began. Splitting fixes that timing error, not confounding.

In practice

Recent studies PubMed search · not vetted

Searching PubMed…

Watch out

Common mistakes

The one to remember

Changing covariate values does not make their coefficient vary with time. Ordinary adjustment can be biased under treatment-confounder feedback. A Kaplan-Meier curve that censors a competing death or another event overstates cumulative incidence when read as one minus survival.

  • Filling earlier intervals with the last measured biomarker.Instead: Use only information available before each event; future values create look-ahead bias.
  • Claiming split follow-up solves treatment-confounder feedback.Instead: Use a causal method built for feedback when that is the target problem.

Inside Mallard

How Mallard uses this

Learn search lists Cox regression with time-varying covariates. The method registry links this method to its single-method article and code.

Code example in Mallard: Cox regression with a time-varying exposure (cox-time-varying-exposure).
Atlas node analysis.cox_time_varying, the id a plan cue records.
Code for this method
Loading…

Related Learn pages

Related designs and methods

Evidence

Sources & further reading

  1. Partial-linear single-index Cox regression models with multiple time-dependent covariates. (opens in a new tab) · BMC Med Res Methodol · doi 10.1186/s12874-024-02434-9
  2. Competing risks and time-dependent covariates. (opens in a new tab) · Biom J · doi 10.1002/bimj.200900076
  3. Time-dependent covariates in the Cox proportional-hazards regression model. (opens in a new tab) · Annu Rev Public Health · doi 10.1146/annurev.publhealth.20.1.145
Source records, titles, authors, years and available DOIs checked against PubMed on 2026-11-06. Prepared with AI assistance; no independent professional approval is claimed. Lee and colleagues develop and simulate Cox models with multiple time-dependent covariates. Cortese and Andersen develop prediction strategies and limits for internal time-dependent covariates. Fisher and Lin is an overview, not counted as a primary development paper.
Last source review: 2026-11-06
AI-generated educational content
Mallard uses reputable methodological and reporting sources, but this material may contain errors or omit important context. Verify important methodological decisions with the cited sources and, when appropriate, a qualified research methodologist or statistician.