Nothing
library(testthat)
context("Simulate models that depend on TSLD or TDOS")
seed <- 1
source(file.path(getwd(), test_path(), "test-utils.R"))
test_that("Weibull model simulation works as expected", {
regFilename <- "weibull_model"
model <- suppressWarnings(read.campsis(file.path(getwd(), test_path(), "models/", regFilename)))
config <- DatasetConfig(exportTDOS = TRUE)
ds <- Dataset(3) %>%
add(Bolus(time = c(0, 48), amount = 100)) %>%
add(Observations(seq(0, 96, by = 4))) %>%
add(Covariate("DOSE", 100)) %>%
add(config)
nocbvars <- "TDOS" # This is needed for mrgsolve because TDOS is considered as a time-varying covariate
settings <- Settings(NOCB(variables = nocbvars))
# Export TDOS only
simulation <- expression(simulate(model = model, dataset = ds, dest = destEngine, seed = seed, settings = settings))
test <- expression(
output_regression_test(results, output = "CONC", filename = regFilename)
)
campsis_test(simulation, test, env = environment())
# Now export TSLD as well
config <- DatasetConfig(exportTSLD = TRUE, exportTDOS = TRUE)
ds <- ds %>% add(config)
# Not really a simulation here...
simulation <- expression(
nocb <- if (destEngine %in% c("RxODE", "rxode2")) {
FALSE
} else {
TRUE
},
ds %>% export(dest = destEngine, settings = settings)
)
test <- expression(
results_ <- results %>% dplyr::filter(ID == 1),
expected <- if (destEngine %in% c("RxODE", "rxode2")) {
c(c(0, 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 0), c(0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48))
} else {
c(c(0, 0, 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44), c(0, 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44))
},
expect_equal(results_$TSLD, expected)
)
campsis_test(simulation, test, env = environment())
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.