Learn R Programming

survdnn (version 0.6.0)

predict.survdnn: 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 survdnn
predict(object, newdata, times = NULL, type = c("survival", "lp", "risk"), ...)

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`.

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:

"lp"

Linear predictor (log-risk score; higher implies worse prognosis).

"survival"

Predicted survival probabilities at each value of `times`.

"risk"

Cumulative risk (1 - survival) at a single time point.

...

Currently ignored (for future extensions).

Examples

Run this code
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]

Run the code above in your browser using DataLab