train_time_svhm: Train time dependent SVHM

View source: R/train_time_svhm.R

train_time_svhmR Documentation

Train time dependent SVHM

Description

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.

Usage

train_time_svhm(
  train,
  test,
  covariates,
  cost,
  opt = "osqp",
  gamma_squared = 0.5
)

Arguments

train

training dataset

test

test dataset

cost

cost parameter of the support vector machine of type numeric

opt

which quadratic optimization is used (opt='mosek' or opt='osqp')

gamma_squared

width of gaussian kernel

Value

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

Examples

{
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)
}


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