predict_rsf_reg: Compute the prediction of a model built with 'rsf_reg'

Description Usage Arguments Value See Also Examples

View source: R/rsf_reg.R

Description

Given a model built wtih rsf_reg, predict_rsf_reg allows to get the predictions of the model for new observations

Usage

1
predict_rsf_reg(obj, newdata)

Arguments

obj

A list output by rsf_reg

newdata

A data.frame which contains the same variables as the ones used for the training

Value

A list with the following elements :

pred

The vector of the predicted values for phi(T') (with T' = min(T, max_time)) for the observations of newdata

surv

The matrix which contains the estimated values of the survival curves at time_points, for the observations of newdata

time_points

The vector of the time points where the survival curves are evaluated

See Also

rsf_reg

Examples

 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
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)
res1 = rsf_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"))

# ------------------------------------------------
#   Predict on new data
# ------------------------------------------------

pred1 = predict_rsf_reg(obj = res1,
                       newdata = transplant_bis[-train_lines,])
print(pred1$pred[1:30])

YohannLeFaou/sword documentation built on May 28, 2019, 3:21 p.m.