tests/testthat/test-simulate_no_omega.R

library(testthat)

context("Test that the simulate method works even when no OMEGA's/SIGMA's are provided")
seed <- 1
source(file.path(getwd(), test_path(), "test-utils.R"))

test_that("Simulate a 1-cpt model without OMEGA's/SIGMA's - Github issue #8", {
  model <- model_suite$testing$nonmem$advan2_trans2

  # Keep THETA's only
  model@parameters <- model@parameters %>% select("theta")

  dataset <- Dataset(3) %>%
    add(Bolus(time = 0, amount = 1000, compartment = 1)) %>%
    add(Observations(times = seq(0, 24, by = 0.5))) %>%
    add(Covariate(name = "EPS_PROP", 0)) %>%
    add(Covariate(name = "ETA_V", 0)) %>%
    add(Covariate(name = "ETA_CL", 0)) %>%
    add(Covariate(name = "ETA_KA", 0))

  simulation <- expression(simulate(model = model, dataset = dataset, dest = destEngine, seed = seed))
  test <- expression(
    subject1 <- results %>% dplyr::filter(ID == 1) %>% dplyr::select(-ID),
    subject2 <- results %>% dplyr::filter(ID == 2) %>% dplyr::select(-ID),
    subject3 <- results %>% dplyr::filter(ID == 3) %>% dplyr::select(-ID),
    # No IIV, no RUV -> subject 1 strictly identical to subject 2 and 3
    expect_equal(subject1, subject2),
    expect_equal(subject2, subject3)
  )
  campsis_test(simulation, test, env = environment())
})

Try the campsis package in your browser

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

campsis documentation built on Aug. 5, 2026, 9:07 a.m.