tests/testthat/test_parameters_table.R

test_that("Simulating with table of parameters works", {
  skip_on_cran()
  parameters_table <- data.frame(
    CL = rnorm(10, 5, 5),
    V = rnorm(10, 5, 0.5)
  )

  mod <- new_ode_model(
    code = "
      dAdt[1] = -(CL/V) * A[1];
    ",
    obs = list(cmt = 1, scale = "V"),
    covariates = list(WT = new_covariate(70)),
    cpp_show_code=FALSE
  )
  par <- list(CL = 5, V = 50)
  reg <- new_regimen(amt = 2000, interval = 24, type = "infusion")
  covariates = list(WT = new_covariate(1))
  res <- sim_ode(
    ode = mod,
    parameters_table = parameters_table,
    covariates = covariates,
    regimen = reg,
    only_obs = TRUE
  )

  expect_equal(length(unique(res$id)), 10)
  expect_equal(sum(is.na(res$y)), 0)
})

Try the PKPDsim package in your browser

Any scripts or data that you put into this service are public.

PKPDsim documentation built on March 7, 2023, 5:40 p.m.