predictSurvProb2survreg {SurvMetrics} | R Documentation |
Function to extract survival probability predictions from survreg
modeling approach.
predictSurvProb2survreg(object, newdata, time_days)
object |
A model fitted by |
newdata |
A data frame containing predictor variable combinations for which to compute predicted survival probabilities. |
time_days |
A vector of times in the range of the response variable, We.g. times when the response is a survival object, at which to return the survival probabilities. |
A matrix with as many rows as NROW(newdata) and as many columns as length(time_days). Each entry should be a probability and in rows the values should be decreasing.
Hanpu Zhou zhouhanpu@csu.edu.cn
library(survival)
set.seed(1234)
mydata <- kidney[, -1]
train_index <- sample(1:nrow(mydata), 0.7 * nrow(mydata))
train_data <- mydata[train_index, ]
test_data <- mydata[-train_index, ]
survregfit <- survreg(Surv(time, status) ~ ., dist = 'weibull', data = train_data)
pre_sb <- predictSurvProb2survreg(survregfit, test_data, c(10, 20))