Tutorials › Nonlinear Mixed-Effects Models (NLME) › Time-Varying Covariates in Survival Models

Categorical, Count and Time-to-Event Responses · Tutorial 448 of 797

Time-Varying Covariates in Survival Models

Construct event-time predictors from covariate histories without using information observed after the event, and account for risk sets and delayed entry in mixed-effects survival likelihoods.

Advanced 10 min read

What You'll Learn

  • Define predictable time-varying covariates and specify how their values apply at an event time.
  • Split follow-up into intervals that preserve the observed covariate history and risk sets.
  • Derive the event-time likelihood contribution for a piecewise-constant predictor.
  • Distinguish a valid covariate update from leakage of post-event information.
  • Condition the random-effects distribution appropriately when subjects have delayed entry.
  • Recognize when a conditional covariate-history model may need a joint model.

Why Covariate Timing Matters

A survival model can use more than characteristics measured once at baseline. Dose, treatment status, biomarker level, or organ function may change while a subject remains at risk. The key is to align each value with the time period in which it was known and relevant. A value recorded after an event cannot explain that earlier event, and a person contributes to a risk set only during the period they are observed and event-free.

In a mixed-effects survival model, this timing rule applies within each subject as well as across subjects. The covariate history determines the time-specific predictor; the subject-specific random effect accounts for latent heterogeneity. Neither changes the need to construct the event-time likelihood from the correct risk period.

Definition: A time-varying covariate \(x_i(t)\) is a covariate whose value may change over follow-up for subject \(i\). It is predictable for an event process if the value used at time \(t\) is determined by information available immediately before \(t\), written \(x_i(t-)\). A covariate is often represented as piecewise constant: its value is fixed within each interval between recorded updates.

Hazard Model and Event-Time Likelihood

Let \(T_i\) be the event time, \(\delta_i=1\) if the event is observed and \(\delta_i=0\) if follow-up is right-censored, and \(b_i\) the subject-specific random-effects vector. A common conditional proportional-hazards specification is

$$ \lambda_i(t\mid b_i,x_i(t-)) = \lambda_0(t)\exp\{\beta^\mathsf{T}x_i(t-)+z_i^\mathsf{T}b_i\}, \qquad H_i(t\mid b_i)=\int_0^t\lambda_i(u\mid b_i,x_i(u-))\,du . $$

Here \(\lambda_0(t)\) is the baseline hazard, \(\beta\) is the fixed-effects coefficient vector, and \(z_i\) specifies how the random effects enter. The hazard has units of inverse time; the exponent is dimensionless. Conditional on the random effects and covariate history, the event-time contribution for a subject observed from time zero is

$$ L_i(b_i)= \{\lambda_i(T_i\mid b_i,x_i(T_i-))\}^{\delta_i} \exp\{-H_i(T_i\mid b_i)\}. $$

An observed event contributes the hazard at its time as well as survival up to that time. A censored subject contributes survival through the censoring time but no event hazard factor. These contributions assume that censoring is noninformative conditional on the variables and random effects in the model, and that the specified conditional hazard adequately represents the event process.

Suppose \(x_i(t)=x_{ik}\) on the interval \([a_{ik},a_{i,k+1})\). The cumulative hazard is the sum of the interval-specific integrated hazards. The event hazard uses the covariate value just before the event, including when the event occurs exactly at a recorded update time: the ordering convention must be stated, and information not yet available at that instant is excluded.

Why Interval Splitting Works

Writing one row per subject with a single covariate value discards changes during follow-up. Instead, represent follow-up with start-stop intervals. Split a subject’s observed time at each covariate update, entry time, event time, and censoring time as needed. Each interval records the subject’s current covariate value and the time during which they are actually at risk.

The likelihood follows directly from conditional survival. On an interval where the predictor is constant, survival over that interval is the exponential of minus its integrated hazard. Multiplying these survival terms across successive intervals adds their cumulative hazards. If an event occurs at the end of an interval, its hazard factor uses the predictor on the interval immediately preceding the event.

$$ \begin{aligned} H_i(T_i\mid b_i) &=\sum_k \int_{a_{ik}}^{a_{i,k+1}} \lambda_0(u)\exp\{\beta^\mathsf{T}x_{ik}+z_i^\mathsf{T}b_i\}\,du,\\ L_i(b_i) &=\{\lambda_i(T_i\mid b_i,x_i(T_i-))\}^{\delta_i} \exp\left\{-\sum_k\int_{a_{ik}}^{\min(T_i,a_{i,k+1})} \lambda_i(u\mid b_i,x_{ik})\,du\right\}. \end{aligned} $$

This is a calculation over one subject’s continuous follow-up, not a product of independent event records. Splitting a record into rows is a bookkeeping device for integrating the hazard over the correct intervals; it does not create extra subjects or independent observations.

Worked Example: An Updated Treatment Indicator

Consider a hypothetical subject followed from month 0 to an event at month 5. Treatment status is 0 from month 0 to month 2 and 1 from month 2 to month 5. Suppose the baseline hazard is constant at \(0.020\) per month, there is no random effect for this calculation, and the treatment coefficient is \(\beta=\log(2)\). Thus treatment doubles the hazard while status is 1.

The interval hazards are \(0.020\) per month before month 2 and \(0.020\exp\{\log(2)\}=0.040\) per month afterward. The cumulative hazard through month 5 is

$$ H(5)=(0.020)(2)+(0.040)(3)=0.040+0.120=0.160. $$

The event occurs during the status-1 interval, so the event hazard is \(0.040\) per month. The conditional likelihood contribution is

$$ L=(0.040)\exp(-0.160)=0.03409\ \text{per month}. $$

The contribution has units of inverse time because it includes an event density. Using status 1 for the entire five months would instead give cumulative hazard \(0.200\), incorrectly assigning the later treatment status to the first two months.

Risk Sets Must Follow Observation Time

At an event time, the risk set contains subjects who have entered observation and are still event-free and under observation immediately before that time. A covariate update changes a subject’s predictor; it does not itself add or remove the subject from the risk set. Delayed entry means a subject contributes no observed risk time before entry. Censoring and events end that subject’s risk-period contribution.

The start-stop representation makes this explicit: each row covers only a period in which the subject is observed and at risk, and its covariate value is the value for that period. If a risk-set calculation is used, include only subjects in that set at the event time, with their values immediately before it.

Worked Example: Updating Predictors Without Changing the Risk Set

In a hypothetical study, subject A enters at month 0, changes from status 0 to status 1 at month 2, and has an event at month 4. Subject B enters at month 1, remains at status 0, and is censored at month 6. Subject C enters at month 3, has status 1 from entry, and has an event at month 5. At month 4, all three are observed and event-free immediately beforehand, so the risk set is A, B, and C.

Suppose the baseline hazard at month 4 is \(0.010\) per month, the status coefficient is \(\log(2)\), and random effects are set to zero for this illustration. Immediately before month 4, A and C have status 1 and B has status 0. Their hazards are therefore

$$ \lambda_A(4)=0.010(2)=0.020,\qquad \lambda_B(4)=0.010,\qquad \lambda_C(4)=0.010(2)=0.020 \quad \text{per month}. $$

The summed hazard over this risk set is \(0.020+0.010+0.020=0.050\) per month. Under these hazards, A’s instantaneous share of the total event rate is \(0.020/0.050=0.400\). This is a rate share, not a claim that A has a 40% probability of an event over a finite interval. A’s status update at month 2 changes their hazard, but does not create a new subject or a new risk-set membership.

Random Effects and Delayed Entry

For a population of subjects with random-effects density \(f(b)\), the usual marginal likelihood integrates each subject’s conditional contribution over that density. This integration must reflect how the subject entered the observed sample. If subjects enter at time \(L_i\) only after surviving to \(L_i\), their random effects among entrants are generally not distributed as \(f(b)\): subjects with random effects associated with longer survival are more likely to have survived to entry.

Let \(S_i(L_i\mid b)\) be the conditional probability of surviving to entry, given the covariate history and random effects. The random-effects density among entrants is

$$ f(b\mid T_i>L_i)= \frac{f(b)S_i(L_i\mid b)} {\int f(b')S_i(L_i\mid b')\,db'}. $$

Thus the post-entry conditional contribution is integrated against this entry-conditioned density. Equivalently, integrate the post-entry contribution multiplied by \(S_i(L_i\mid b)\) against \(f(b)\), then divide by the marginal probability of surviving to entry. Integrating the post-entry contribution against the unconditioned population distribution is valid only if that distribution already describes entrants or the entry mechanism otherwise justifies it. The survival-to-entry term must use the relevant pre-entry covariate history.

Worked Example: Selection of Random Effects at Entry

Suppose, hypothetically, that a frailty multiplier \(m\) is 0.5 or 2.0 with equal population probability. Before delayed entry, the cumulative baseline hazard is 1.0, so conditional survival to entry is \(\exp(-m)\). The unnormalized entrant weights are \(0.5\exp(-0.5)=0.3033\) for \(m=0.5\) and \(0.5\exp(-2)=0.06767\) for \(m=2.0\). Their sum is \(0.3709\), giving entrant probabilities approximately \(0.8176\) and \(0.1824\), respectively.

Suppose the post-entry baseline cumulative hazard to an observed event is 0.20 and the baseline hazard at the event time is \(0.10\) per month. For a given multiplier \(m\), the post-entry event contribution is \(0.10m\exp(-0.20m)\). For \(m=0.5\), this is \(0.050\exp(-0.10)=0.04524\) per month; for \(m=2.0\), it is \(0.200\exp(-0.40)=0.1341\) per month.

Using the entrant probabilities, the entry-conditioned marginal contribution is approximately

$$ (0.8176)(0.04524)+(0.1824)(0.1341)=0.06145\ \text{per month}. $$

Using the original equal population weights instead would give \((0.5)(0.04524)+(0.5)(0.1341)=0.08965\) per month. The discrepancy arises because survival to entry selected more subjects with the lower frailty multiplier. This example assumes no additional covariate changes and illustrates why delayed entry affects the random-effects integration as well as the observed risk period.

Assumptions, Alternatives, and Failure Modes

A time-varying-covariate likelihood is meaningful only when its data construction and observation assumptions are defensible. In particular:

  • The covariate value used at each time must be known just before that time. A value measured after an event must not be carried backward to predict it.
  • Update times and event times must share a clear time scale, and the rule for updates coincident with events must be specified.
  • Subjects contribute only during observed, event-free periods. Delayed entry, censoring, and any event must be represented at their correct times.
  • The conditional hazard and random-effects distribution must be adequate for the intended likelihood. If the covariate process is informative about latent event risk beyond the included history and random effects, treating its observed path as fixed may be inadequate; a joint model for covariate and event processes may be needed.

A baseline-only model is simpler and may be appropriate when the scientific predictor is a baseline characteristic or when time-updated measurements are unavailable. It cannot represent changes in the predictor during follow-up. Last observation carried forward is one possible way to define a piecewise-constant history between measurements, but it assumes that the last measured value remains an adequate representation until the next measurement. It is not a license to use measurements obtained after the event. A model for the underlying evolving covariate process can be more appropriate when measurements are sparse, noisy, or jointly related to event risk, but it requires additional assumptions and data.

Common construction errors include treating every split row as an independent subject, assigning a post-event value to the event interval, and carrying a time-updated exposure backward to baseline. Another subtle error is forming delayed-entry likelihoods by integrating over the population random-effects distribution without accounting for survival to entry. A practical check is to reconstruct, for each event time, who was under observation and event-free immediately beforehand and which covariate value was then available. If this cannot be answered from the analysis data, the event-time predictor is not yet well defined.

Key takeaway: A time-varying covariate belongs to a specific at-risk interval. Use its predictable value immediately before each event, integrate hazard over the intervals actually observed, and condition random-effects integration on survival to delayed entry when the sampling process requires it.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions below.

  1. A covariate changes at month 3, and an event occurs at month 4. Which value belongs in the event hazard? What does the earlier interval contribute?
  2. A subject is censored at month 6 without an event. Which parts of the conditional likelihood contribution are present?
  3. Why does splitting follow-up at each covariate update not create independent observations?
  4. Under delayed entry, when is it justified to integrate the post-entry likelihood over the unconditioned population random-effects density?
  5. Give one reason that carrying the most recent measured biomarker forward between visits may be inadequate.

Solutions. (1) Use the value available immediately before month 4, which is the value in force after the month-3 update. The earlier interval contributes to cumulative hazard through survival up to month 3 using its own covariate value. (2) The contribution is survival through month 6, \(\exp\{-H_i(6\mid b_i)\}\), with no event hazard factor because \(\delta_i=0\). (3) The rows partition one subject’s observed follow-up so the cumulative hazard can be calculated with the correct predictor in each interval; they remain parts of one subject’s likelihood contribution. (4) It is justified if the distribution used is already the random-effects distribution among entrants, or if the entry mechanism otherwise makes survival-based selection irrelevant. Otherwise use the survival-to-entry weighting and normalization. (5) The biomarker may change substantially between visits, measurements may be noisy, or its unobserved trajectory may be associated with event risk; in such cases the carried-forward value may misrepresent the covariate history.