tests/testthat/test-predict.R

test_that("predict_frailty works for all prediction types", {
  set.seed(123)
  dat <- r_frailty(n = 50, baseline = "weibull", bpar = c(2, 1.5), frailty = "gamma", fpar = c(0.8))
  fit <- fit_frailty(time = dat$time, status = dat$status, baseline = "weibull", frailty = "gamma")

  types <- c("survival", "hazard", "median", "expected", "risk", "marginal", "forecast")

  for (tp in types) {
    p <- predict_frailty(fit, type = tp, newtime = c(1, 2, 3))
    expect_true(all(is.finite(p)), label = paste("Prediction finite for", tp))
  }
})

Try the MultiFrailty package in your browser

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

MultiFrailty documentation built on Aug. 8, 2026, 1:07 a.m.