tests/testthat/test-GDILM_SEIRS_Sim_Par_Est.R

test_that("An example for a simulation study", {
  result=GDILM_SEIRS_Sim_Par_Est(5,5,8,30,0.7, 0.5, -12, 2.5, -3, 30, 50, 0.5, 0.5, 5, 5, 10, 3)
  expect_type(result, "list")
  expect_true(all(is.finite(unlist(result))))
  expect_true(result$lambda1 >= 0 && result$lambda1 <= 1)
  expect_true(result$tau1 > 0)
})

test_that("the simulation recovers the parameters it was given", {
  skip_on_cran()
  set.seed(1)
  fit <- GDILM_SEIRS_Sim_Par_Est(5, 5, 10, 30, 0.7, 0.5, -12, 2.5, -3, 40, 50, 0.3, 0.6, 5, 5, 10, 3)
  expect_equal(fit$alphaS, -12,  tolerance = 0.3)
  expect_equal(fit$alphaT,  -3,  tolerance = 0.5)
  expect_equal(fit$delta,  2.5,  tolerance = 0.5)
})

test_that("a scenario with too few cases is rejected rather than fitted", {
  skip_on_cran()
  # alphaS0 = 1 infects the whole grid at once, leaving no susceptibles.
  expect_error(
    GDILM_SEIRS_Sim_Par_Est(5, 5, 10, 30, 0.7, 0.5, 1, 2.5, 0, 40, 50, 0.3, 0.6, 5, 5, 10, 3),
    "doesn't include enough number of cases")
})

test_that("the grid uses both dimensions", {
  # GridDim2 must reach the adjacency structure, not just the coordinates.
  expect_error(
    GDILM_SEIRS_Sim_Par_Est(2, 3, 4, 10, 0.7, 0.5, 1, 2.5, 0, 30, 50, 0.5, 0.5, 5, 5, 5, 1),
    "doesn't include enough number of cases")
})

Try the GDILM.SEIRS package in your browser

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

GDILM.SEIRS documentation built on Sept. 7, 2026, 1:07 a.m.