View source: R/train_time_svhm.R
train_time_svhm | R Documentation |
Uses the Rmosek or osqp package to train the time dependent SVHM on a given training and test set. The training calculates the risk scores and
the optimal decision function values for each individual at every event time of the training set.
The columns of the dataset must contain
id, futime, death, covariates, lt, rt
where lt
and rt
are the start and end times of each time interval. the death
column must also be logical values.
train_time_svhm( train, test, covariates, cost, opt = "osqp", gamma_squared = 0.5 )
train |
training dataset |
test |
test dataset |
cost |
cost parameter of the support vector machine of type numeric |
opt |
which quadratic optimization is used ( |
gamma_squared |
width of gaussian kernel |
trained model with
$e_vec
vector indicating if an event happens at each event time
$event_times
ordered event times of the training dataset
$sol
calculated optimal solution for each event time
$train
train dataset with risk scores
$test
test dataset with risk scores
{ library(timereg) library(SVHM) data(csl) df <- csl names(df)[names(df) == "dc"] <- "death" names(df)[names(df) == "eventT"] <- "futime" df <- transform(df, death = as.logical(death)) df<-split(df, df$id) df[sample(1:length(df))] partition <- SVHM:::createListPartition(df, 1, test_size=.3) df_test <- partition$"test" df_train <- partition[["1"]] trained_model <- train_time_svhm(df_train, df_test, c("sex"), 10, opt="osqp", gamma_squared=100) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.