Course contentsShow
← Data Science
Lesson 833 of 2,14521. Survival AnalysisFree lesson

Time-Varying Covariates

Extend Cox models to include predictors that change value over the course of follow-up time.

Time-Varying Covariates

What You'll Learn

You'll learn how to extend Cox proportional hazards models to handle predictors that change their values over the course of the follow-up period.

The Core Idea

So far, we've worked with Cox models where covariates stay fixed from the start of observation—like a person's age at diagnosis or their initial treatment group. But in reality, many important factors change over time: a patient's blood pressure fluctuates, employment status shifts, or treatment dosages get adjusted.

Time-varying covariates allow your survival model to reflect these dynamic changes. Instead of saying "What's the hazard for someone with high blood pressure?", you can say "What's the hazard for someone when they have high blood pressure?"

Think of it like tracking someone's risk as they move through different states. If smoking status changes from "smoker" to "non-smoker" at year 3, the model uses "smoker" for the hazard calculation before year 3 and "non-smoker" afterward.

How It Works

The Cox model structure stays similar, but now covariates are functions of time: X(t) instead of just X. The hazard ratio associated with a time-varying covariate reflects the instantaneous effect of that predictor's current value on the hazard at time t.

Your data structure changes too: instead of one row per subject, you typically create multiple rows representing different time intervals where covariate values remain constant. Each interval records the start time, stop time, event status, and covariate values during that period.

When to Use This

Time-varying covariates are essential when the covariate itself is influenced by the passage of time or by events occurring during follow-up—like medication changes, disease progression markers, or employment transitions.

Key Takeaway: Time-varying covariates extend Cox models to handle predictors that change value during follow-up, making your survival analysis reflect the dynamic reality of real-world risk factors.