tests/testthat/test_methods.R

test_that("S3 methods for igp_fit work properly", {
  data(laser)
  fit <- igp_fit(laser, time_col = "t", deg_col = "increase", unit_col = "unit", frailty = "gamma")
  
  # Print & Summary
  expect_output(print(fit))
  s <- summary(fit)
  expect_s3_class(s, "summary_igp_fit")
  expect_output(print(s))
  
  # Coef & Vcov & Confint
  expect_equal(length(coef(fit)), 3)
  expect_equal(dim(vcov(fit)), c(3, 3))
  ci <- confint(fit)
  expect_equal(dim(ci), c(3, 2))
  
  # logLik, AIC, BIC
  ll <- logLik(fit)
  expect_s3_class(ll, "logLik")
  expect_equal(AIC(fit), fit$aic)
  expect_equal(BIC(fit), fit$bic)
  
  # Predict
  p_lt <- predict(fit, threshold = 10, type = "lifetime")
  expect_s3_class(p_lt, "lifetime_dist")
  p_fr <- predict(fit, type = "frailty")
  expect_s3_class(p_fr, "individual_frailty")
  p_qu <- predict(fit, threshold = 10, type = "quantiles")
  expect_true(is.data.frame(p_qu))
  
  # Plot
  pdf(NULL)
  expect_silent(plot(fit, type = "paths", threshold = 10))
  expect_silent(plot(fit, type = "frailty"))
  expect_silent(plot(fit, type = "lifetime", threshold = 10))
  expect_silent(plot(fit, type = "diagnostics"))
  expect_silent(plot(fit, type = "all", threshold = 10))
  dev.off()
})

Try the IGPFrailty package in your browser

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

IGPFrailty documentation built on Aug. 25, 2026, 9:08 a.m.