train_svhm | R Documentation |
Uses the Rmosek or osqp package to train the SVHM on a given training and test set. Names of the cencoring variable and event variable mus be death
and futime
train_svhm( train, test, covariates, cost, k = 3, opt = "osqp", gamma_squared = 0.5 )
train |
training dataset |
test |
test dataset |
covariates |
vector of name of covariates |
cost |
cost parameter of the support vector machine of type numeric |
k |
integer of how many nearest event times are used to predict the event time (default is 3) |
opt |
which quadratic optimization is used ( |
gamma_squared |
width of gaussian kernel |
trained model with
$e_vec
vector indicating vector containing information if a subject is at risk or if an event happens. If n are the number of subjects and m the number of event times, then event_vec has length n*m,
$k_mat
kernel matrix,
$sol
calculated optimal solution,
$t_predict
test dataset with risk scores risk
and t_predict
,
$p_corr
pearson correlation of the predicted times
$C_indes
C-Index
The mosek package requires a license
{ library(KMsurv) library(SVHM) data(bmt) df<-bmt[1:40,] # shuffle data rows <- sample(nrow(df)) df <- df[rows, ] covariates <- c('z3', 'z4') # censoring variable and event variable need to have names "death" and "futime" names(df)[names(df) == "d3"] <- "death" names(df)[names(df) == "t2"] <- "futime" n<-floor(nrow(df)/2) train<- df[(1:n), ] test<- df[-(1:n), ] train_svhm(train, test, covariates, 10, .5, k=1, opt='osqp') }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.