# Generated by roxytest: Do not edit by hand!
# File R/calculations.r: @tests
test_that("Function eval_surv() @ L42", {
dist1 <- define_surv_param(distribution = "exp", rate = 0.05)
expect_equal(
surv_prob(dist1, c(1,2,3,4)),
eval_surv(dist1, c(1,2,3,4))
)
})
test_that("Function compute_surv() @ L64", {
dist1 <- define_surv_param(distribution = "exp", rate = 0.05)
expect_equal(
surv_prob(dist1, seq(from=2,to=10,by=2)),
compute_surv(dist1, seq_len(5), 2, type = 'surv')
)
expect_equal(
event_prob(dist1, seq(from=2,to=10,by=2)-2, seq(from=2,to=10,by=2)),
compute_surv(dist1, seq_len(5), 2, type = 'prob')
)
})
test_that("Function event_prob() @ L102", {
dist1 <- define_surv_param('exp', rate = 0.12)
expect_equal(
event_prob(dist1, c(0,1,2), c(1,2,3)),
rep(1-pexp(1, rate = 0.12, lower.tail = FALSE), 3)
)
expect_error(
event_prob('foo', 1, 2),
'Error calculating event probabilities, invalid survival distribution provided.',
fixed = TRUE
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.