context("Test basic usage")
set.seed(20200428)
test_that("A basic sim setup returns the correct object", {
incfn <- dist_setup(1.434065,0.6612,dist_type='lognormal')
# delay distribution sampling function
delayfn <- dist_setup(2, 4, 'weibull')
# generate initial cases
case_data <- outbreak_setup(num.initial.cases = 5,
incfn=incfn,
delayfn = delayfn,
testing = FALSE,
test_delay = 1,
sensitivity = 0.9,
precaution = 3,
self_report = 0,
prop.asym = 0,
iso_adhere = 0.9)
expect_equal(nrow(case_data), 5)
expect_true(all(case_data$missed))
expect_true(all(!case_data$asym))
})
test_that("asym arg works properly", {
incfn <- dist_setup(1.434065,0.6612,dist_type='lognormal')
# delay distribution sampling function
delayfn <- dist_setup(2, 4,'weibull')
# generate initial cases
# All asymptomatics
all_asym <- outbreak_setup(num.initial.cases = 5,
incfn=incfn,
delayfn = delayfn,
testing = FALSE,
test_delay = 1,
prop.asym = 1,
iso_adhere = 0.9)
expect_true(all(all_asym$asym))
set.seed(110102932)
# Mixed asympt
# dbinom(0, 10000, 0.5)
# With 10000 cases, probability of 0 symptomatic or 0 asympt is less than machine precision
mix <- outbreak_setup(num.initial.cases = 10000,
incfn=incfn,
delayfn = delayfn,
test_delay = 1,
testing = FALSE,
prop.asym=0.5,
self_report = 0.5,
precaution = 1)
expect_length(unique(mix$asym), 2)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.