predict.parametric | R Documentation |
Predicted values from a fitted Parametric survival model.
## S3 method for class 'parametric'
predict(
object,
newdata,
form = c("aft", "ph", "tobit", "po"),
times = NULL,
type = c("survival", "risk", "all"),
distr6 = FALSE,
ntime = 150,
round_time = 2,
...
)
object |
( |
newdata |
|
form |
|
times |
|
type |
( |
distr6 |
( |
ntime |
|
round_time |
|
... |
|
The form
parameter determines how the distribution is created.
Options are:
Accelerated failure time ("aft"
)
h(t) = h_0(\frac{t}{exp(lp)})exp(-lp)
Proportional Hazards ("ph"
)
h(t) = h_0(t)exp(lp)
Tobit ("tobit"
)
h(t) = \Phi(\frac{t - lp}{scale})
Proportional odds ("po"
)
h(t) = \frac{h_0(t)}{1 + (exp(lp)-1)S_0(t)}
where h_0,S_0
are the estimated baseline hazard and survival functions
(in this case with a given parametric form), lp
is the predicted linear
predictor calculated using the formula lp = \hat{\beta} X_{new}
where
X_{new}
are the variables in the test data set and \hat{\beta}
are the coefficients from the fitted parametric survival model (object
).
\Phi
is the cdf of a N(0, 1) distribution, and scale
is the
fitted scale parameter.
A numeric
if type = "risk"
, a distr6::Distribution()
(if distr6 = TRUE
) and type = "survival"
; a matrix
if
(distr6 = FALSE
) and type = "survival"
where entries are survival
probabilities with rows of observations and columns are time-points;
or a list combining above if type = "all"
.
if (requireNamespaces(c("distr6", "survival"))) {
library(survival)
set.seed(42)
train <- simsurvdata(10)
test <- simsurvdata(5)
fit <- parametric(Surv(time, status) ~ ., data = train)
# Return a discrete distribution survival matrix
predict_distr <- predict(fit, newdata = test)
predict_distr
# Return a relative risk ranking with type = "risk"
predict(fit, newdata = test, type = "risk")
# Or survival probabilities and a rank
predict(fit, newdata = test, type = "all", distr6 = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.