create_longitudinal_labels: Convert Survival Data to Longitudinal Binary Labels

View source: R/data_preparation.R

create_longitudinal_labelsR Documentation

Convert Survival Data to Longitudinal Binary Labels

Description

Transforms time-to-event survival data into a matrix of binary labels at user-defined time thresholds. This is the core data transformation that enables survival analysis within the multi-task learning framework.

Usage

create_longitudinal_labels(SurvTime, Event, thresholds = c(4, 6))

Arguments

SurvTime

A numeric vector of length n containing observed survival times. Must be non-negative.

Event

A numeric vector of length n encoding censoring status. 1 = event observed, 0 = censored.

thresholds

A numeric vector of length numTasks representing the time thresholds at which to evaluate survival status. Default: c(4, 6).

Details

The encoding logic for each patient at each threshold is:

  • 1 — patient is progression-free at this threshold (survival time exceeds threshold, regardless of event status)

  • 0 — patient experienced an event before this threshold (survival time < threshold AND event observed)

  • NA — patient was censored before this threshold (survival time < threshold AND no event observed); label is unknown

Value

A numeric matrix of dimensions n x numTasks. Column names are set to the threshold values. Contains 1, 0, and NA values as described above.

See Also

create_indicator_matrix to convert NA values into a binary censoring indicator matrix.

Examples

# Simulate 10 patients
set.seed(42)
SurvTime <- rexp(10, rate = 0.1)
Event <- rbinom(10, 1, 0.7)
thresholds <- c(4, 6, 10, 15)

Y <- create_longitudinal_labels(SurvTime, Event, thresholds)
Y   # 1 = progression-free, 0 = event, NA = censored

orthoMTL documentation built on Aug. 23, 2026, 5:10 p.m.