View source: R/risk_and_event_mat_func.r
create_risk_and_event_matrix | R Documentation |
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
create_risk_and_event_matrix(training_dataset, ordered_event_times)
training_dataset |
data frame representing the training data |
ordered_event_times |
data frame of all event times ordered in ascending order |
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
{ # 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) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.