inst/doc/from-1.0.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
run <- requireNamespace("ranger", quietly = TRUE)

## ----eval = run---------------------------------------------------------------
library(survalis)
f <- Surv(time, status) ~ age + karno + celltype

m <- fit(f, veteran, "ranger", spec = list(num.trees = 200), seed = 1)
round(as.matrix(predict(m, veteran[1:3, ], times = c(90, 180))), 3)
predict(m, veteran[1:3, ], times = c(90, 180), type = "rmst")

## -----------------------------------------------------------------------------
expo <- list(
  name = "exponential",
  fit = function(formula, data, ...) survival::survreg(formula, data, dist = "exponential"),
  predict = function(object, newdata, times) {
    rate <- 1 / predict(object, newdata, type = "response")
    exp(-outer(rate, times))
  }
)
evaluate(Surv(time, status) ~ age + karno, veteran, model = expo,
         times = c(90, 180), resampling = cv(3, seed = 1))

Try the survalis package in your browser

Any scripts or data that you put into this service are public.

survalis documentation built on Nov. 14, 2026, 5:10 p.m.