predictSurvProb2survreg {SurvMetrics}R Documentation

Predicting Survival Probabilities for a 'survreg' Object

Description

Function to extract survival probability predictions from survreg modeling approach.

Usage

predictSurvProb2survreg(object, newdata, time_days)

Arguments

object

A model fitted by survreg from which to extract predicted survival probabilities

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.

Value

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.

Author(s)

Hanpu Zhou zhouhanpu@csu.edu.cn

Examples

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))


[Package SurvMetrics version 0.5.0 Index]