# Generated by roxytest: Do not edit by hand!
# File R/surv_spline.r: @tests
test_that("Function get_spline_params_from_args() @ L92", {
expect_equal(
get_spline_params_from_args(list(1,2,3,4,5,c(6, 6))),
list(
gamma1 = 1, gamma2 = 2,
gamma3 = 3, knots1 = 4,
knots2 = 5, knots3 = 6
)
)
expect_equal(
get_spline_params_from_args(
list(
knots3 = 6, knots1 = c(4, 4),
knots2 = 5, gamma1 = c(1,1,1),
gamma3 = 3, gamma2 = 2
)
),
list(
gamma1 = 1, gamma2 = 2,
gamma3 = 3, knots1 = 4,
knots2 = 5, knots3 = 6
)
)
expect_error(
get_spline_params_from_args(
list(
knots3 = 6, knots1 = c(4, 4),
knots2 = 5, gamma1 = c(1,1,1),
gamma3 = 3, foo = 1
)
),
'incorrect argument names were provided',
fixed = T
)
})
test_that("Function check_spline_params() @ L156", {
expect_error(
check_spline_params(list(1,2,3,4,5)),
'must provide at least two parameter values',
fixed =T
)
expect_error(
check_spline_params(list(1,2)),
'must provide at least two parameter values',
fixed =T
)
expect_error(
check_spline_params(list(1,2,3,4,"foo", 6)),
'parameter was of type "character" instead of "numeric"',
fixed =T
)
})
test_that("Function print.surv_spline() @ L188", {
dist1 <- define_surv_spline(
scale = 'hazard',
gamma1 = -2.08, gamma2 = 2.75, gamma3 = 0.23,
knots1 = -1.62, knots2 = 0.57, knots3 = 1.191
)
expect_output(
print(dist1),
"A Royston & Parmar spline model of log cumulative hazard with 3 knots (gamma = [-2.08, 2.75, 0.23], knots = [-1.62, 0.57, 1.19]).",
fixed = TRUE
)
})
test_that("Function surv_prob.surv_spline() @ L213", {
dist1 <- define_surv_spline(
scale = 'hazard',
gamma1 = -2.08, gamma2 = 2.75, gamma3 = 0.23,
knots1 = -1.62, knots2 = 0.57, knots3 = 1.191
)
expect_equal(
surv_prob(dist1, c(0, 1, 2, 3)),
c(1.0000000, 0.9042421, 0.6387142, 0.3847163),
tolerance = 0.00001
)
})
test_that("Function get_spline_scale_display_name() @ L254", {
expect_equal(
get_spline_scale_display_name('hazard'),
'log cumulative hazard'
)
expect_equal(
get_spline_scale_display_name('odds'),
'log cumulative odds'
)
expect_equal(
get_spline_scale_display_name('blah'),
'blah'
)
})
test_that("Function define_spline_survival() @ L279", {
expect_equal(
define_surv_spline(
scale = 'hazard',
gamma1 = -2.08, gamma2 = 2.75, gamma3 = 0.23,
knots1 = -1.62, knots2 = 0.57, knots3 = 1.191
),
define_spline_survival(
scale = 'hazard',
gamma1 = -2.08, gamma2 = 2.75, gamma3 = 0.23,
knots1 = -1.62, knots2 = 0.57, knots3 = 1.191
)
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.