Debian Codegraph @

tests/testthat/test-survival-survreg.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 sr <- survreg(
10 Surv(futime, fustat) ~ ecog.ps + rx,
11 ovarian,
12 dist = "exponential"
13 )
14
15 test_that("survreg tidier arguments", {
16 check_arguments(tidy.survreg)
17 check_arguments(glance.survreg)
18 check_arguments(augment.survreg)
19 })
20
21 test_that("tidy.survreg", {
22 td <- tidy(sr)
23 td2 <- tidy(sr, conf.int = TRUE)
24
25 check_tidy_output(td)
26 check_tidy_output(td2)
27
28 check_dims(td, 3, 5)
29 check_dims(td2, 3, 7)
30
31 expect_equal(td$term, c("(Intercept)", "ecog.ps", "rx"))
32 expect_equal(td2$term, c("(Intercept)", "ecog.ps", "rx"))
33 })
34
35 test_that("glance.survreg", {
36 gl <- glance(sr)
37 check_glance_outputs(gl)
38 })
39
40 test_that("augment.survreg", {
41 check_augment_function(
42 aug = augment.survreg,
43 model = sr,
44 data = ovarian,
45 newdata = ovarian
46 )
47 })
48
49 test_that("tidy.survreg with robust std err", {
50 sr <- survreg(
51 Surv(futime, fustat) ~ ecog.ps + rx,
52 ovarian,
53 dist = "exponential",
54 robust = TRUE
55 )
56 td <- tidy(sr)
57 td2 <- tidy(sr, conf.int = TRUE)
58
59 check_tidy_output(td)
60 check_tidy_output(td2)
61
62 check_dims(td, 3, 5)
63 check_dims(td2, 3, 7)
64 })