tests/testthat/test-GDILM_SEIRS_Par_Est.R

test_that("An example for a real data model fitting", {
data(data)
data(adjacency_matrix)
result=GDILM_SEIRS_Par_Est(data,adjacency_matrix,2,2,2,0.5, 0.5, -20, 2, -3, 1, 1, 20, 2)
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 estimates respond to the data", {
  skip_on_cran()
  data(data)
  data(adjacency_matrix)
  data2 <- data
  data2$NInfected <- pmax(1, round(data2$NInfected / 10))
  a <- GDILM_SEIRS_Par_Est(data,  adjacency_matrix, 2,2,2, 0.5,0.5, -20, 2, -3, 1,1, 20, 2)
  b <- GDILM_SEIRS_Par_Est(data2, adjacency_matrix, 2,2,2, 0.5,0.5, -20, 2, -3, 1,1, 20, 2)
  expect_false(isTRUE(all.equal(a$delta, b$delta)))
})

test_that("the input guards fire", {
  data(data)
  data(adjacency_matrix)
  expect_error(GDILM_SEIRS_Par_Est(data, adjacency_matrix, 2,2,2, 0.5, 1.5, -20, 2, -3, 1,1, 20, 2),
               "between 0 and 1")
  expect_error(GDILM_SEIRS_Par_Est(data, adjacency_matrix, 2,2,2, 0.5, 0.5, -20, 0, -3, 1,1, 20, 2),
               "greater than zero")
  expect_error(GDILM_SEIRS_Par_Est(data[, -1], adjacency_matrix, 2,2,2, 0.5, 0.5, -20, 2, -3, 1,1, 20, 2),
               "must have exactly these columns")
})

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.