Debian Codegraph @

tests/testthat/test-survival-pyears.R

raw
1 skip_on_cran()
2
3 skip_if_not_installed("modeltests")
4 library(modeltests)
5
6 skip_if_not_installed("survival")
7 suppressPackageStartupMessages(library(survival))
8
9 temp.yr <- tcut(mgus$dxyr, 55:92, labels = as.character(55:91))
10 temp.age <- tcut(mgus$age, 34:101, labels = as.character(34:100))
11 ptime <- ifelse(is.na(mgus$pctime), mgus$futime, mgus$pctime)
12 pstat <- ifelse(is.na(mgus$pctime), 0, 1)
13
14 fit <- pyears(
15 Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex,
16 mgus,
17 data.frame = TRUE
18 )
19
20 fit2 <- pyears(
21 Surv(ptime / 365.25, pstat) ~ temp.yr + temp.age + sex,
22 mgus,
23 data.frame = FALSE
24 )
25
26 test_that("pyears tidier arguments", {
27 check_arguments(tidy.pyears)
28 check_arguments(glance.pyears)
29 })
30
31 test_that("tidy.pyears", {
32 td <- tidy(fit)
33 td2 <- tidy(fit2)
34
35 check_tidy_output(td, strict = FALSE)
36 check_tidy_output(td2, strict = FALSE)
37 })
38
39 test_that("glance.pyears", {
40 gl <- glance(fit)
41 gl2 <- glance(fit2)
42
43 check_glance_outputs(gl, gl2)
44 })