Tutorials › Multiple Imputation by Chained Equations (MICE) › Lagged Covariates and Exposure Histories

Survival and Time-Varying Data · Tutorial 400 of 497

Lagged Covariates and Exposure Histories

Learn to construct time-aligned lagged covariates and concise summaries of prior exposure histories for survival analyses and repeated-measure imputation.

Advanced 12 min read

What You'll Learn

  • Distinguish a fixed-time lag from the most recently observed measurement.
  • Define prior exposure summaries using explicit time windows and endpoint rules.
  • Align derived values with start-stop risk intervals and event times.
  • Recalculate derived variables from imputed source values in each completed data set.
  • Recognize structural absence, missing measurements, and temporal misalignment.
  • Diagnose implausible lags and histories before fitting a survival model.

Why the Timing of a Covariate Matters

In a survival analysis, a covariate attached to a person-period record must describe information available for that person at the time represented by the record. A measurement made after that time cannot be used as if it were known earlier. This is particularly important when a person’s treatment or exposure changes during follow-up, or when covariates are measured intermittently.

A lagged covariate refers to an earlier value of a variable, with the lag defined by a time rule. A prior exposure summary condenses information about exposure before a specified prediction time, often over a stated window. These are distinct constructions: a lag may select one earlier value, while a summary may combine several earlier observations or describe whether exposure occurred during a prior period.

The central design decision is not just what to calculate, but which records are eligible to contribute. State the prediction time, the lag or look-back window, and the treatment of measurements at the boundary before calculating anything.

Definition: Let \(X_i(s_{ij})\) be a covariate measured for subject \(i\) at time \(s_{ij}\), and let \(t\) be the prediction time. A fixed-time lag of length \(L>0\) is \(X_i(t-L)\), when a measurement exists at exactly \(t-L\). A prior-history summary is a specified function of exposure information recorded before \(t\), often restricted to a window such as \([t-w,t)\). If no measurement exists at the required time, the lag is unavailable; it is not automatically equal to the last observed value.

Time Indexing and the Information Boundary

For start-stop survival data, subject \(i\) may contribute one or more records for intervals \([a_{ik},b_{ik})\), during which the subject is at risk. A covariate used for the interval beginning at \(a_{ik}\) should be defined from information available by that prediction time under a clear convention. A conservative convention is to use measurements with timestamps strictly less than \(a_{ik}\). If a measurement taken exactly at \(a_{ik}\) is available before the interval’s risk prediction is made, it may instead be included, but that ordering must be justified and used consistently.

Write \(\mathcal{F}_{i,t-}\) for the information about subject \(i\) recorded strictly before time \(t\). A valid prior-history covariate \(Z_i(t)\) is a function of that information: \(Z_i(t)\) is determined by \(\mathcal{F}_{i,t-}\). This is sometimes described as a predictable covariate. The idea is simple: at a risk time \(t\), the model may condition on the past, not on a future observation whose value would not yet be available.

For example, a time-dependent Cox model can be written as

$$ \lambda_i(t\mid \mathcal{F}_{i,t-})= \lambda_0(t)\exp\{\beta Z_i(t)\}. $$

Here \(\lambda_0(t)\) is the baseline hazard and \(\beta\) is a log hazard ratio per unit of \(Z_i(t)\). Interpreting this as a proportional-hazards model requires the proportional-hazards specification to be suitable and the covariate history to be aligned correctly with risk time. The temporal construction does not itself establish those modeling assumptions; it ensures that the covariate does not use unavailable future information.

Worked Example: A Fixed Seven-Day Lag

Suppose a hypothetical participant has blood pressure recorded at days 0, 7, 14, and 21, with values 128, 132, 126, and 134 mmHg, respectively. Risk intervals begin at days 14 and 21. Define a seven-day fixed lag using a measurement exactly seven days before each interval start.

At the start of the interval on day 14, the lag time is \(14-7=7\) days. The recorded value is \(X_i(7)=132\) mmHg. Thus the covariate for this interval is 132 mmHg.

At day 21, the lag time is \(21-7=14\) days. The value is \(X_i(14)=126\) mmHg, so the lagged covariate is 126 mmHg. This calculation does not use the day-21 value of 134 mmHg.

The rule is valid for these records because the required measurements exist at the specified times and precede their prediction times. If the day-14 measurement had not been collected, the day-21 fixed seven-day lag would be unavailable under this definition; replacing it with the day-7 value would change the rule.

Fixed Lags Are Not the Same as “Last Observed” Values

Measurements in practice are often irregular. Two different constructions are easily confused:

  • Fixed-time lag: select the value measured at a specified time before \(t\), such as \(t-7\) days. If no such measurement is available, the lag is unavailable.
  • Most-recent-prior value: select the value at the latest measurement time strictly before \(t\). The elapsed time between that measurement and \(t\) can vary across records.

The second construction can be useful, but it must be named and its maximum acceptable age considered. It is not equivalent to a fixed lag. Treating the most recent value as current without qualification can conceal long gaps between measurement and prediction. The earlier material on why last observation carried forward fails in survival data explains why automatically carrying a value forward is not a general solution to missing or intermittent measurements.

Worked Example: Irregular Measurements and a Prior-Window Summary

For a hypothetical patient, exposure status was recorded as 1 (exposed) or 0 (not exposed) on days 2, 5, 9, and 12, with values 1, 0, 1, and 1. At a prediction time of day 10, define the prior-8-day exposure summary as the proportion of recorded visits in \([10-8,10)=[2,10)\) with exposure status 1.

The eligible measurements are on days 2, 5, and 9. Their exposure values sum to \(1+0+1=2\), and there are three eligible visits. Therefore,

$$ \text{prior-window proportion at day 10} =\frac{1+0+1}{3} =\frac{2}{3} =0.667. $$

This is a proportion of recorded visits in the specified window, not the proportion of elapsed time exposed. The day-12 record is excluded because \(12\not<10\). If visits are more frequent during exposure, the visit-based proportion may not represent time-weighted exposure; a different summary would be needed for that scientific target.

Constructing Prior-Exposure Summaries

A history summary is interpretable only when its inputs and time window are explicit. Examples include an indicator of any exposure during the previous 30 days, the number of recorded exposed visits in a prior window, or the mean of a measured exposure over eligible earlier observations. These summaries answer different questions. For instance, “any exposure in the prior month” does not retain frequency or intensity, while the number of exposed visits depends on the measurement schedule.

A general form for a window-based summary is

$$ H_i(t;w)=g\{E_i(s_{ij}):t-w\leq s_{ij}<t\}, $$

where \(E_i(s_{ij})\) is an exposure record, \(w>0\) is the look-back duration, and \(g\) is the prespecified summary function. The left endpoint is included and the prediction time is excluded in this convention. Other endpoint rules are possible, but changing them can change the result when a measurement occurs exactly on a boundary.

Do not label an arbitrary summary “cumulative exposure” unless its units and construction truly represent accumulated exposure. For example, a count of exposed visits is measured in visits, whereas a time-weighted exposure integral would combine exposure level and duration. Constructing time-updated cumulative exposures requires additional choices about the exposure process and is a separate task.

Worked Example: Any Exposure in a Prior Window

A hypothetical study records whether a participant received a treatment on days 3, 8, 13, and 18. The values are 0, 1, 0, and 1. For an interval starting on day 16, define \(H_i(16;10)=1\) if at least one treatment record is positive in \([6,16)\), and 0 otherwise.

The records in the window are day 8 with value 1 and day 13 with value 0. Day 3 is earlier than the lower boundary, and day 18 is after the prediction time; neither contributes. Because at least one eligible value is 1,

$$ H_i(16;10)=\mathbb{1}\{\max(1,0)=1\}=1. $$

The summary says that treatment was recorded at least once in the preceding ten days. It does not say that treatment was continuous, nor does it quantify dose or duration. That interpretation follows from the defined rule, not from the numerical value alone.

Derived Histories in Multiple Imputation

When a lag or history summary is calculated from a covariate that has missing values, it should normally be derived after that source variable has been imputed in each completed data set. If a missing source value is imputed differently across completed data sets, the corresponding lag or summary should reflect that uncertainty and can differ as well. For a deterministic rule, calculate the derived variable from the completed source values rather than imputing a separate, unconstrained version of the derived variable.

This requires the imputation and analysis data to preserve the subject identifier, measurement time, interval boundaries, and the agreed timing rule. A derived value can be wrong even when every imputed value is plausible if rows have been sorted incorrectly, linked to the wrong subject, or assigned to the wrong risk interval.

Worked Example: Recomputing a Lag in Each Completed Data Set

Suppose a hypothetical participant has a day-4 covariate measurement of 5 units, a missing day-9 measurement, and an observed day-14 measurement of 8 units. The prediction time is day 14, and the defined lag is the immediately preceding scheduled measurement at day 9. In two completed data sets, the imputed day-9 value is 6 units in the first and 7 units in the second.

In the first completed data set, the lag at day 14 is the completed day-9 value, 6 units. In the second, it is 7 units. The observed day-14 value of 8 units is not used as its own lag; it occurs at the prediction time under the strict-before convention.

Thus the derived lag varies across the completed data sets in the same way as its imputed source. If the day-9 value were missing in the original data but the analysis instead used the day-4 value without defining a fallback rule, the result would silently change from a scheduled one-visit lag to a more distant observation. That is not a valid substitute for the specified construction.

Checks, Alternatives, and Failure Modes

Before using derived histories in a survival model or an imputation model, check their construction against the actual timestamps. The following checks often reveal errors that a model-fitting command will not detect:

  • For every record, verify that each contributing measurement belongs to the same subject and satisfies the time-window rule.
  • Check whether any lag or summary uses a measurement at or after its prediction time.
  • Tabulate the age of the measurement used for a most-recent-prior value; unusually old values may indicate gaps or mistaken carry-forward.
  • Check the number of eligible measurements per window. A visit-based mean based on one visit has a different precision and interpretation from one based on many.
  • Distinguish an undefined lag because no scheduled prior measurement exists from a scheduled measurement that is missing. These have different meanings and should not automatically receive the same treatment.
  • Inspect values at interval starts, event times, censoring times, and window boundaries to confirm the endpoint convention was applied consistently.

The main alternatives serve different scientific aims. A contemporaneous covariate uses information current at the prediction time, if it is actually available then. A fixed lag targets a value at a defined earlier time. A most-recent-prior value accommodates irregular timing but may have variable age. A window summary compresses several earlier records and may be less sensitive to one noisy measurement, at the cost of discarding detail. A full time-varying history retains more information but can require more modeling and more complete measurement histories.

No construction repairs a poorly timed measurement process. A prior-window average of sparse, selectively observed records can be biased as a representation of the underlying exposure. A fixed lag may be unavailable for many subjects. A summary may discard the pattern of change that matters for the outcome. These choices should be justified by the scientific question and the data-collection schedule, and reported so the meaning of each covariate is reproducible.

Key takeaway: Define the prediction time first, then specify exactly which earlier timestamps may contribute and how they are combined. A lag or history is valid only if its construction respects that temporal boundary and its interpretation matches the chosen rule.

Check Your Understanding

Answer each question using the stated time rules. Solutions follow the questions.

  1. A fixed three-day lag is required at day 12. Measurements are available at days 7, 9, and 10. Which measurement supplies the lag, if any?
  2. At day 20, define an “any exposure in the previous five days” indicator using \([15,20)\). Exposure values are 1 on day 15, 0 on day 18, and 1 on day 20. Calculate the indicator.
  3. Explain why a prior-window proportion of exposed visits is not necessarily the proportion of time exposed.
  4. A time-varying source covariate is imputed in multiple completed data sets. Should its deterministic lag be independently imputed once, or recomputed in each completed data set? Explain.
  5. For a record starting at day 30, a supposed prior-history summary uses a day-31 measurement. Identify the problem and state the general correction.

Solutions. (1) The required time is \(12-3=9\), so use the day-9 measurement. The day-10 value is not the specified fixed lag. (2) The eligible records are days 15 and 18; day 20 is excluded because the window ends at 20. Since at least one eligible value is 1, the indicator is 1. (3) The calculation weights each recorded visit equally, not each unit of elapsed time; irregular visit frequency can therefore change the visit proportion without changing the fraction of time exposed. (4) Recompute the deterministic lag in every completed data set from that data set’s completed source values, preserving the uncertainty in the imputed source. (5) Day 31 is after the prediction time and is unavailable at day 30. Restrict the history to records satisfying the prespecified prior-time rule, such as timestamps strictly less than 30.

Clinical Biostats