View source: R/data_preparation.R
| create_longitudinal_labels | R Documentation |
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.
create_longitudinal_labels(SurvTime, Event, thresholds = c(4, 6))
SurvTime |
A numeric vector of length |
Event |
A numeric vector of length |
thresholds |
A numeric vector of length |
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
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.
create_indicator_matrix to convert NA
values into a binary censoring indicator matrix.
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.