# Generated by roxytest: Do not edit by hand!
# File R/apply_af.r: @tests
test_that("Function apply_af() @ L58", {
dist1 <- define_surv_param("exp", rate = 0.25)
expect_equal(
apply_af(dist1, 0.5),
create_list_object(c('surv_aft', 'surv_dist'), dist = dist1, af = 0.5)
)
expect_equal(
apply_af(dist1, 0.5),
apply_af(apply_af(dist1, 0.5), 1)
)
expect_equal(
apply_af(dist1, 0.25),
apply_af(apply_af(dist1, 0.5), 0.5)
)
expect_equal(
apply_af(dist1, 0.5),
apply_af(dist1, log(0.5), TRUE)
)
expect_error(
apply_af('foo', 0.5),
'Error applying acceleration factor, invalid survival distribution provided.',
fixed = TRUE
)
expect_error(
apply_af(dist1, 'foo'),
'Error applying acceleration factor, "af" must be numeric.',
fixed = TRUE
)
expect_error(
apply_af(dist1, NA_real_),
'Error applying acceleration factor, "af" cannot be NA.',
fixed = TRUE
)
expect_error(
apply_af(dist1, -2),
'Error applying acceleration factor, "af" cannot be negative.',
fixed = TRUE
)
})
test_that("Function surv_prob.surv_aft() @ L134", {
dist1 <- define_surv_param("exp", rate = 0.50)
dist2 <- define_surv_param("exp", rate = 0.25)
dist3 <- apply_af(dist1, 2)
dist4 <- apply_af(dist1, log(2), TRUE)
expect_equal(
surv_prob(dist1, seq_len(100)),
surv_prob(dist3, 2 * seq_len(100))
)
expect_equal(
surv_prob(dist2, seq_len(100)),
surv_prob(dist3, seq_len(100))
)
expect_equal(
surv_prob(dist2, seq_len(100)),
surv_prob(dist4, seq_len(100))
)
})
test_that("Function print.surv_aft() @ L151", {
dist1 <- apply_af(define_surv_param('exp', rate = 0.025), 0.5)
expect_output(
print(dist1),
'An accelerated failure time survival distribution:
* Acceleration Factor: 0.5
* Baseline Distribution: An exponential distribution (rate = 0.025).',
fixed = T
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.