Cox regression with time-varying covariates
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
- Earlier treatment changes a covariate that also drives later treatment and outcome. Consider a marginal structural model. Read: Choosing an analysis for time-varying treatment
- You only know whether treatment ever occurred, without dates. Reconstruct timing before fitting a time-varying model. Read: Immortal time bias
Before you start
What you need
- Start-stop intervalsSplit follow-up where a covariate changes. Store the value known before each interval’s event.
- Dated covariates and eventsSpecify same-day ordering and any lag. Do not use future measurements.
- The target associationtargetState whether changing covariates are exposures, confounders or predictors.
- 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.
- Different people supply independent observations.How to check: For patients grouped within clinics or families, use inference that accounts for those groups.
- 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.
- Covariate values do not use future outcome information.How to check: Audit treatment starts, measurement dates and interval endpoints.
- 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.
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
- 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
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.
cox-time-varying-exposure).analysis.cox_time_varying, the id a plan cue records.Related Learn pages
Related designs and methods
Evidence
Sources & further reading
- 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
- Competing risks and time-dependent covariates. (opens in a new tab) · Biom J · doi 10.1002/bimj.200900076
- 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