Description Usage Arguments Value See Also Examples
Given a model built wtih cox_reg
,
predict_cox_reg
allows to get the predictions of the model for new
observations
1 | predict_cox_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 |
surv |
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 |
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 = cox_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_cox_reg(obj = res1,
newdata = transplant_bis[-train_lines,])
print(pred1$pred[1:30])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.