tests/testthat/test-compare.R

test_that("compare_models compares multiple models accurately", {
  set.seed(123)
  dat <- r_frailty(n = 60, baseline = "weibull", bpar = c(2, 1.5), frailty = "gamma", fpar = c(0.8))
  fit1 <- fit_frailty(time = dat$time, status = dat$status, baseline = "weibull", frailty = "none")
  fit2 <- fit_frailty(time = dat$time, status = dat$status, baseline = "weibull", frailty = "gamma")

  cmp <- compare_models(fit1, fit2)
  expect_s3_class(cmp, "data.frame")
  expect_equal(nrow(cmp), 2)
  expect_true("AIC" %in% colnames(cmp))
  expect_true("BIC" %in% colnames(cmp))
  expect_true("AICc" %in% colnames(cmp))
  expect_true("HQIC" %in% colnames(cmp))
})

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.