create_risk_and_event_matrix: Risk and Event Matrix

View source: R/risk_and_event_mat_func.r

create_risk_and_event_matrixR Documentation

Risk and Event Matrix

Description

calculates two matrices of length n*m, if n are the number of subjects and m the number of event times. The Risk Matrix indicates for every subject in a dataset if the subject is still at risk at every event time. The Event Matrix is equal to the Risk Matrix but if a subject experiences an event at an event time the entrie is set to -1

Usage

create_risk_and_event_matrix(training_dataset, ordered_event_times)

Arguments

training_dataset

data frame representing the training data

ordered_event_times

data frame of all event times ordered in ascending order

Value

List $r_mat matrix indicating at risk at every event time for subjects $e_mat matrix indicating if subjects are at risk and if they are experiencing an event at any event time

Examples

{
# Create random data
train <- data.frame(futime = sample.int(10,6),
                    death = sample(c(TRUE,FALSE), 6, replace=TRUE),
                    training_id=1:6)
ordered_event_times <- with(train,
                           data.frame(
                              futime = sort(train$futime[train$death == TRUE]),
                              training_id = train$training_id[train$death == TRUE])
)

SVHM:::create_risk_and_evemt_matrix(train, ordered_event_times)
}


herglola/SVHM documentation built on March 24, 2022, 12:44 p.m.