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