predict.survdnn {survdnn} | R Documentation |
Predict from a survdnn Model
Description
Generate predictions from a fitted 'survdnn' model for new data. Supports linear predictors, survival probabilities at specified time points, or cumulative risk estimates.
Usage
## S3 method for class 'survdnn'
predict(object, newdata, times = NULL, type = c("survival", "lp", "risk"), ...)
Arguments
object |
An object of class '"survdnn"' returned by [survdnn()]. |
newdata |
A data frame of new observations to predict on. |
times |
Numeric vector of time points at which to compute survival or risk probabilities. Required if 'type = "survival"' or 'type = "risk"'. |
type |
Character string specifying the type of prediction to return:
|
... |
Currently ignored (for future extensions). |
Value
A numeric vector (if 'type = "lp"' or '"risk"'), or a data frame (if 'type = "survival"') with one row per observation and one column per 'times'.
Examples
library(survival)
data(veteran, package = "survival")
# Fit survdnn with Cox loss
mod <- survdnn(Surv(time, status) ~ age + karno + celltype, data = veteran,
loss = "cox", epochs = 50, verbose = FALSE)
# Linear predictor (log-risk)
predict(mod, newdata = veteran, type = "lp")[1:5]
# Survival probabilities at selected times
predict(mod, newdata = veteran, type = "survival", times = c(30, 90, 180))[1:5, ]
# Cumulative risk at 180 days
predict(mod, newdata = veteran, type = "risk", times = 180)[1:5]