Description Usage Arguments Value See Also Examples
Given a model built wtih sw_reg,
predict_sw_reg allows to get the
predictions of the model for new
observations
1  | predict_sw_reg(obj, newdata)
 | 
obj | 
 A list output by   | 
newdata | 
 A data.frame which contains the same variables as the ones used for the training  | 
A list with the following elements :
pred | 
 The vector of the predicted values for   | 
pred_KMloc | 
 The vector of the predicted values for   | 
surv_KMloc | 
 The matrix which contains the estimated values of the survival curves at
  | 
time_points | 
 The vector of the time points where the survival curves
are evaluated (require   | 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  | # ------------------------------------------------
#   Load "transplant" data
# ------------------------------------------------
data("transplant", package = "survival")
transplant$delta = 1 * (transplant$event == "ltx") # create binary var
# which indicate censoring/non censoring
# keep only rows with no missing value
transplant_bis = transplant[stats::complete.cases(transplant),]
# ------------------------------------------------
#   Basic call to train a model
# ------------------------------------------------
set.seed(17)
train_lines = sample(1:nrow(transplant_bis), 600)
res = sw_reg(y_var = "futime",
                                   delta_var = "delta",
                                   x_vars = setdiff(colnames(transplant_bis),
                                                    c("futime", "delta", "event")),
                                   train = transplant_bis[train_lines,],
                                   types_w_ev = c("KM", "Cox", "RSF", "unif"),
                                   mode_sw_RF = 2)
# ------------------------------------------------
#   Predict on new data
# ------------------------------------------------
pred = predict_sw_reg(obj = res,
                                            newdata = transplant_bis[-train_lines,])
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.