Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Event Types and Risk Sets in Joint Competing-Risks Data

Competing Risks and Recurrent Events · Tutorial 396 of 697

Event Types and Risk Sets in Joint Competing-Risks Data

Learn to encode two competing event types and censoring correctly, and to construct cause-specific risk sets from longitudinal-survival records.

Advanced 11 min read

What You'll Learn

  • Distinguish the first event of each cause from right censoring and from a missing marker visit.
  • Define observed follow-up time, event-type indicators, and the at-risk set just before an event time.
  • Translate repeated marker measurements and follow-up outcomes into an analysis-ready event history.
  • Determine how a competing event changes later risk-set membership.
  • Check event records for inconsistent times, statuses, ties, and post-event measurements.
  • Compare cause-specific risk sets with simpler single-event coding and recognize their limitations.

Why Event Type and Risk-Set Membership Matter

In a joint longitudinal-survival dataset, repeated marker measurements are linked to a time-to-event record. When more than one type of first event can occur, the event record must say not only when follow-up ended, but also why. For example, a hypothetical patient might experience disease progression, die without prior progression, or remain event-free until the end of observation. These outcomes are not interchangeable: progression and death are competing first events, while the end of observation without either event is censoring.

A cause-specific risk set is the group still under observation and free of every first event immediately before a given time. It is not a group formed by excluding people who will eventually have a different event type. Correctly constructing these records and sets is a necessary data step before fitting or interpreting any competing-risks model.

Definition: In a two-cause first-event setting, let \(T_i\) be subject \(i\)'s time to the first event of either cause, and let \(C_i\) be the censoring time. The observed follow-up time is \(X_i=\min(T_i,C_i)\). Define \(\Delta_i=1\) if the first event is observed by \(X_i\), and \(\Delta_i=0\) if follow-up is censored before an event is observed. When \(\Delta_i=1\), let \(J_i\in\{1,2\}\) identify the event cause; when \(\Delta_i=0\), set \(J_i=0\). The cause-specific event indicator is \(\Delta_{ik}=I(\Delta_i=1,J_i=k)\), for \(k=1,2\).

The two event types are competing events when occurrence of either one prevents the other from being the first event for that subject. This definition concerns the event being analyzed: after a first event of cause 1, the subject can no longer experience cause 2 as a first event, even if later events of other kinds are recorded in a broader clinical record. With complete first-event coding, \(\Delta_i=\Delta_{i1}+\Delta_{i2}\), and at most one of \(\Delta_{i1}\) and \(\Delta_{i2}\) equals 1.

From Longitudinal Records to an Event History

Write the observed longitudinal marker data for subject \(i\) as measurements \(Y_{ij}\) at visit times \(t_{ij}\), for \(j=1,\ldots,n_i\). A useful analysis-ready record keeps this repeated-measurement information linked to one terminal first-event record: \(X_i\), \(\Delta_i\), and \(J_i\). In a long-format file, there may be several rows per subject for marker visits, but the event time and event type must remain consistent across those rows, or be stored in a linked subject-level table.

A marker visit is not an event. A missed visit does not, by itself, establish that follow-up ended, and a final marker measurement does not automatically define the censoring time. The event and censoring times should come from the study's follow-up rules and source records. In particular, a marker can be unobserved near an event without changing the event type or time.

Worked Example: Encoding Longitudinal Records

The following hypothetical subjects have marker measurements at the listed months. Event times are measured from enrollment. Cause 1 is progression, cause 2 is death before progression, and censoring means the subject was last known event-free at that time.

SubjectMarker visits (month: value)Observed time \(X_i\)Record
A0: 8.1; 2: 7.64Progression
B0: 6.9; 3: 6.4; 5: 6.26Death before progression
C0: 7.3; 3: 7.07Administrative censoring

For A, \(\Delta_A=1\), \(J_A=1\), and \((\Delta_{A1},\Delta_{A2})=(1,0)\). The last marker was measured at month 2, but the recorded progression time is month 4; the visit time is not substituted for the event time.

For B, \(\Delta_B=1\), \(J_B=2\), and \((\Delta_{B1},\Delta_{B2})=(0,1)\). Death is the first event, so B has no cause-1 first event at a later time.

For C, \(\Delta_C=0\), \(J_C=0\), and \((\Delta_{C1},\Delta_{C2})=(0,0)\). C contributes observed event-free follow-up through month 7, but no event of either cause is recorded. These three subjects therefore have three distinct event histories even though each has a final observed time.

Cause-Specific Risk Sets

For a first-event analysis, define the risk set immediately before time \(t\) as \(\mathcal R(t)=\{i:X_i\geq t\}\), using the convention that a subject with an event at \(t\) is at risk just before that event. Subject \(i\) belongs to the set at \(t\) if no first event or censoring has occurred before \(t\). In the two-cause setting, the cause-specific risk set for either cause is this same set of event-free, observed subjects just before \(t\): \(\mathcal R_k(t)=\mathcal R(t)\), for \(k=1,2\). Cause specificity enters in which event is counted at \(t\), not by removing subjects who later experience the competing cause.

Definition: The cause-\(k\) event count at time \(t\) is \(d_k(t)=\sum_i I(X_i=t,\Delta_{ik}=1)\). A subject who experiences cause \(3-k\) at time \(t\) is in the risk set immediately before \(t\), but contributes to \(d_{3-k}(t)\), not \(d_k(t)\). After that event time, the subject is no longer in either first-event risk set.

This rule follows directly from the meaning of “at risk immediately before \(t\).” A subject whose first event is at \(t\) has not yet experienced that event before \(t\), so is included in the pre-event set. Someone whose competing first event occurred earlier is no longer eligible to have the other cause as a first event. Someone censored earlier is no longer observed and is also excluded. Thus, membership depends on observed history up to just before the time under consideration, not on the eventual event type alone.

Worked Example: Constructing Risk Sets at Event Times

Consider six hypothetical subjects with observed times and outcomes: A, cause 1 at month 4; B, cause 2 at month 6; C, censored at month 7; D, cause 1 at month 9; E, cause 2 at month 9; and F, censored at month 10. Assume event and censoring times are recorded on the same time scale and use the pre-event convention above.

At month 4, all six subjects have \(X_i\geq4\), so \(\mathcal R_1(4)=\mathcal R_2(4)=\{A,B,C,D,E,F\}\). A is the cause-1 event, giving \(d_1(4)=1\) and \(d_2(4)=0\).

At month 6, A has already experienced a first event and is no longer at risk. The risk set is \(\{B,C,D,E,F\}\), and B contributes one cause-2 event: \(d_1(6)=0\), \(d_2(6)=1\).

At month 7, the risk set is \(\{C,D,E,F\}\); C is still included just before censoring at 7. Immediately after that time C leaves observation. At month 9, the risk set is \(\{D,E,F\}\). Both D and E are included just before month 9, with \(d_1(9)=1\) and \(d_2(9)=1\). The tied event times do not make either subject a competing event that happened earlier than the other; both are first events at the same recorded time.

The arithmetic check at month 9 is \(|\mathcal R(9)|=3\), with two first events and one subject, F, still under observation after that time. This check is about membership immediately before the event time; it does not imply that F must remain under observation indefinitely.

Event Indicators and a Short Justification

The cause-specific indicator is a compact way to preserve event type without treating censoring as an event. For each subject, the possible indicator pairs are \((1,0)\) for cause 1, \((0,1)\) for cause 2, and \((0,0)\) for censoring. The pair \((1,1)\) is impossible for a single first event. These indicators satisfy

$$ \Delta_i=\Delta_{i1}+\Delta_{i2}, \qquad \Delta_{i1}\Delta_{i2}=0. $$

To justify the risk-set definition, consider a fixed time \(t\). If \(X_i<t\), then either a first event or censoring has already ended observed event-free follow-up, so subject \(i\) cannot be at risk immediately before \(t\). If \(X_i\geq t\), no such endpoint is recorded before \(t\), so subject \(i\) is still eligible to experience either first-event cause immediately before \(t\). Hence the pre-event indicator is \(I(X_i\geq t)\), and summing these indicators gives

$$ |\mathcal R_k(t)|=\sum_i I(X_i\geq t), \qquad k\in\{1,2\}. $$

The same expression applies to both causes because a competing event at the current time is not prior history. Once it occurs, the subject leaves the common first-event risk set for subsequent times.

Worked Example: Censoring, Competing Events, and Missing Visits

Suppose three hypothetical participants are followed for a first event: P has a cause-2 event at month 5; Q has no event and is last confirmed event-free at month 5; R misses a planned marker visit at month 5, is contacted and confirmed event-free at month 8, and has a cause-1 event at month 10.

For P, \(X_P=5\), \(\Delta_P=1\), and \((\Delta_{P1},\Delta_{P2})=(0,1)\). P is included in both risk sets just before month 5 and is excluded from both after the cause-2 event.

For Q, if the protocol defines month 5 as the end of ascertainment and no event is observed by then, \(X_Q=5\), \(\Delta_Q=0\), and \((\Delta_{Q1},\Delta_{Q2})=(0,0)\). Q is included just before month 5 and is not treated as having cause 1 or cause 2.

For R, the missed visit is not a censoring record because follow-up continues and the event is later observed. R's event record is \(X_R=10\), \(\Delta_R=1\), \(J_R=1\). The month-5 marker value is missing, but that fact does not alter R's event time or type. At month 8, R remains under observation and event-free, despite the earlier missing marker visit.

Checks, Alternatives, and Limitations

A practical construction should be checked against the study protocol and source records before analysis. Useful checks include the following:

  • Every subject has one observed time and one valid status: cause 1, cause 2, or censored.
  • For an observed event, the recorded cause is exactly one of the two permitted causes; for censoring, no event cause is assigned.
  • Follow-up time is nonnegative, and no marker measurement used as an observed follow-up measurement occurs after the first event time.
  • Risk-set membership can only decrease after a first event or censoring; a subject cannot re-enter a first-event risk set.
  • Same-time events, censorings, and events must follow a documented tie convention. The pre-event convention used here includes subjects with \(X_i=t\) immediately before \(t\).

A common error is to form the cause-1 risk set by removing everyone who will eventually have cause 2. That uses future information: a subject who is still event-free at time \(t\) is at risk of either cause at \(t\), even if a competing event occurs later. The correction is to include all subjects with \(X_i\geq t\) in the pre-event risk set and distinguish the causes through \(\Delta_{i1}\) and \(\Delta_{i2}\).

Another tempting shortcut is to collapse both event causes into a single binary event indicator. This may be adequate only when the scientific question genuinely treats the two event types as the same endpoint. It discards the event-type distinction needed for competing-risks analyses. Conversely, coding a competing event as censoring in a cause-specific event record is not the same as claiming it is ordinary loss to follow-up: the event is known and should retain its cause label. Cause-specific risk-set bookkeeping is also distinct from other competing-risks estimands and risk-set constructions; those require their own definitions and should not be substituted without stating the target quantity.

The records alone do not guarantee valid inference. For example, methods using censoring generally require assumptions about the censoring process, often conditional on recorded covariates or history. The risk-set definition specifies who is observed and event-free at a time; it does not establish that censoring is independent or that the longitudinal measurement process is adequately handled. Joint modeling adds assumptions about the marker and event processes, which must be assessed separately. Recurrent events are also outside this first-event setup: after a first event, a subject may remain eligible for further events under a different data structure and model.

The key operational principle is simple: preserve the time, status, and cause as separate fields, link them correctly to the longitudinal measurements, and construct each risk set from observed event-free follow-up immediately before the time of interest.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. A subject has a cause-1 event at month 12. What are \(\Delta_i\), \(J_i\), and the two cause-specific indicators?
  2. At time \(t=8\), a subject has a cause-2 event at month 11. Should the subject be in \(\mathcal R_1(8)\)? Why?
  3. A participant misses a marker visit at month 4 but is confirmed event-free at month 6. Is month 4 necessarily the censoring time?
  4. At month 10, two subjects have different first-event causes recorded at that same time. Under the pre-event convention, are both in the risk set immediately before month 10?

Solutions. (1) \(\Delta_i=1\), \(J_i=1\), \(\Delta_{i1}=1\), and \(\Delta_{i2}=0\). (2) Yes. The subject is still event-free and observed just before month 8; the later competing event does not remove the subject from the earlier risk set. (3) No. A missed marker visit alone does not end event follow-up; the participant is confirmed event-free at month 6, so censoring must be determined from the follow-up protocol and subsequent records. (4) Yes. Both subjects have their first events at month 10 and are included immediately before that time; each is counted for its own cause.

Clinical Biostats