Running 'SEIR.R' [4s]
  Running 'SIR.R' [4s]
  Running 'SIS.R' [3s]
  Running 'SISe.R' [3s]
  Running 'SISe3.R' [173s]
  Running 'SISe3_sp.R' [175s]
  Running 'SISe_sp.R' [2s]
  Running 'SimInf.R' [2s]
  Running 'SimInf_events.R' [3s]
  Running 'SimInf_model.R' [2s]
  Running 'abc-gdata.R' [4s]
  Running 'abc-ldata.R' [5s]
  Running 'abc.R' [2s]
  Running 'density_ratio.R' [159s]
  Running 'distributions.R' [177s]
  Running 'edge_properties.R' [2s]
  Running 'indiv_events.R' [3s]
  Running 'ldata_sp.R' [3s]
  Running 'match_compartments.R' [168s]
  Running 'measures.R' [5s]
  Running 'mparse.R' [43s]
  Running 'package_skeleton.R' [4s]
  Running 'pfilter.R' [3s]
  Running 'phi.R' [160s]
  Running 'prevalence.R' [2s]
  Running 'punchcard.R' [2s]
  Running 'sample_select.R' [174s]
  Running 'solver_aem.R' [2s]
  Running 'u0.R' [2s]
  Running 'v0.R' [159s]
Running the tests in 'tests/SISe3.R' failed.
Complete output:
  > ## This file is part of SimInf, a framework for stochastic
  > ## disease spread simulations.
  > ##
  > ## Copyright (C) 2015 Pavol Bauer
  > ## Copyright (C) 2017 -- 2019 Robin Eriksson
  > ## Copyright (C) 2015 -- 2019 Stefan Engblom
  > ## Copyright (C) 2015 -- 2020 Stefan Widgren
  > ##
  > ## SimInf is free software: you can redistribute it and/or modify
  > ## it under the terms of the GNU General Public License as published by
  > ## the Free Software Foundation, either version 3 of the License, or
  > ## (at your option) any later version.
  > ##
  > ## SimInf is distributed in the hope that it will be useful,
  > ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  > ## GNU General Public License for more details.
  > ##
  > ## You should have received a copy of the GNU General Public License
  > ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
  > 
  > library(SimInf)
  > library(tools)
  > source("util/check.R")
  > 
  > ## Specify the number of threads to use.
  > set_num_threads(1)
  > 
  > ## For debugging
  > sessionInfo()
  R Under development (unstable) (2024-03-22 r86169 ucrt)
  Platform: x86_64-w64-mingw32/x64
  Running under: Windows Server 2022 x64 (build 20348)
  
  Matrix products: default
  
  
  locale:
  [1] LC_COLLATE=C                 LC_CTYPE=German_Germany.utf8
  [3] LC_MONETARY=C                LC_NUMERIC=C                
  [5] LC_TIME=C                   
  
  time zone: Europe/Berlin
  tzcode source: internal
  
  attached base packages:
  [1] tools     stats     graphics  grDevices utils     datasets  methods  
  [8] base     
  
  other attached packages:
  [1] SimInf_9.6.0
  
  loaded via a namespace (and not attached):
  [1] MASS_7.3-60.2  compiler_4.4.0 Matrix_1.7-0   grid_4.4.0     digest_0.6.35 
  [6] lattice_0.22-6
  > 
  > ## Check invalid u0
  > res <- assertError(SISe3(u0 = "u0"))
  > check_error(res, "Missing columns in u0.")
  > 
  > u0 <- data.frame(S_1 = c(0, 1, 2, 3, 4, 5),
  +                  I_1 = c(0, 0, 0, 0, 0, 0),
  +                  S_2 = c(0, 1, 2, 3, 4, 5),
  +                  I_2 = c(0, 0, 0, 0, 0, 0),
  +                  S_3 = c(0, 1, 2, 3, 4, 5),
  +                  I_3 = c(0, 0, 0, 0, 0, 0))
  > 
  > ## Check missing columns in u0
  > res <- assertError(
  +     SISe3(u0 = u0[, c("I_1", "S_2", "I_2", "S_3", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3(u0 = u0[, c("S_1", "S_2", "I_2", "S_3", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3(u0 = u0[, c("S_1", "I_1", "I_2", "S_3", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3(u0 = u0[, c("S_1", "I_1", "S_2", "S_3", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3(u0 = u0[, c("S_1", "I_1", "S_2", "I_2", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3(u0 = u0[, c("S_1", "I_1", "S_2", "I_2", "S_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > ## Check default phi
  > res <- SISe3(u0        = u0,
  +              tspan     = seq_len(10) - 1,
  +              events    = NULL,
  +              upsilon_1 = 0.0357,
  +              upsilon_2 = 0.0357,
  +              upsilon_3 = 0.00935,
  +              gamma_1   = 0.1,
  +              gamma_2   = 0.1,
  +              gamma_3   = 0.1,
  +              alpha     = 1.0,
  +              beta_t1   = 0.19,
  +              beta_t2   = 0.085,
  +              beta_t3   = 0.075,
  +              beta_t4   = 0.185,
  +              end_t1    = 91,
  +              end_t2    = 182,
  +              end_t3    = 273,
  +              end_t4    = 365,
  +              epsilon   = 0.000011)
  > stopifnot(identical(res@v0,
  +                     structure(c(0, 0, 0, 0, 0, 0),
  +                               .Dim = c(1L, 6L),
  +                               .Dimnames = list("phi", NULL))))
  > 
  > ## Check missing upsilon_1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'upsilon_1' must be numeric of length 1.")
  > 
  > ## Check missing upsilon_2
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'upsilon_2' must be numeric of length 1.")
  > 
  > ## Check missing upsilon_3
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'upsilon_3' must be numeric of length 1.")
  > 
  > ## Check missing gamma_1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'gamma_1' must be numeric of length 1.")
  > 
  > ## Check missing gamma_2
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'gamma_2' must be numeric of length 1.")
  > 
  > ## Check missing gamma_3
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'gamma_3' must be numeric of length 1.")
  > 
  > ## Check missing alpha
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'alpha' must be numeric of length 1.")
  > 
  > ## Check missing beta_t1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t1' must be numeric of length 1.")
  > 
  > ## Check missing beta_t2
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t2' must be numeric of length 1.")
  > 
  > ## Check missing beta_t3
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t3' must be numeric of length 1.")
  > 
  > ## Check missing beta_t4
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t4' must be numeric of length 1.")
  > 
  > ## Check missing end_t1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t1' is missing.")
  > 
  > ## Check missing end_t2
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t2' is missing.")
  > 
  > ## Check missing end_t3
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t3' is missing.")
  > 
  > ## Check missing end_t4
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t4' is missing.")
  > 
  > ## Check missing epsilon
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365))
  > check_error(res, "'epsilon' must be numeric of length 1.")
  > 
  > ## Check non-numeric upsilon_1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = "0.0357",
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'upsilon_1' must be numeric of length 1.")
  > 
  > ## Check non-numeric upsilon_2
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = "0.0357",
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'upsilon_2' must be numeric of length 1.")
  > 
  > ## Check non-numeric upsilon_3
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = "0.00935",
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'upsilon_3' must be numeric of length 1.")
  > 
  > ## Check non-numeric gamma_1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = "0.1",
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'gamma_1' must be numeric of length 1.")
  > 
  > ## Check non-numeric gamma_2
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = "0.1",
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'gamma_2' must be numeric of length 1.")
  > 
  > ## Check non-numeric gamma_3
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = "0.1",
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'gamma_3' must be numeric of length 1.")
  > 
  > ## Check non-numeric alpha
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = "1.0",
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'alpha' must be numeric of length 1.")
  > 
  > ## Check non-numeric beta_t1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = "0.19",
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t1' must be numeric of length 1.")
  > 
  > ## Check non-numeric beta_t2
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = "0.085",
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t2' must be numeric of length 1.")
  > 
  > ## Check non-numeric beta_t3
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = "0.075",
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t3' must be numeric of length 1.")
  > 
  > ## Check non-numeric beta_t4
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = "0.185",
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t4' must be numeric of length 1.")
  > 
  > ## Check non-integer end_t1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = "91",
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t1' must be integer.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91.5,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t1' must be integer.")
  > 
  > ## Check non-integer end_t2
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = "182",
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t2' must be integer.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182.5,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t2' must be integer.")
  > 
  > ## Check non-integer end_t3
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = "273",
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t3' must be integer.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273.5,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t3' must be integer.")
  > 
  > ## Check non-integer end_t4
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = "365",
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t4' must be integer.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365.5,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t4' must be integer.")
  > 
  > ## Check non-numeric epsilon
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = "0.000011"))
  > check_error(res, "'epsilon' must be numeric of length 1.")
  > 
  > ## Check that length of upsilon_1 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = c(0.0357, 0.0357),
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'upsilon_1' must be numeric of length 1.")
  > 
  > ## Check that length of upsilon_2 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = c(0.0357, 0.0357),
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'upsilon_2' must be numeric of length 1.")
  > 
  > ## Check that length of upsilon_3 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = c(0.00935, 0.00935),
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'upsilon_3' must be numeric of length 1.")
  > 
  > ## Check that length of gamma_1 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = c(0.1, 0.1),
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'gamma_1' must be numeric of length 1.")
  > 
  > ## Check that length of gamma_2 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = c(0.1, 0.1),
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'gamma_2' must be numeric of length 1.")
  > 
  > ## Check that length of gamma_3 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = c(0.1, 0.1),
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'gamma_3' must be numeric of length 1.")
  > 
  > ## Check that length of alpha equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = c(1.0, 1.0),
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'alpha' must be numeric of length 1.")
  > 
  > ## Check that length of beta_t1 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = c(0.19, 0.19),
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t1' must be numeric of length 1.")
  > 
  > ## Check that length of beta_t2 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = c(0.085, 0.085),
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t2' must be numeric of length 1.")
  > 
  > ## Check that length of beta_t3 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = c(0.075, 0.075),
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t3' must be numeric of length 1.")
  > 
  > ## Check that length of beta_t4 equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = c(0.185, 0.185),
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'beta_t4' must be numeric of length 1.")
  > 
  > ## Check that length of epsilon equals 1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = c(0.000011, 0.000011)))
  > check_error(res, "'epsilon' must be numeric of length 1.")
  > 
  > ## Check interval endpoints
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = -1,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t1' must be greater than or equal to '0'.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 18,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t1' must be less than 'end_t2'.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 173,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(
  +     res,
  +     "'end_t2' must be less than 'end_t3' or 'end_t3' less than 'end_t1'.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 365,
  +                          end_t4    = 365,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t3' must be less than '364'.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = -1,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t4' must be greater than or equal to '0'.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 366,
  +                          epsilon   = 0.000011))
  > check_error(res, "'end_t4' must be less than or equal to '365'.")
  > 
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = seq_len(10) - 1,
  +                          events    = NULL,
  +                          phi       = rep(1, 6),
  +                          upsilon_1 = 0.0357,
  +                          upsilon_2 = 0.0357,
  +                          upsilon_3 = 0.00935,
  +                          gamma_1   = 0.1,
  +                          gamma_2   = 0.1,
  +                          gamma_3   = 0.1,
  +                          alpha     = 1.0,
  +                          beta_t1   = 0.19,
  +                          beta_t2   = 0.085,
  +                          beta_t3   = 0.075,
  +                          beta_t4   = 0.185,
  +                          end_t1    = 4:9,
  +                          end_t2    = 5:10,
  +                          end_t3    = c(8:12, 16),
  +                          end_t4    = c(2, 11:15),
  +                          epsilon   = 0.000011))
  > check_error(
  +     res,
  +     "'end_t4' must be less than 'end_t1' or greater than 'end_t3'.")
  > 
  > ## Check extraction of data from 'suscpetible', and 'infected'
  > ## compartments
  > model <- SISe3(u0        = u0,
  +                tspan     = seq_len(10) - 1,
  +                events    = NULL,
  +                phi       = rep(0, 6),
  +                upsilon_1 = 0.0357,
  +                upsilon_2 = 0.0357,
  +                upsilon_3 = 0.00935,
  +                gamma_1   = 0.1,
  +                gamma_2   = 0.1,
  +                gamma_3   = 0.1,
  +                alpha     = 1.0,
  +                beta_t1   = 0.19,
  +                beta_t2   = 0.085,
  +                beta_t3   = 0.075,
  +                beta_t4   = 0.185,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0.000011)
  > 
  > set.seed(123)
  > result <- run(model)
  > 
  > S_expected <- structure(c(0L, 1L, 2L, 3L, 4L, 5L, 0L, 1L, 2L, 3L, 4L, 5L, 0L,
  +                           1L, 2L, 3L, 4L, 5L, 0L, 1L, 2L, 3L, 4L, 5L, 0L, 1L,
  +                           2L, 3L, 4L, 5L, 0L, 1L, 2L, 3L, 4L, 5L, 0L, 1L, 2L,
  +                           3L, 4L, 5L, 0L, 1L, 2L, 3L, 4L, 5L, 0L, 1L, 2L, 3L,
  +                           4L, 5L, 0L, 1L, 2L, 3L, 4L, 5L),
  +                         .Dim = c(6L, 10L))
  > S_observed <- trajectory(result, compartments = "S_1", format = "matrix")
  > stopifnot(identical(S_observed, S_expected))
  > 
  > I_expected <- structure(c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
  +                         .Dim = c(6L, 10L))
  > I_observed <- trajectory(result, compartments = "I_1", format = "matrix")
  > stopifnot(identical(I_observed, I_expected))
  > 
  > ## Check SISe3 plot method
  > pdf_file <- tempfile(fileext = ".pdf")
  > pdf(pdf_file)
  > plot(result)
  > dev.off()
  null device 
            1 
  > stopifnot(file.exists(pdf_file))
  > unlink(pdf_file)
  > 
  > ## Check that C SISe3 run function fails for misspecified SISe3 model
  > res <- assertError(.Call(SimInf:::SISe3_run, NULL, NULL))
  > check_error(res, "Invalid model.")
  > 
  > res <- assertError(.Call(SimInf:::SISe3_run, "SISe3", NULL))
  > check_error(res, "Invalid model.")
  > 
  > ## Check error non-finite v
  > model <- SISe3(u0        = u0,
  +                tspan     = seq_len(10) - 1,
  +                events    = NULL,
  +                phi       = rep(1, 6),
  +                upsilon_1 = 0.0357,
  +                upsilon_2 = 0.0357,
  +                upsilon_3 = 0.00935,
  +                gamma_1   = 0.1,
  +                gamma_2   = 0.1,
  +                gamma_3   = 0.1,
  +                alpha     = 1.0,
  +                beta_t1   = 0.19,
  +                beta_t2   = 0.085,
  +                beta_t3   = 0.075,
  +                beta_t4   = 0.185,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0.000011)
  > model@gdata["beta_t1"] <- Inf
  > model@gdata["beta_t2"] <- Inf
  > model@gdata["beta_t3"] <- Inf
  > model@gdata["beta_t4"] <- Inf
  > res <- assertError(run(model))
  > check_error(res, "The continuous state 'v' is not finite.")
  > 
  > ## Check negative v
  > model <- SISe3(u0        = u0,
  +                tspan     = seq_len(10) - 1,
  +                events    = NULL,
  +                phi       = rep(1, 6),
  +                upsilon_1 = 0.0357,
  +                upsilon_2 = 0.0357,
  +                upsilon_3 = 0.00935,
  +                gamma_1   = 0.1,
  +                gamma_2   = 0.1,
  +                gamma_3   = 0.1,
  +                alpha     = 1.0,
  +                beta_t1   = 0.19,
  +                beta_t2   = 0.085,
  +                beta_t3   = 0.075,
  +                beta_t4   = 0.185,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = -10.000011)
  > res <- assertError(run(model))
  > check_error(res, "The continuous state 'v' is negative.")
  > 
  > proc.time()
     user  system elapsed 
     1.67    0.25    1.89 
Running the tests in 'tests/SISe3_sp.R' failed.
Complete output:
  > ## This file is part of SimInf, a framework for stochastic
  > ## disease spread simulations.
  > ##
  > ## Copyright (C) 2015 Pavol Bauer
  > ## Copyright (C) 2017 -- 2019 Robin Eriksson
  > ## Copyright (C) 2015 -- 2019 Stefan Engblom
  > ## Copyright (C) 2015 -- 2020 Stefan Widgren
  > ##
  > ## SimInf is free software: you can redistribute it and/or modify
  > ## it under the terms of the GNU General Public License as published by
  > ## the Free Software Foundation, either version 3 of the License, or
  > ## (at your option) any later version.
  > ##
  > ## SimInf is distributed in the hope that it will be useful,
  > ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  > ## GNU General Public License for more details.
  > ##
  > ## You should have received a copy of the GNU General Public License
  > ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
  > 
  > library(SimInf)
  > library(tools)
  > source("util/check.R")
  > 
  > ## Specify the number of threads to use.
  > set_num_threads(1)
  > 
  > ## For debugging
  > sessionInfo()
  R Under development (unstable) (2024-03-22 r86169 ucrt)
  Platform: x86_64-w64-mingw32/x64
  Running under: Windows Server 2022 x64 (build 20348)
  
  Matrix products: default
  
  
  locale:
  [1] LC_COLLATE=C                 LC_CTYPE=German_Germany.utf8
  [3] LC_MONETARY=C                LC_NUMERIC=C                
  [5] LC_TIME=C                   
  
  time zone: Europe/Berlin
  tzcode source: internal
  
  attached base packages:
  [1] tools     stats     graphics  grDevices utils     datasets  methods  
  [8] base     
  
  other attached packages:
  [1] SimInf_9.6.0
  
  loaded via a namespace (and not attached):
  [1] MASS_7.3-60.2  compiler_4.4.0 Matrix_1.7-0   grid_4.4.0     digest_0.6.35 
  [6] lattice_0.22-6
  > 
  > ## Check invalid u0
  > res <- assertError(SISe3_sp(u0 = "u0"))
  > check_error(res, "Missing columns in u0.")
  > 
  > u0 <- data.frame(S_1 = c(0, 1, 2, 3, 4, 5, 6, 7, 8),
  +                  I_1 = c(0, 0, 0, 0, 0, 0, 0, 0, 0),
  +                  S_2 = c(0, 1, 2, 3, 4, 5, 6, 7, 8),
  +                  I_2 = c(0, 0, 0, 0, 0, 0, 0, 0, 0),
  +                  S_3 = c(0, 1, 2, 3, 4, 5, 6, 7, 8),
  +                  I_3 = c(0, 0, 0, 0, 0, 0, 0, 0, 0))
  > 
  > ## Place nodes in a grid
  > distance <- expand.grid(x = seq_len(3),
  +                         y = seq_len(3))
  > distance <- distance_matrix(distance$x, distance$y, 2)
  > 
  > ## Check missing columns in u0
  > res <- assertError(
  +     SISe3_sp(u0 = u0[, c("I_1", "S_2", "I_2", "S_3", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3_sp(u0 = u0[, c("S_1", "S_2", "I_2", "S_3", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3_sp(u0 = u0[, c("S_1", "I_1", "I_2", "S_3", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3_sp(u0 = u0[, c("S_1", "I_1", "S_2", "S_3", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3_sp(u0 = u0[, c("S_1", "I_1", "S_2", "I_2", "I_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > res <- assertError(
  +     SISe3_sp(u0 = u0[, c("S_1", "I_1", "S_2", "I_2", "S_3")]))
  > check_error(res, "Missing columns in u0.")
  > 
  > ## Check default phi
  > res <- SISe3_sp(u0        = u0,
  +                 tspan     = seq_len(10) - 1,
  +                 events    = NULL,
  +                 upsilon_1 = 0.0357,
  +                 upsilon_2 = 0.0357,
  +                 upsilon_3 = 0.00935,
  +                 gamma_1   = 0.1,
  +                 gamma_2   = 0.1,
  +                 gamma_3   = 0.1,
  +                 alpha     = 1.0,
  +                 beta_t1   = 0.19,
  +                 beta_t2   = 0.085,
  +                 beta_t3   = 0.075,
  +                 beta_t4   = 0.185,
  +                 end_t1    = 91,
  +                 end_t2    = 182,
  +                 end_t3    = 273,
  +                 end_t4    = 365,
  +                 coupling  = 0.0005,
  +                 distance  = distance)
  > stopifnot(identical(res@v0,
  +                     structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0),
  +                               .Dim = c(1L, 9L),
  +                               .Dimnames = list("phi", NULL))))
  > 
  > ## Check missing upsilon_1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'upsilon_1' must be numeric of length 1.")
  > 
  > ## Check missing upsilon_2
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'upsilon_2' must be numeric of length 1.")
  > 
  > ## Check missing upsilon_3
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'upsilon_3' must be numeric of length 1.")
  > 
  > ## Check missing gamma_1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'gamma_1' must be numeric of length 1.")
  > 
  > ## Check missing gamma_2
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'gamma_2' must be numeric of length 1.")
  > 
  > ## Check missing gamma_3
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'gamma_3' must be numeric of length 1.")
  > 
  > ## Check missing alpha
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'alpha' must be numeric of length 1.")
  > 
  > ## Check missing beta_t1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t1' must be numeric of length 1.")
  > 
  > ## Check missing beta_t2
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t2' must be numeric of length 1.")
  > 
  > ## Check missing beta_t3
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t3' must be numeric of length 1.")
  > 
  > ## Check missing beta_t4
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t4' must be numeric of length 1.")
  > 
  > ## Check missing end_t1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t1' is missing.")
  > 
  > ## Check missing end_t2
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t2' is missing.")
  > 
  > ## Check missing end_t3
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t3' is missing.")
  > 
  > ## Check missing end_t4
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t4' is missing.")
  > 
  > ## Check missing coupling
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             distance  = distance))
  > check_error(res, "'coupling' must be numeric of length 1.")
  > 
  > ## Check missing distance
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005))
  > check_error(res, "'distance' is missing.")
  > 
  > ## Check negative distance
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = -distance))
  > check_error(res, "All values in the 'distance' matrix must be >= 0.")
  > 
  > ## Check non-numeric upsilon_1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = "0.0357",
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'upsilon_1' must be numeric of length 1.")
  > 
  > ## Check non-numeric upsilon_2
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = "0.0357",
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'upsilon_2' must be numeric of length 1.")
  > 
  > ## Check non-numeric upsilon_3
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = "0.00935",
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'upsilon_3' must be numeric of length 1.")
  > 
  > ## Check non-numeric gamma_1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = "0.1",
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'gamma_1' must be numeric of length 1.")
  > 
  > ## Check non-numeric gamma_2
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = "0.1",
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'gamma_2' must be numeric of length 1.")
  > 
  > ## Check non-numeric gamma_3
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = "0.1",
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'gamma_3' must be numeric of length 1.")
  > 
  > ## Check non-numeric alpha
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = "1.0",
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'alpha' must be numeric of length 1.")
  > 
  > ## Check non-numeric beta_t1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = "0.19",
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t1' must be numeric of length 1.")
  > 
  > ## Check non-numeric beta_t2
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = "0.085",
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t2' must be numeric of length 1.")
  > 
  > ## Check non-numeric beta_t3
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = "0.075",
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t3' must be numeric of length 1.")
  > 
  > ## Check non-numeric beta_t4
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = "0.185",
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t4' must be numeric of length 1.")
  > 
  > ## Check non-integer end_t1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = "91",
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t1' must be integer.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91.5,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t1' must be integer.")
  > 
  > ## Check non-integer end_t2
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = "182",
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t2' must be integer.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182.5,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t2' must be integer.")
  > 
  > ## Check non-integer end_t3
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = "273",
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t3' must be integer.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273.5,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t3' must be integer.")
  > 
  > ## Check non-integer end_t4
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = "365",
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t4' must be integer.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365.5,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t4' must be integer.")
  > 
  > ## Check non-numeric coupling
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = "0.0005",
  +                             distance  = distance))
  > check_error(res, "'coupling' must be numeric of length 1.")
  > 
  > ## Check that length of upsilon_1 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = c(0.0357, 0.0357),
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'upsilon_1' must be numeric of length 1.")
  > 
  > ## Check that length of upsilon_2 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = c(0.0357, 0.0357),
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'upsilon_2' must be numeric of length 1.")
  > 
  > ## Check that length of upsilon_3 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = c(0.00935, 0.00935),
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'upsilon_3' must be numeric of length 1.")
  > 
  > ## Check that length of gamma_1 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = c(0.1, 0.1),
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'gamma_1' must be numeric of length 1.")
  > 
  > ## Check that length of gamma_2 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = c(0.1, 0.1),
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'gamma_2' must be numeric of length 1.")
  > 
  > ## Check that length of gamma_3 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = c(0.1, 0.1),
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'gamma_3' must be numeric of length 1.")
  > 
  > ## Check that length of alpha equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = c(1.0, 1.0),
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'alpha' must be numeric of length 1.")
  > 
  > ## Check that length of beta_t1 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = c(0.19, 0.19),
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t1' must be numeric of length 1.")
  > 
  > ## Check that length of beta_t2 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = c(0.085, 0.085),
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t2' must be numeric of length 1.")
  > 
  > ## Check that length of beta_t3 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = c(0.075, 0.075),
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t3' must be numeric of length 1.")
  > 
  > ## Check that length of beta_t4 equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = c(0.185, 0.185),
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'beta_t4' must be numeric of length 1.")
  > 
  > ## Check that length of coupling equals 1
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = c(0.0005, 0.0005),
  +                             distance  = distance))
  > check_error(res, "'coupling' must be numeric of length 1.")
  > 
  > ## Check interval endpoints
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = -1,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t1' must be greater than or equal to '0'.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 18,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t1' must be less than 'end_t2'.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 173,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(
  +     res,
  +     "'end_t2' must be less than 'end_t3' or 'end_t3' less than 'end_t1'.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 365,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t3' must be less than '364'.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = -1,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t4' must be greater than or equal to '0'.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 366,
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(res, "'end_t4' must be less than or equal to '365'.")
  > 
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 4:12,
  +                             end_t2    = 5:13,
  +                             end_t3    = c(8:15, 19),
  +                             end_t4    = c(2, 11:18),
  +                             coupling  = 0.0005,
  +                             distance  = distance))
  > check_error(
  +     res,
  +     "'end_t4' must be less than 'end_t1' or greater than 'end_t3'.")
  > 
  > ## Check distance matrix
  > res <- assertError(SISe3_sp(u0        = u0,
  +                             tspan     = seq_len(10) - 1,
  +                             events    = NULL,
  +                             phi       = rep(1, nrow(u0)),
  +                             upsilon_1 = 0.0357,
  +                             upsilon_2 = 0.0357,
  +                             upsilon_3 = 0.00935,
  +                             gamma_1   = 0.1,
  +                             gamma_2   = 0.1,
  +                             gamma_3   = 0.1,
  +                             alpha     = 1.0,
  +                             beta_t1   = 0.19,
  +                             beta_t2   = 0.085,
  +                             beta_t3   = 0.075,
  +                             beta_t4   = 0.185,
  +                             end_t1    = 91,
  +                             end_t2    = 182,
  +                             end_t3    = 273,
  +                             end_t4    = 365,
  +                             coupling  = 0.0005,
  +                             distance  = as.matrix(distance)))
  > check_error(res, "The 'distance' argument must be of type 'dgCMatrix'.")
  > 
  > ## Check extraction of data from 'suscpetible', and 'infected'
  > ## compartments
  > model <- SISe3_sp(u0        = u0,
  +                   tspan     = seq_len(10) - 1,
  +                   events    = NULL,
  +                   phi       = rep(0, nrow(u0)),
  +                   upsilon_1 = 0.0357,
  +                   upsilon_2 = 0.0357,
  +                   upsilon_3 = 0.00935,
  +                   gamma_1   = 0.1,
  +                   gamma_2   = 0.1,
  +                   gamma_3   = 0.1,
  +                   alpha     = 1.0,
  +                   beta_t1   = 0.19,
  +                   beta_t2   = 0.085,
  +                   beta_t3   = 0.075,
  +                   beta_t4   = 0.185,
  +                   end_t1    = 91,
  +                   end_t2    = 182,
  +                   end_t3    = 273,
  +                   end_t4    = 365,
  +                   coupling  = 0.0005,
  +                   distance  = distance)
  > 
  > result <- run(model)
  > 
  > S_expected <- structure(c(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  +                           0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  +                           0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  +                           0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  +                           0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  +                           0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  +                           0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  +                           0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  +                           0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
  +                           0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L),
  +                         .Dim = 9:10)
  > S_observed <- trajectory(result, compartments = "S_1", format = "matrix")
  > stopifnot(identical(S_observed, S_expected))
  > 
  > I_expected <- structure(c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
  +                         .Dim = 9:10)
  > I_observed <- trajectory(result, compartments = "I_1", format = "matrix")
  > stopifnot(identical(I_observed, I_expected))
  > 
  > ## Check SISe3_sp plot method
  > pdf_file <- tempfile(fileext = ".pdf")
  > pdf(pdf_file)
  > plot(result)
  > dev.off()
  null device 
            1 
  > stopifnot(file.exists(pdf_file))
  > unlink(pdf_file)
  > 
  > ## Check that C SISe3_sp run function fails for misspecified SISe3_sp model
  > res <- assertError(.Call(SimInf:::SISe3_sp_run, NULL, NULL))
  > check_error(res, "Invalid model.")
  > 
  > res <- assertError(.Call(SimInf:::SISe3_sp_run, "SISe3_sp", NULL))
  > check_error(res, "Invalid model.")
  > 
  > ## Check error non-finite v
  > model <- SISe3_sp(u0        = u0,
  +                   tspan     = seq_len(10) - 1,
  +                   events    = NULL,
  +                   phi       = rep(1, nrow(u0)),
  +                   upsilon_1 = 0.0357,
  +                   upsilon_2 = 0.0357,
  +                   upsilon_3 = 0.00935,
  +                   gamma_1   = 0.1,
  +                   gamma_2   = 0.1,
  +                   gamma_3   = 0.1,
  +                   alpha     = 1.0,
  +                   beta_t1   = 0.19,
  +                   beta_t2   = 0.085,
  +                   beta_t3   = 0.075,
  +                   beta_t4   = 0.185,
  +                   end_t1    = 91,
  +                   end_t2    = 182,
  +                   end_t3    = 273,
  +                   end_t4    = 365,
  +                   coupling  = 0.0005,
  +                   distance  = distance)
  > model@gdata["beta_t1"] <- Inf
  > model@gdata["beta_t2"] <- Inf
  > model@gdata["beta_t3"] <- Inf
  > model@gdata["beta_t4"] <- Inf
  > res <- assertError(run(model))
  > check_error(res, "The continuous state 'v' is not finite.")
  > 
  > ## Check negative v
  > u0 <- data.frame(S_1 = c(0, 1, 2, 3, 4, 5, 6, 7, 8),
  +                  I_1 = c(10, 10, 10, 10, 10, 10, 10, 10, 10),
  +                  S_2 = c(0, 1, 2, 3, 4, 5, 6, 7, 8),
  +                  I_2 = c(10, 10, 10, 10, 10, 10, 10, 10, 10),
  +                  S_3 = c(0, 1, 2, 3, 4, 5, 6, 7, 8),
  +                  I_3 = c(10, 10, 10, 10, 10, 10, 10, 10, 10))
  > model <- SISe3_sp(u0        = u0,
  +                   tspan     = seq_len(10) - 1,
  +                   events    = NULL,
  +                   phi       = rep(1, nrow(u0)),
  +                   upsilon_1 = 0,
  +                   upsilon_2 = 0,
  +                   upsilon_3 = 0,
  +                   gamma_1   = 0,
  +                   gamma_2   = 0,
  +                   gamma_3   = 0,
  +                   alpha     = -1.0,
  +                   beta_t1   = 0.19,
  +                   beta_t2   = 0.085,
  +                   beta_t3   = 0.075,
  +                   beta_t4   = 0.185,
  +                   end_t1    = 91,
  +                   end_t2    = 182,
  +                   end_t3    = 273,
  +                   end_t4    = 365,
  +                   coupling  = 0.0005,
  +                   distance  = distance)
  > res <- assertError(run(model))
  > check_error(res, "The continuous state 'v' is negative.")
  > 
  > proc.time()
     user  system elapsed 
     1.71    0.18    1.90 
Running the tests in 'tests/density_ratio.R' failed.
Complete output:
  > ## This file is part of SimInf, a framework for stochastic
  > ## disease spread simulations.
  > ##
  > ## Copyright (C) 2015 -- 2022 Stefan Widgren
  > ##
  > ## SimInf is free software: you can redistribute it and/or modify
  > ## it under the terms of the GNU General Public License as published by
  > ## the Free Software Foundation, either version 3 of the License, or
  > ## (at your option) any later version.
  > ##
  > ## SimInf is distributed in the hope that it will be useful,
  > ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  > ## GNU General Public License for more details.
  > ##
  > ## You should have received a copy of the GNU General Public License
  > ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
  > 
  > library(SimInf)
  > library(tools)
  > source("util/check.R")
  > 
  > ## Define a tolerance
  > tol <- 1e-8
  > 
  > res <- assertError(SimInf:::KLIEP(xnu = 1:5))
  > check_error(res, "'xnu' must be a numeric matrix.")
  > 
  > res <- assertError(SimInf:::KLIEP(xnu = matrix(letters)))
  > check_error(res, "'xnu' must be a numeric matrix.")
  > 
  > res <- assertError(SimInf:::KLIEP(xnu = matrix(1:5),
  +                                   xde = 1:5))
  > check_error(res, "'xde' must be a numeric matrix.")
  > 
  > res <- assertError(SimInf:::KLIEP(xnu = matrix(1:5),
  +                                   xde = matrix(letters)))
  > check_error(res, "'xde' must be a numeric matrix.")
  > 
  > res <- assertError(SimInf:::KLIEP(xnu = matrix(1:5),
  +                                   xde = matrix(1:10, ncol = 2)))
  > check_error(res, "'xnu' and 'xde' must have the same dimension.")
  > 
  > k_exp <- list(
  +     centers = matrix(
  +         c(0.15866887259293, 0.0678276402346609, 0.140392419061464,
  +           0.297264725500235, 0.194414701474047, 0.136348568491747,
  +           0.40738289937909, 0.226893928121722, 0.0957028661881928,
  +           0.199255825468578, 0.0906202016799841, 0.0651901007465582,
  +           0.340891146381286, 0.0221757252037811, 0.251443293760272,
  +           0.233696373688884, 0.245285345806801, 0.282122243710531,
  +           0.183996980651875, 0.155587801061997, 0.23623719736897,
  +           0.385624453117312, 0.0766884886471079, 0.217190288594464,
  +           0.272087625521246, 0.191005160486847, 0.176291185042765,
  +           0.26645299522167, 0.199366909494725, 0.188687665150672,
  +           0.209050540274438, 0.162332143633923, 0.110247814369777,
  +           0.174723745274005, 0.192941180078945, 0.156050020488564,
  +           0.17262122101169, 0.219429265228376, 0.187264664691927,
  +           0.292336619686751, 0.168645667329794, 0.38603919086155,
  +           0.142122083866479, 0.0759774352533857, 0.367529364474216,
  +           0.283510749608552, 0.0863755850544872, 0.315267500971573,
  +           0.283288311869081, 0.252267470851217, 0.143901238832785,
  +           0.225396271939338, 0.195764515532828, 0.241329396487559,
  +           0.38610864675768, 0.273746592096926, 0.236746772291844,
  +           0.253719705914935, 0.130797636094235, 0.121662679370646,
  +           0.0978921887152071, 0.319063856330577, 0.137441608707457,
  +           0.244879577694815, 0.130278292557011, 0.294239291713624,
  +           0.540738920164133, 0.0745158238185157, 0.0409575255349674,
  +           0.161926402244349, 0.30689095927618, 0.188308468635559,
  +           0.207801353962278, 0.141861815352828, 0.312800316971911,
  +           0.407610355082073, 0.106205843062612, 0.208626668653456,
  +           0.221705712061752, 0.37907914771765, 0.205768084249932,
  +           0.143259161148373, 0.148219068865941, 0.124138278373792,
  +           0.207149312653065, 0.317870994771287, 0.245488958190045,
  +           0.261707136592386, 0.219646257028471, 0.0753423072309183,
  +           0.0888801775603571, 0.164757366465784, 0.132298971172881,
  +           0.186812090357893, 0.183962194121917, 0.228458906250619,
  +           0.0964876847601211, 0.52094974480679, 0.124497981806903,
  +           0.191842811335265, 0.0515374062088796, 0.0423087931492029,
  +           0.136021344641827, 0.211539205414427, 0.124575203763823,
  +           0.104910939380527, 0.255662481689383, 0.111622455964317,
  +           0.0590789151177758, 0.0890987214162981, 0.0656564189872087,
  +           0.0325122458500823, 0.148133093093331, 0.0285428832857261,
  +           0.108433186961055, 0.123193738499165, 0.119879169818851,
  +           0.134116543632999, 0.159979420406585, 0.160031744169813,
  +           0.102443013589625, 0.195547459676763, 0.0366325308080599,
  +           0.0884917758507539, 0.100595819168217, 0.0648211116294286,
  +           0.101022618623991, 0.0938443848302465, 0.0820824998035653,
  +           0.1384129854365, 0.0981588345971509, 0.0780951004908632,
  +           0.0532600339311397, 0.0754266654215426, 0.0766432975610597,
  +           0.0756280593781778, 0.105486651851484, 0.119046449484794,
  +           0.0810388139483554, 0.0747910886165144, 0.0849266860385628,
  +           0.164388920883296, 0.117010024068742, 0.0674909409846359,
  +           0.199433752166282, 0.172688651087249, 0.0851615424568608,
  +           0.162002743603335, 0.234356325079822, 0.0932027534341367,
  +           0.0961431960412654, 0.195109847073779, 0.0957595833538713,
  +           0.152480371229507, 0.225506427061178, 0.149819862536592,
  +           0.0990468959517521, 0.0845553147391475, 0.0893564012949097,
  +           0.0836900287340116, 0.0642620155669707, 0.157536904523274,
  +           0.114683945022786, 0.0774623906378795, 0.046271964584089,
  +           0.0968015628314825, 0.267913675484394, 0.034055638151969,
  +           0.0611366869107128, 0.0821267584650991, 0.164231315677943,
  +           0.110397951208684, 0.101164994119577, 0.0762658768913305,
  +           0.164155964134603, 0.276974860176674, 0.0648854876513018,
  +           0.0746397850171394, 0.197673097768591, 0.20059932293895,
  +           0.062554986150949, 0.058377381226075, 0.106652092554706,
  +           0.0807704115256616, 0.0766435024075708, 0.201904889647503,
  +           0.1302722829521, 0.163767058143673, 0.112078157618444,
  +           0.0646474146538829, 0.0536435978452884, 0.110937935009356,
  +           0.0875181065146079, 0.0665930697567526, 0.117516037265074,
  +           0.127155750461157, 0.0415853024057675, 0.234418314627975,
  +           0.103126229751343, 0.110674595150279),
  +         nrow = 100,
  +         ncol = 2,
  +         dimnames = list(NULL, c("beta", "gamma"))),
  +     sigma = 0.0900000000000001,
  +     weights = matrix(
  +         c(0.0380537949460922, 0, 0.00953022456724182, 0,
  +           0.0545506417191683, 0.0136099531913631, 0,
  +           0.0599194032745142, 0, 0.0744886113269028, 0, 0, 0, 0,
  +           0.0453889492172151, 0.0459055541634079, 0.040275497981034,
  +           0, 0.0215211596779569, 0.00916479725954, 0.0615642382007064,
  +           0, 0, 0.0759996060092404, 0.0313696976511586,
  +           0.0719362066942132, 0.0588367276404031, 0.0424801950121562,
  +           0.0759451255085902, 0.042012366822696, 0.0726088654384141,
  +           0.04832300333276, 0, 0.0609241805582585, 0.073794155461691,
  +           0.0405468793392079, 0.0544007225250696, 0.0569824911748279,
  +           0.0704443800108572, 0.027828374312413, 0.0551391150842738,
  +           0, 0.0185721709838352, 0, 0, 0, 0, 0, 0, 0.0559589196006985,
  +           0.0248420024758804, 0, 0.0713512514177033,
  +           0.0074609129698774, 0, 0, 0.0634950734680829,
  +           0.0595572971595476, 0.00617316370837994, 0, 0, 0,
  +           0.0132836792304521, 0.0686726369931549, 0,
  +           0.00972054508183379, 0, 0, 0, 0.0480090390852202, 0,
  +           0.0619245756093922, 0.0711300391256782, 0.0213162016924589,
  +           0, 0, 0, 0.078801044543807, 0, 0, 0.0777348268894596,
  +           0.0193836921456208, 0.0287989442758535, 0,
  +           0.0784328304940592, 0, 0.0293327943203392, 0,
  +           0.0624487923252231, 0, 0, 0.0454635927920055,
  +           0.00831508026277209, 0.0695836586138719, 0.0558604197545034,
  +           0.045317672280211, 0, 0, 0, 0.0631340319234454),
  +         nrow = 100,
  +         ncol = 1))
  > 
  > xnu <- matrix(
  +     c(0.209050540274438, 0.0745158238185157, 0.195764515532828,
  +       0.221705712061752, 0.124138278373792, 0.207801353962278,
  +       0.106205843062612, 0.407610355082073, 0.15866887259293,
  +       0.0753423072309183, 0.26645299522167, 0.319063856330577,
  +       0.162332143633923, 0.244879577694815, 0.192941180078945,
  +       0.199255825468578, 0.164757366465784, 0.148219068865941,
  +       0.283510749608552, 0.0759774352533857, 0.245285345806801,
  +       0.0409575255349674, 0.191005160486847, 0.38610864675768,
  +       0.176291185042765, 0.132298971172881, 0.137441608707457,
  +       0.30689095927618, 0.156050020488564, 0.236746772291844,
  +       0.0221757252037811, 0.155587801061997, 0.183996980651875,
  +       0.174723745274005, 0.130797636094235, 0.208626668653456,
  +       0.124497981806903, 0.217190288594464, 0.283288311869081,
  +       0.187264664691927, 0.205768084249932, 0.0863755850544872,
  +       0.253719705914935, 0.194414701474047, 0.540738920164133,
  +       0.312800316971911, 0.188308468635559, 0.0957028661881928,
  +       0.233696373688884, 0.17262122101169, 0.385624453117312,
  +       0.315267500971573, 0.142122083866479, 0.143259161148373,
  +       0.219429265228376, 0.23623719736897, 0.183962194121917,
  +       0.0906202016799841, 0.136348568491747, 0.191842811335265,
  +       0.292336619686751, 0.340891146381286, 0.0964876847601211,
  +       0.294239291713624, 0.251443293760272, 0.317870994771287,
  +       0.226893928121722, 0.282122243710531, 0.143901238832785,
  +       0.207149312653065, 0.121662679370646, 0.0651901007465582,
  +       0.367529364474216, 0.140392419061464, 0.37907914771765,
  +       0.273746592096926, 0.110247814369777, 0.252267470851217,
  +       0.168645667329794, 0.0766884886471079, 0.40738289937909,
  +       0.188687665150672, 0.161926402244349, 0.0978921887152071,
  +       0.225396271939338, 0.219646257028471, 0.199366909494725,
  +       0.0678276402346609, 0.0888801775603571, 0.38603919086155,
  +       0.241329396487559, 0.52094974480679, 0.141861815352828,
  +       0.297264725500235, 0.228458906250619, 0.245488958190045,
  +       0.186812090357893, 0.130278292557011, 0.261707136592386,
  +       0.272087625521246, 0.0981588345971509, 0.034055638151969,
  +       0.0957595833538713, 0.197673097768591, 0.0807704115256616,
  +       0.101164994119577, 0.0648854876513018, 0.276974860176674,
  +       0.0515374062088796, 0.0646474146538829, 0.0938443848302465,
  +       0.157536904523274, 0.0780951004908632, 0.0774623906378795,
  +       0.0766432975610597, 0.0890987214162981, 0.110937935009356,
  +       0.106652092554706, 0.172688651087249, 0.0674909409846359,
  +       0.119879169818851, 0.0611366869107128, 0.0648211116294286,
  +       0.225506427061178, 0.101022618623991, 0.0875181065146079,
  +       0.114683945022786, 0.164231315677943, 0.0756280593781778,
  +       0.0990468959517521, 0.0285428832857261, 0.160031744169813,
  +       0.159979420406585, 0.0754266654215426, 0.0893564012949097,
  +       0.0746397850171394, 0.103126229751343, 0.0884917758507539,
  +       0.234356325079822, 0.0810388139483554, 0.062554986150949,
  +       0.0851615424568608, 0.0845553147391475, 0.124575203763823,
  +       0.267913675484394, 0.164155964134603, 0.110397951208684,
  +       0.0590789151177758, 0.123193738499165, 0.105486651851484,
  +       0.195547459676763, 0.162002743603335, 0.117010024068742,
  +       0.058377381226075, 0.119046449484794, 0.102443013589625,
  +       0.117516037265074, 0.0656564189872087, 0.104910939380527,
  +       0.110674595150279, 0.0747910886165144, 0.148133093093331,
  +       0.0415853024057675, 0.0968015628314825, 0.108433186961055,
  +       0.201904889647503, 0.111622455964317, 0.134116543632999,
  +       0.0961431960412654, 0.0766435024075708, 0.0836900287340116,
  +       0.0325122458500823, 0.199433752166282, 0.136021344641827,
  +       0.20059932293895, 0.149819862536592, 0.0532600339311397,
  +       0.0932027534341367, 0.0849266860385628, 0.0366325308080599,
  +       0.255662481689383, 0.1384129854365, 0.0821267584650991,
  +       0.0642620155669707, 0.195109847073779, 0.112078157618444,
  +       0.0820824998035653, 0.0423087931492029, 0.0536435978452884,
  +       0.164388920883296, 0.152480371229507, 0.234418314627975,
  +       0.0762658768913305, 0.211539205414427, 0.127155750461157,
  +       0.1302722829521, 0.0665930697567526, 0.046271964584089,
  +       0.163767058143673, 0.100595819168217),
  +     nrow = 100,
  +     ncol = 2,
  +     dimnames = list(NULL, c("beta", "gamma")))
  > 
  > xde <- matrix(
  +     c(0.183272171962524, 0.286665854223967, 0.479837846249473,
  +       0.15601028828712, 0.210449104820306, 0.783545816658709,
  +       0.20797940639307, 0.356683426219085, 0.174441339991796,
  +       0.311472528406188, 0.312618137380801, 0.0764995733272139,
  +       0.445794125231028, 0.181688103349505, 0.232886057681369,
  +       0.283768372036866, 0.136282146610161, 0.130875140564847,
  +       0.396320561618403, 0.241626604403328, 0.231073853690387,
  +       0.250068793970613, 0.0562589357124645, 0.233741831667209,
  +       0.0768013963609406, 0.416998012704813, 0.321633596667585,
  +       0.274946732909724, 0.492343227281947, 0.234760541331245,
  +       0.0351504294300505, 0.00462768118336318, 0.0549215455189399,
  +       0.168813987089903, 0.548363336740293, 0.3373051316121,
  +       0.285282623594898, 0.502790385072833, 0.305245346654149,
  +       0.209850450558834, 0.203891991490068, 0.251780046254595,
  +       0.135496909941293, 0.358540661201862, 0.434559157406459,
  +       0.267177639704822, 0.110925026213855, 0.172477486884074,
  +       0.389471792384217, 0.0475096473225209, 0.592008618510323,
  +       0.0637834715323238, 0.351755175160943, 0.532296078329972,
  +       0.142965758271128, 0.0798802260203365, 0.358967523980154,
  +       0.0610254436494506, 0.056619739579847, 0.28894717625466,
  +       0.541032702513395, 0.353258909142117, 0.118184847740171,
  +       0.0207455042648753, 0.366648262596299, 0.35258359702782,
  +       0.231298963794709, 0.73859718912455, 0.437310232535087,
  +       0.0268394414426883, 0.0439902222869838, 0.239840969915543,
  +       0.426775966522104, 0.162472728645736, 0.418788595043238,
  +       0.0443641413560885, 0.164514549442556, 0.276091283834601,
  +       0.00331618899316374, 0.0614586408797554, 0.211634019686239,
  +       0.272021910006331, 0.0286906399781307, 0.195913973197248,
  +       0.243870747037428, 0.084509092537688, 0.156602956261581,
  +       0.48830001923963, 0.393990923407287, 0.279027935004963,
  +       0.306421507881298, 0.451536031671576, 0.358163801994629,
  +       0.470943230882583, 0.293392541192592, 0.250669697018224,
  +       0.331150464295294, 0.110199032567371, 0.294061514519004,
  +       0.11314871862894, 0.164885570883981, 0.347195849130311,
  +       0.257499279206768, 0.138463692230449, 0.102678219062226,
  +       0.491185912902041, 0.182903902689719, 0.267972456314478,
  +       0.0788761659332474, 0.224842131926287, 0.142627875968024,
  +       0.15057723513501, 0.319577154865769, 0.111643597522549,
  +       0.0876810863434334, 0.265308620596188, 0.0767476628197823,
  +       0.18711334426653, 0.173775718516814, 0.128033395103158,
  +       0.0758075168228626, 0.16828057083199, 0.0401116317192869,
  +       0.0715031228906515, 0.157456291177569, 0.233224805571622,
  +       0.306633945820197, 0.088383999557897, 0.432319573117717,
  +       0.0807740526515329, 0.0182882702152279, 0.0141829165881729,
  +       0.0189098241003207, 0.0974922622343302, 0.358440922746488,
  +       0.195073677830819, 0.161261414165878, 0.203945348967322,
  +       0.0997170568342017, 0.130186595008833, 0.166832857126262,
  +       0.140843092109321, 0.068682860907081, 0.190780880742505,
  +       0.364803478566964, 0.161017679173967, 0.0437058713706013,
  +       0.0735456293352288, 0.152536232301707, 0.116827591730613,
  +       0.23819803120759, 0.0432207498853736, 0.159725795711559,
  +       0.286682454237269, 0.0597053540590569, 0.215466962204395,
  +       0.20396405150408, 0.0322257280624139, 0.0456879729855247,
  +       0.127343771245382, 0.416697666000963, 0.20967964395221,
  +       0.0616185025223351, 0.0103845548040148, 0.264579874016758,
  +       0.180492900785837, 0.136746194538531, 0.448328820930334,
  +       0.299207524915843, 0.0279952094744666, 0.0256522139211944,
  +       0.193761077397201, 0.194230298812302, 0.0804125031635778,
  +       0.343782538933508, 0.0525677626216369, 0.0573410031198289,
  +       0.184950750217791, 0.021153881397456, 0.172437288231969,
  +       0.0863828398130232, 0.172160387428454, 0.0200048840605435,
  +       0.112990049529548, 0.150022327520234, 0.0579606391142452,
  +       0.0913381637972474, 0.278382953069656, 0.202267792334234,
  +       0.144094255439136, 0.204313686321642, 0.193647935188636,
  +       0.207302861287417, 0.235093953556966, 0.139972345981802,
  +       0.105469221608851, 0.235051656339251, 0.0974422975213154,
  +       0.0644462895894134, 0.130574863299273),
  +     nrow = 100,
  +     ncol = 2,
  +     dimnames = list(NULL, c("beta", "gamma")))
  > 
  > set.seed(22)
  > k_obs <- SimInf:::KLIEP(xnu, xde)
  > 
  > stopifnot(all(abs(k_exp$centers - k_obs$centers) < tol))
  > stopifnot(all(abs(k_exp$sigma - k_obs$sigma) < tol))
  > stopifnot(all(abs(k_exp$weights - k_obs$weights) < tol))
  > 
  > proc.time()
     user  system elapsed 
     2.07    0.42    2.46 
Running the tests in 'tests/distributions.R' failed.
Complete output:
  > ## This file is part of SimInf, a framework for stochastic
  > ## disease spread simulations.
  > ##
  > ## Copyright (C) 2015 -- 2021 Stefan Widgren
  > ##
  > ## SimInf is free software: you can redistribute it and/or modify
  > ## it under the terms of the GNU General Public License as published by
  > ## the Free Software Foundation, either version 3 of the License, or
  > ## (at your option) any later version.
  > ##
  > ## SimInf is distributed in the hope that it will be useful,
  > ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  > ## GNU General Public License for more details.
  > ##
  > ## You should have received a copy of the GNU General Public License
  > ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
  > 
  > library(SimInf)
  > library(tools)
  > source("util/check.R")
  > 
  > ## Specify the number of threads to use.
  > set_num_threads(1)
  > 
  > ## For debugging
  > sessionInfo()
  R Under development (unstable) (2024-03-22 r86169 ucrt)
  Platform: x86_64-w64-mingw32/x64
  Running under: Windows Server 2022 x64 (build 20348)
  
  Matrix products: default
  
  
  locale:
  [1] LC_COLLATE=C                 LC_CTYPE=German_Germany.utf8
  [3] LC_MONETARY=C                LC_NUMERIC=C                
  [5] LC_TIME=C                   
  
  time zone: Europe/Berlin
  tzcode source: internal
  
  attached base packages:
  [1] tools     stats     graphics  grDevices utils     datasets  methods  
  [8] base     
  
  other attached packages:
  [1] SimInf_9.6.0
  
  loaded via a namespace (and not attached):
  [1] MASS_7.3-60.2  compiler_4.4.0 Matrix_1.7-0   grid_4.4.0     digest_0.6.35 
  [6] lattice_0.22-6
  > 
  > res <- assertError(SimInf:::parse_priors(c(a + b ~ uniform(0, 5),
  +                                            c ~ uniform(0, 1), 4)))
  > check_error(res, "'priors' must be a formula or a list with formula items.")
  > 
  > res <- assertError(SimInf:::parse_priors(4))
  > check_error(res, "'priors' must be a formula or a list with formula items.")
  > 
  > res <- assertError(SimInf:::parse_priors(NULL))
  > check_error(res, "'priors' must be a formula or a list with formula items.")
  > 
  > res <- assertError(SimInf:::parse_priors(mu ~ uniform(0, 1) + normal(0, 1)))
  > check_error(res, "Invalid formula specification for distribution.")
  > 
  > res <- assertError(SimInf:::parse_priors(mu ~ uniform[0, 1]))
  > check_error(res, "Invalid formula specification for distribution.")
  > 
  > res <- assertError(SimInf:::parse_priors(mu ~ unknown(0, 1)))
  > check_error(res, "Unknown distribution: 'unknown'.")
  > 
  > res <- assertError(SimInf:::parse_priors(c(muR ~ uniform(0, 1),
  +                                            muR ~ uniform(0, 1))))
  > check_error(res, "'priors' must have non-duplicated parameter names.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ uniform(1)))
  > check_error(res, "Invalid formula specification for uniform distribution.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ uniform(1, 0)))
  > check_error(res, "Invalid distribution: uniform bounds in wrong order.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ normal(1)))
  > check_error(res, "Invalid formula specification for normal distribution.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ normal(0, -1)))
  > check_error(res, "Invalid distribution: normal variance must be >= 0.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ poisson(1, 2)))
  > check_error(res, "Invalid formula specification for poisson distribution.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ poisson(-1)))
  > check_error(res, "Invalid distribution: lambda must be >= 0.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ normal(0, gamma)))
  > check_error(res, "Invalid formula specification for 'priors'.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ gamma(1)))
  > check_error(res, "Invalid formula specification for gamma distribution.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ gamma(-1, 1)))
  > check_error(res, "Invalid distribution: gamma hyperparameters must be > 0.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ gamma(1, -1)))
  > check_error(res, "Invalid distribution: gamma hyperparameters must be > 0.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ binomial(1)))
  > check_error(res, "Invalid formula specification for binomial distribution.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ binomial(1, NA)))
  > check_error(res, "Invalid formula specification for binomial distribution.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ binomial(1, -1)))
  > check_error(res, "Invalid distribution: binomial hyperparameters must be >= 0.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ binomial(1.1, 0.1)))
  > check_error(res, "Invalid distribution: binomial size must be an integer >= 0.")
  > 
  > res <- assertError(SimInf:::parse_priors(beta ~ binomial(1, 1.1)))
  > check_error(res, "Invalid distribution: binomial probability must be <= 1.")
  > 
  > res <- assertError(SimInf:::parse_priors(~ uniform(1, 5)))
  > check_error(res, "Invalid formula specification for distribution.")
  > 
  > stopifnot(identical(
  +     SimInf:::parse_priors(beta ~ uniform(1, 5)),
  +     data.frame(parameter = "beta", distribution = "uniform",
  +                p1 = 1, p2 = 5, stringsAsFactors = FALSE)))
  > 
  > res <- assertError(
  +     SimInf:::match_priors(
  +                  SIR(u0 = data.frame(S = 99, I = 1, R = 0),
  +                      tspan = 1:100,
  +                      beta = 0.16,
  +                      gamma = 0.077),
  +                  data.frame(parameter = "delta",
  +                             distribution = "uniform",
  +                             p1 = 1,
  +                             p2 = 5)))
  > check_error(
  +     res,
  +     "All parameters in 'priors' must be either in 'gdata' or 'ldata'.")
  > 
  > res <- assertError(
  +     SimInf:::match_priors(
  +                  SIR(u0 = data.frame(S = c(99, 99), I = c(1, 1), R = c(0, 0)),
  +                      tspan = 1:100,
  +                      beta = 0.16,
  +                      gamma = 0.077),
  +                  data.frame(parameter = "beta",
  +                             distribution = "uniform",
  +                             p1 = 1,
  +                             p2 = 5)))
  > check_error(res, "The 'model' must contain one node.")
  > 
  > res <- SimInf:::match_priors(
  +                     SIR(u0 = data.frame(S = 99, I = 1, R = 0),
  +                         tspan = 1:100,
  +                         beta = 0.16,
  +                         gamma = 0.077),
  +                     data.frame(parameter = "beta",
  +                                distribution = "uniform",
  +                                p1 = 1,
  +                                p2 = 5))
  > stopifnot(identical(res, list(pars = 1L, target = "ldata")))
  > 
  > res <- SimInf:::match_priors(
  +                     mparse(transitions = c("S -> beta*S*I/(S+I+R) -> I",
  +                                            "I -> gamma*I -> R"),
  +                            compartments = c("S", "I", "R"),
  +                            gdata = c(beta = 0.16, gamma = 0.077),
  +                            u0 = data.frame(S = 99, I = 1, R = 0),
  +                            tspan = 1:10),
  +                     data.frame(parameter = "beta",
  +                                distribution = "uniform",
  +                                p1 = 1,
  +                                p2 = 5))
  > stopifnot(identical(res, list(pars = 1L, target = "gdata")))
  > 
  > proc.time()
     user  system elapsed 
     1.57    0.14    1.70 
Running the tests in 'tests/match_compartments.R' failed.
Complete output:
  > ## This file is part of SimInf, a framework for stochastic
  > ## disease spread simulations.
  > ##
  > ## Copyright (C) 2015 -- 2020 Stefan Widgren
  > ##
  > ## SimInf is free software: you can redistribute it and/or modify
  > ## it under the terms of the GNU General Public License as published by
  > ## the Free Software Foundation, either version 3 of the License, or
  > ## (at your option) any later version.
  > ##
  > ## SimInf is distributed in the hope that it will be useful,
  > ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  > ## GNU General Public License for more details.
  > ##
  > ## You should have received a copy of the GNU General Public License
  > ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
  > 
  > library(SimInf)
  > library(tools)
  > source("util/check.R")
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = ~S + I,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = FALSE,
  +                                 U = c("S", "I", "R"),
  +                                 V = "phi"),
  +     list(lhs = NULL,
  +          rhs = list(
  +              U = structure(
  +                  1:2,
  +                  .Names = c("S", "I"),
  +                  available_compartments = c("S", "I", "R")),
  +              V = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = "phi")),
  +          condition = NULL)))
  > 
  > res <- assertError(
  +     SimInf:::match_compartments(compartments = ~S + I + phi,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = FALSE,
  +                                 U = c("S", "I", "R"),
  +                                 V = "phi"))
  > check_error(res, "Cannot combine data from different slots.")
  > 
  > res <- assertError(
  +     SimInf:::match_compartments(compartments = phi ~ S + I,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = TRUE,
  +                                 U = c("S", "I", "R"),
  +                                 V = "phi"))
  > check_error(res, "Cannot combine data from different slots.")
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = ~S + I + phi,
  +                                 ok_combine = TRUE,
  +                                 ok_lhs = FALSE,
  +                                 U = c("S", "I", "R"),
  +                                 V = "phi"),
  +     list(lhs = NULL,
  +          rhs = list(
  +              U = structure(
  +                  1:2,
  +                  .Names = c("S", "I"),
  +                  available_compartments = c("S", "I", "R")),
  +              V = structure(
  +                  c(phi = 1L),
  +                  available_compartments = "phi")),
  +          condition = NULL)))
  > 
  > res <- assertError(
  +     SimInf:::match_compartments(compartments = ~S + I + phi + test,
  +                                 ok_combine = TRUE,
  +                                 ok_lhs = FALSE,
  +                                 U = c("S", "I", "R"),
  +                                 V = "phi"))
  > check_error(res, "Non-existing compartment(s) in model: 'test'.")
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = I ~ S + I + R,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = TRUE,
  +                                 U = c("S", "I", "R"),
  +                                 V = "phi"),
  +     list(lhs = list(
  +              U = structure(
  +                  c(I = 2L),
  +                  available_compartments = c("S", "I", "R")),
  +              V = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = "phi")),
  +          rhs = list(
  +              U = structure(
  +                  1:3,
  +                  .Names = c("S", "I", "R"),
  +                  available_compartments = c("S", "I", "R")),
  +              V = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = "phi")),
  +          condition = NULL)))
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = I ~ S + I | R == 0,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = TRUE,
  +                                 U = c("S", "I", "R"),
  +                                 V = "phi"),
  +     list(lhs = list(
  +              U = structure(
  +                  c(I = 2L),
  +                  available_compartments = c("S", "I", "R")),
  +              V = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = "phi")),
  +          rhs = list(
  +              U = structure(
  +                  1:2,
  +                  .Names = c("S", "I"),
  +                  available_compartments = c("S", "I", "R")),
  +              V = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = "phi")),
  +          condition = "R == 0")))
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = ~ S | R == 0,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = FALSE,
  +                                 U = c("S", "I", "R"),
  +                                 V = NULL),
  +     list(lhs = NULL,
  +          rhs = list(
  +              U = structure(
  +                  c(S = 1L),
  +                  available_compartments = c("S", "I", "R")),
  +              V = integer(0)),
  +          condition = "R == 0")))
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = c("S", "E", "I", "R"),
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = FALSE,
  +                                 U = c("S", "E", "I", "R"),
  +                                 V = NULL),
  +     list(lhs = NULL,
  +          rhs = list(
  +              U = structure(
  +                  1:4,
  +                  .Names = c("S", "E", "I", "R"),
  +                  available_compartments = c("S", "E", "I", "R")),
  +              V = integer(0)),
  +          condition = NULL)))
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = c(" S ", " E", "I ", "R"),
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = FALSE,
  +                                 U = c("S", "E", "I", "R"),
  +                                 V = NULL),
  +     list(lhs = NULL,
  +          rhs = list(
  +              U = structure(
  +                  1:4,
  +                  .Names = c("S", "E", "I", "R"),
  +                  available_compartments = c("S", "E", "I", "R")),
  +              V = integer(0)),
  +          condition = NULL)))
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = ~ .,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = FALSE,
  +                                 U = c("S", "I", "R"),
  +                                 V = "phi"),
  +     list(lhs = NULL,
  +          rhs = list(
  +              U = structure(
  +                  1:3,
  +                  .Names = c("S", "I", "R"),
  +                  available_compartments = c("S", "I", "R")),
  +              V = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = "phi")),
  +          condition = NULL)))
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = ~ .,
  +                                 ok_combine = TRUE,
  +                                 ok_lhs = FALSE,
  +                                 U = c("S", "I", "R"),
  +                                 V = "phi"),
  +     list(lhs = NULL,
  +          rhs = list(
  +              U = structure(
  +                  1:3,
  +                  .Names = c("S", "I", "R"),
  +                  available_compartments = c("S", "I", "R")),
  +              V = structure(
  +                  c(phi = 1L),
  +                  available_compartments = "phi")),
  +          condition = NULL)))
  > 
  > res <- assertError(SimInf:::parse_formula_item(""))
  > check_error(res, "No compartments in formula specification.")
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = D ~ .,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = TRUE,
  +                                 U = c("A", "B", "C"),
  +                                 V = c("D", "E", "F")),
  +     list(lhs = list(
  +              U = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = c("A", "B", "C")),
  +              V = structure(
  +                  c(D = 1L),
  +                  available_compartments = c("D", "E", "F"))),
  +          rhs = list(
  +              U = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = c("A", "B", "C")),
  +              V = structure(
  +                  1:3,
  +                  .Names = c("D", "E", "F"),
  +                  available_compartments = c("D", "E", "F"))),
  +          condition = NULL)))
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = . ~ D,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = TRUE,
  +                                 U = c("A", "B", "C"),
  +                                 V = c("D", "E", "F")),
  +     list(lhs = list(
  +              U = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = c("A", "B", "C")),
  +              V = structure(
  +                  1:3,
  +                  .Names = c("D", "E", "F"),
  +                  available_compartments = c("D", "E", "F"))),
  +          rhs = list(
  +              U = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = c("A", "B", "C")),
  +              V = structure(
  +                  c(D = 1L),
  +                  available_compartments = c("D", "E", "F"))),
  +          condition = NULL)))
  > 
  > stopifnot(identical(
  +     SimInf:::match_compartments(compartments = . ~ .,
  +                                 ok_combine = FALSE,
  +                                 ok_lhs = TRUE,
  +                                 U = c("A", "B", "C"),
  +                                 V = c("D", "E", "F")),
  +     list(lhs = list(
  +              U = structure(
  +                  1:3,
  +                  .Names = c("A", "B", "C"),
  +                  available_compartments = c("A", "B", "C")),
  +              V = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = c("D", "E", "F"))),
  +          rhs = list(
  +              U = structure(
  +                  1:3,
  +                  .Names = c("A", "B", "C"),
  +                  available_compartments = c("A", "B", "C")),
  +              V = structure(
  +                  integer(0),
  +                  .Names = character(0),
  +                  available_compartments = c("D", "E", "F"))),
  +          condition = NULL)))
  > 
  > proc.time()
     user  system elapsed 
     1.42    0.12    1.60 
Running the tests in 'tests/phi.R' failed.
Complete output:
  > ## This file is part of SimInf, a framework for stochastic
  > ## disease spread simulations.
  > ##
  > ## Copyright (C) 2015 Pavol Bauer
  > ## Copyright (C) 2017 -- 2019 Robin Eriksson
  > ## Copyright (C) 2015 -- 2019 Stefan Engblom
  > ## Copyright (C) 2015 -- 2021 Stefan Widgren
  > ##
  > ## SimInf is free software: you can redistribute it and/or modify
  > ## it under the terms of the GNU General Public License as published by
  > ## the Free Software Foundation, either version 3 of the License, or
  > ## (at your option) any later version.
  > ##
  > ## SimInf is distributed in the hope that it will be useful,
  > ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  > ## GNU General Public License for more details.
  > ##
  > ## You should have received a copy of the GNU General Public License
  > ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
  > 
  > library(SimInf)
  > 
  > ## Specify the number of threads to use.
  > max_threads <- set_num_threads(1)
  > 
  > ## For debugging
  > sessionInfo()
  R Under development (unstable) (2024-03-22 r86169 ucrt)
  Platform: x86_64-w64-mingw32/x64
  Running under: Windows Server 2022 x64 (build 20348)
  
  Matrix products: default
  
  
  locale:
  [1] LC_COLLATE=C                 LC_CTYPE=German_Germany.utf8
  [3] LC_MONETARY=C                LC_NUMERIC=C                
  [5] LC_TIME=C                   
  
  time zone: Europe/Berlin
  tzcode source: internal
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  other attached packages:
  [1] SimInf_9.6.0
  
  loaded via a namespace (and not attached):
  [1] MASS_7.3-60.2  compiler_4.4.0 Matrix_1.7-0   tools_4.4.0    grid_4.4.0    
  [6] digest_0.6.35  lattice_0.22-6
  > 
  > ## Define a tolerance
  > tol <- 1e-8
  > 
  > ## Expected phi
  > phi_exp <- c(0.810011, 0.185349185610407, 0.0424465987871056,
  +              0.00975507058676853, 0.00227629753002237,
  +              0.000565394139653014, 0.000173994321933323,
  +              8.44545979644941e-05, 6.39707811474e-05,
  +              5.9284740887299e-05, 5.82127251826398e-05,
  +              5.79674823748003e-05, 5.79113786866402e-05,
  +              6.95407791782812e-05, 9.7263016625088e-05,
  +              0.000112148945427821, 0.000120142199101708,
  +              0.000124434313160683, 0.0001267390371,
  +              0.000127976597976407, 0.00012864112742251,
  +              0.000128997957856597, 0.000129189564051683,
  +              0.000129292450270145, 0.000129347696782111,
  +              0.000129377362340141, 0.000131884062252197,
  +              0.000138101356693643, 0.000141703770219126,
  +              0.000143791074163116, 0.000145000496047577,
  +              0.000145701257093339, 0.000146107290793875,
  +              0.000146342554107908, 0.000146478869952767,
  +              0.000146557853833598, 0.000146603618531295,
  +              0.000146630135429847, 0.000146645499803353,
  +              0.000117375145714429, 7.32919208901144e-05,
  +              6.27631756303809e-05, 6.02485121232044e-05,
  +              5.964791514813e-05, 5.95044698221693e-05,
  +              5.94702096403935e-05, 5.94620270102002e-05,
  +              5.94600726879108e-05, 5.94596059216608e-05,
  +              5.94594944401854e-05, 5.94594678141829e-05,
  +              5.94594614548841e-05, 5.91621626358214e-05,
  +              5.81846832104543e-05, 5.79610672710232e-05,
  +              5.79099111166633e-05, 5.78982082294025e-05,
  +              5.78955309841726e-05, 5.78949185163378e-05,
  +              5.78947784033424e-05, 5.78947463499832e-05,
  +              5.78947390172028e-05, 5.78947373396978e-05,
  +              5.78947369559385e-05, 5.78947368681467e-05,
  +              6.3973684217256e-05, 9.42736699178863e-05,
  +              0.000110543764665068, 0.00011928026987988,
  +              0.000123971485546074, 0.000126490513908745,
  +              0.000127843149204895, 0.000128569469825775,
  +              0.000128959480086351, 0.000129168902755875,
  +              0.000129281355834533, 0.000129341739435452,
  +              0.000129374163441121, 0.000130685471048975,
  +              0.000137406871141659, 0.00014130137265387,
  +              0.000143557917692025, 0.000144865400945854,
  +              0.000145622980533292, 0.000146061935930711,
  +              0.000146316274674941, 0.000146463643171141,
  +              0.000146549031159267, 0.000146598506513255,
  +              0.000146627173433579, 0.000146643783568821,
  +              0.000130521651182138, 7.64318047728573e-05,
  +              6.35130989329136e-05, 6.04276222370442e-05,
  +              5.96906934332844e-05, 5.95146868983662e-05,
  +              5.94726498655133e-05, 5.94626098284664e-05,
  +              5.94602118870071e-05)
  > 
  > ## Check phi from the SISe model
  > sis_e <- SISe(u0      = data.frame(S = 100, I = 0),
  +               tspan   = seq(from = 1, to = 700, by = 7),
  +               events  = NULL,
  +               phi     = 1,
  +               upsilon = 0,
  +               gamma   = 0,
  +               alpha   = 0,
  +               beta_t1 = 0.19,
  +               beta_t2 = 0.085,
  +               beta_t3 = 0.075,
  +               beta_t4 = 0.185,
  +               end_t1  = 91,
  +               end_t2  = 182,
  +               end_t3  = 273,
  +               end_t4  = 365,
  +               epsilon = 0.000011)
  > 
  > sis_e <- run(sis_e)
  > sis_e_phi_obs <- trajectory(sis_e, "phi", format = "matrix")[1, ]
  > stopifnot(all(abs(sis_e_phi_obs - phi_exp) < tol))
  > sis_e_phi_obs <- trajectory(sis_e, "phi")$phi
  > stopifnot(all(abs(sis_e_phi_obs - as.numeric(phi_exp)) < tol))
  > 
  > ## Run with sparse V
  > punchcard(sis_e) <- data.frame(time = seq(from = 1, to = 700, by = 7),
  +                                node = 1,
  +                                phi = TRUE)
  > sis_e <- run(sis_e)
  > sis_e_phi_obs <- trajectory(sis_e, "phi", format = "matrix")[1, ]
  > stopifnot(all(abs(sis_e_phi_obs - phi_exp) < tol))
  > sis_e_phi_obs <- trajectory(sis_e, "phi")$phi
  > stopifnot(all(abs(sis_e_phi_obs - as.numeric(phi_exp)) < tol))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     sis_e <- run(sis_e)
  +     set_num_threads(1)
  +     sis_e_phi_obs <- trajectory(sis_e, "phi", format = "matrix")[1, ]
  +     stopifnot(all(abs(sis_e_phi_obs - phi_exp) < tol))
  +     sis_e_phi_obs <- trajectory(sis_e, "phi")$phi
  +     stopifnot(all(abs(sis_e_phi_obs - as.numeric(phi_exp)) < tol))
  + }
  > 
  > ## Check phi from the SISe3 model
  > sis_e3 <- SISe3(u0      = data.frame(S_1 = 10, I_1 = 0,
  +                                      S_2 = 20, I_2 = 0,
  +                                      S_3 = 70, I_3 = 0),
  +                 tspan   = seq(from = 1, to = 700, by = 7),
  +                 events    = NULL,
  +                 phi       = 1,
  +                 upsilon_1 = 0,
  +                 upsilon_2 = 0,
  +                 upsilon_3 = 0,
  +                 gamma_1   = 0,
  +                 gamma_2   = 0,
  +                 gamma_3   = 0,
  +                 alpha     = 0,
  +                 beta_t1   = 0.19,
  +                 beta_t2   = 0.085,
  +                 beta_t3   = 0.075,
  +                 beta_t4   = 0.185,
  +                 end_t1    = 91,
  +                 end_t2    = 182,
  +                 end_t3    = 273,
  +                 end_t4    = 365,
  +                 epsilon   = 0.000011)
  > 
  > sis_e3 <- run(sis_e3)
  > sis_e3_phi_obs <- trajectory(sis_e3, "phi", format = "matrix")[1, ]
  > stopifnot(all(abs(sis_e3_phi_obs - phi_exp) < tol))
  > sis_e3_phi_obs <- trajectory(sis_e3, "phi")$phi
  > stopifnot(all(abs(sis_e3_phi_obs - as.numeric(phi_exp)) < tol))
  > 
  > ## Run with sparse V
  > punchcard(sis_e3) <- data.frame(time = seq(from = 1, to = 700, by = 7),
  +                                 node = 1,
  +                                 phi = TRUE)
  > sis_e3 <- run(sis_e3)
  > sis_e3_phi_obs <- trajectory(sis_e3, "phi", format = "matrix")[1, ]
  > stopifnot(all(abs(sis_e3_phi_obs - phi_exp) < tol))
  > sis_e3_phi_obs <- trajectory(sis_e3, "phi")$phi
  > stopifnot(all(abs(sis_e3_phi_obs - as.numeric(phi_exp)) < tol))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     sis_e3 <- run(sis_e3)
  +     set_num_threads(1)
  +     sis_e3_phi_obs <- trajectory(sis_e3, "phi", format = "matrix")[1, ]
  +     stopifnot(all(abs(sis_e3_phi_obs - phi_exp) < tol))
  +     sis_e3_phi_obs <- trajectory(sis_e3, "phi")$phi
  +     stopifnot(all(abs(sis_e3_phi_obs - as.numeric(phi_exp)) < tol))
  + }
  > 
  > ## Check decay of phi for various configurations of the intervals.
  > ## [1, 2)   1*0.97
  > ## [2, 3)   1*0.97*0.97
  > ## [3, 4)   1*0.97*0.97*0.95
  > ## [4, 5)   1*0.97*0.97*0.95*0.95
  > ## [5, 6)   1*0.97*0.97*0.95*0.95*0.93
  > ## [6, 7)   1*0.97*0.97*0.95*0.95*0.93*0.93
  > ## [7, 8)   1*0.97*0.97*0.95*0.95*0.93*0.93*0.91
  > ## [8, 9)   1*0.97*0.97*0.95*0.95*0.93*0.93*0.91*0.91
  > ## [9, 10)  1*0.97*0.97*0.95*0.95*0.93*0.93*0.91*0.91*0.97
  > ## [10, 11) 1*0.97*0.97*0.95*0.95*0.93*0.93*0.91*0.91*0.97*0.97
  > phi <- c(0.97, 0.9409, 0.893855, 0.84916225, 0.7897208925,
  +          0.734440430025, 0.66834079132275, 0.608190120103702,
  +          0.589944416500591, 0.572246084005574)
  > 
  > model <- SISe(u0 = data.frame(S = 1, I = 0),
  +               tspan = 1:10,
  +               phi = 1,
  +               upsilon = 0,
  +               gamma = 0,
  +               alpha = 0,
  +               beta_t1 = 0.03,
  +               beta_t2 = 0.05,
  +               beta_t3 = 0.07,
  +               beta_t4 = 0.09,
  +               end_t1 = 3,
  +               end_t2 = 5,
  +               end_t3 = 7,
  +               end_t4 = 9,
  +               epsilon = 0)
  > stopifnot(all(abs(phi - trajectory(run(model), ~phi)$phi) < tol))
  > 
  > model <- SISe(u0 = data.frame(S = 1, I = 0),
  +               tspan = 1:10,
  +               phi = 1,
  +               upsilon = 0,
  +               gamma = 0,
  +               alpha = 0,
  +               beta_t1 = 0.05,
  +               beta_t2 = 0.07,
  +               beta_t3 = 0.09,
  +               beta_t4 = 0.03,
  +               end_t1 = 5,
  +               end_t2 = 7,
  +               end_t3 = 9,
  +               end_t4 = 3,
  +               epsilon = 0)
  > stopifnot(all(abs(phi - trajectory(run(model), ~phi)$phi) < tol))
  > 
  > model <- SISe(u0 = data.frame(S = 1, I = 0),
  +               tspan = 1:10,
  +               phi = 1,
  +               upsilon = 0,
  +               gamma = 0,
  +               alpha = 0,
  +               beta_t1 = 0.07,
  +               beta_t2 = 0.09,
  +               beta_t3 = 0.03,
  +               beta_t4 = 0.05,
  +               end_t1 = 7,
  +               end_t2 = 9,
  +               end_t3 = 3,
  +               end_t4 = 5,
  +               epsilon = 0)
  > stopifnot(all(abs(phi - trajectory(run(model), ~phi)$phi) < tol))
  > 
  > proc.time()
     user  system elapsed 
     1.48    0.26    1.95 
Running the tests in 'tests/sample_select.R' failed.
Complete output:
  > ## This file is part of SimInf, a framework for stochastic
  > ## disease spread simulations.
  > ##
  > ## Copyright (C) 2015 Pavol Bauer
  > ## Copyright (C) 2017 -- 2019 Robin Eriksson
  > ## Copyright (C) 2015 -- 2019 Stefan Engblom
  > ## Copyright (C) 2015 -- 2021 Stefan Widgren
  > ##
  > ## SimInf is free software: you can redistribute it and/or modify
  > ## it under the terms of the GNU General Public License as published by
  > ## the Free Software Foundation, either version 3 of the License, or
  > ## (at your option) any later version.
  > ##
  > ## SimInf is distributed in the hope that it will be useful,
  > ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  > ## GNU General Public License for more details.
  > ##
  > ## You should have received a copy of the GNU General Public License
  > ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
  > 
  > library(SimInf)
  > library(tools)
  > source("util/check.R")
  > 
  > ## Specify the number of threads to use.
  > max_threads <- set_num_threads(1)
  > 
  > ## For debugging
  > sessionInfo()
  R Under development (unstable) (2024-03-22 r86169 ucrt)
  Platform: x86_64-w64-mingw32/x64
  Running under: Windows Server 2022 x64 (build 20348)
  
  Matrix products: default
  
  
  locale:
  [1] LC_COLLATE=C                 LC_CTYPE=German_Germany.utf8
  [3] LC_MONETARY=C                LC_NUMERIC=C                
  [5] LC_TIME=C                   
  
  time zone: Europe/Berlin
  tzcode source: internal
  
  attached base packages:
  [1] tools     stats     graphics  grDevices utils     datasets  methods  
  [8] base     
  
  other attached packages:
  [1] SimInf_9.6.0
  
  loaded via a namespace (and not attached):
  [1] MASS_7.3-60.2  compiler_4.4.0 Matrix_1.7-0   grid_4.4.0     digest_0.6.35 
  [6] lattice_0.22-6
  > 
  > ## Test that sample_select in events.c works
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## One individual start in susceptible state in node = 2, with a zero
  > ## probability of becoming infected.
  > ##
  > ## At t = 1, two individuals are moved to node = 1. This should fail.
  > u0 <- data.frame(S_1 = c(0, 1),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 0),
  +                  I_3 = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 2,
  +                      proportion = 1,
  +                      select     = 4,
  +                      shift      = 0)
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:10,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > res <- assertError(run(model))
  Cannot sample 2 for event from 1 individuals.
  
  Current state in node
  ---------------------
  {1, 0, 0, 0, 0, 0}
  
  Current state in dest
  ---------------------
  {0, 0, 0, 0, 0, 0}
  
  Scheduled event
  ---------------
  event: 3 (external transfer event)
  time: 1
  node: 2
  dest: 1
  n: 2
  proportion: 1
  select: 4
  shift: 0
  
  > check_error(res, "Unable to sample individuals for event.")
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     res <- assertError(run(model))
  +     set_num_threads(1)
  +     check_error(res, "Unable to sample individuals for event.")
  + }
  Cannot sample 2 for event from 1 individuals.
  
  Current state in node
  ---------------------
  {1, 0, 0, 0, 0, 0}
  
  Current state in dest
  ---------------------
  {0, 0, 0, 0, 0, 0}
  
  Scheduled event
  ---------------
  event: 3 (external transfer event)
  time: 1
  node: 2
  dest: 1
  n: 2
  proportion: 1
  select: 4
  shift: 0
  
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## One individual start in susceptible state in node = 2, with a zero
  > ## probability of becoming infected.
  > ##
  > ## At t = 1, -1 individuals are moved to node = 1. This should fail.
  > u0 <- data.frame(S_1 = c(0, 1),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 0),
  +                  I_3 = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = -1,
  +                      proportion = 1,
  +                      select     = 4,
  +                      shift      = 0)
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:10,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > res <- assertError(run(model))
  Cannot sample -1 individuals for event.
  
  Current state in node
  ---------------------
  {1, 0, 0, 0, 0, 0}
  
  Current state in dest
  ---------------------
  {0, 0, 0, 0, 0, 0}
  
  Scheduled event
  ---------------
  event: 3 (external transfer event)
  time: 1
  node: 2
  dest: 1
  n: -1
  proportion: 1
  select: 4
  shift: 0
  
  > check_error(res, "Unable to sample individuals for event.")
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     res <- assertError(run(model))
  +     set_num_threads(1)
  +     check_error(res, "Unable to sample individuals for event.")
  + }
  Cannot sample -1 individuals for event.
  
  Current state in node
  ---------------------
  {1, 0, 0, 0, 0, 0}
  
  Current state in dest
  ---------------------
  {0, 0, 0, 0, 0, 0}
  
  Scheduled event
  ---------------
  event: 3 (external transfer event)
  time: 1
  node: 2
  dest: 1
  n: -1
  proportion: 1
  select: 4
  shift: 0
  
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## One individual start in susceptible state in node = 2, with a zero
  > ## probability of becoming infected.
  > ##
  > ## At t = 1, a proportion of 10 individuals are moved to node = 1.
  > ## This should fail.
  > u0 <- data.frame(S_1 = c(0, 1),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 0),
  +                  I_3 = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 0,
  +                      proportion = 10,
  +                      select     = 4,
  +                      shift      = 0)
  > 
  > ## We should not be able to create model with prop = 10
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = 0:10,
  +                          events    = events,
  +                          phi       = rep(0, 2),
  +                          upsilon_1 = 0,
  +                          upsilon_2 = 0,
  +                          upsilon_3 = 0,
  +                          gamma_1   = 1,
  +                          gamma_2   = 1,
  +                          gamma_3   = 1,
  +                          alpha     = 0,
  +                          beta_t1   = 1,
  +                          beta_t2   = 1,
  +                          beta_t3   = 1,
  +                          beta_t4   = 1,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0))
  > check_error(res, "prop must be in the range 0 <= prop <= 1", FALSE)
  > 
  > ## Replace proportion = 10 to proportion = 1
  > events$proportion <- 1
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:10,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > ## Replace proportion = 1 with proportion = 10
  > model@events@proportion <- 10
  > 
  > res <- assertError(.Call(SimInf:::SISe3_run, model, NULL))
  
  Current state in node
  ---------------------
  {1, 0, 0, 0, 0, 0}
  
  Current state in dest
  ---------------------
  {0, 0, 0, 0, 0, 0}
  
  Scheduled event
  ---------------
  event: 3 (external transfer event)
  time: 1
  node: 2
  dest: 1
  n: 0
  proportion: 10
  select: 4
  shift: 0
  
  > check_error(res, "Invalid proportion detected (< 0.0 or > 1.0).")
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     res <- assertError(.Call(SimInf:::SISe3_run, model, NULL))
  +     set_num_threads(1)
  +     check_error(res, "Invalid proportion detected (< 0.0 or > 1.0).")
  + }
  
  Current state in node
  ---------------------
  {1, 0, 0, 0, 0, 0}
  
  Current state in dest
  ---------------------
  {0, 0, 0, 0, 0, 0}
  
  Scheduled event
  ---------------
  event: 3 (external transfer event)
  time: 1
  node: 2
  dest: 1
  n: 0
  proportion: 10
  select: 4
  shift: 0
  
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## One individual start in susceptible state in node = 2, with a zero
  > ## probability of becoming infected.
  > ##
  > ## At t = 1, a proportion of -1 individuals are moved to node = 1.
  > ## This should fail.
  > u0 <- data.frame(S_1 = c(0, 1),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 0),
  +                  I_3 = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 0,
  +                      proportion = -1,
  +                      select     = 4,
  +                      shift      = 0)
  > 
  > ## We should not be able to create model with proportion = -1
  > res <- assertError(SISe3(u0        = u0,
  +                          tspan     = 0:10,
  +                          events    = events,
  +                          phi       = rep(0, 2),
  +                          upsilon_1 = 0,
  +                          upsilon_2 = 0,
  +                          upsilon_3 = 0,
  +                          gamma_1   = 1,
  +                          gamma_2   = 1,
  +                          gamma_3   = 1,
  +                          alpha     = 0,
  +                          beta_t1   = 1,
  +                          beta_t2   = 1,
  +                          beta_t3   = 1,
  +                          beta_t4   = 1,
  +                          end_t1    = 91,
  +                          end_t2    = 182,
  +                          end_t3    = 273,
  +                          end_t4    = 365,
  +                          epsilon   = 0))
  > check_error(res, "prop must be in the range 0 <= prop <= 1", FALSE)
  > 
  > ## Replace proportion = -1 with proportion = 0
  > events$proportion <- 0
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:10,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > ## Replace proportion = 0 with proportion = -1
  > model@events@proportion <- -1
  > 
  > res <- assertError(.Call(SimInf:::SISe3_run, model, NULL))
  
  Current state in node
  ---------------------
  {1, 0, 0, 0, 0, 0}
  
  Current state in dest
  ---------------------
  {0, 0, 0, 0, 0, 0}
  
  Scheduled event
  ---------------
  event: 3 (external transfer event)
  time: 1
  node: 2
  dest: 1
  n: 0
  proportion: -1
  select: 4
  shift: 0
  
  > check_error(res, "Invalid proportion detected (< 0.0 or > 1.0).")
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     res <- assertError(.Call(SimInf:::SISe3_run, model, NULL))
  +     set_num_threads(1)
  +     check_error(res, "Invalid proportion detected (< 0.0 or > 1.0).")
  + }
  
  Current state in node
  ---------------------
  {1, 0, 0, 0, 0, 0}
  
  Current state in dest
  ---------------------
  {0, 0, 0, 0, 0, 0}
  
  Scheduled event
  ---------------
  event: 3 (external transfer event)
  time: 1
  node: 2
  dest: 1
  n: 0
  proportion: -1
  select: 4
  shift: 0
  
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## One individual start in susceptible state in node = 2, with a zero
  > ## probability of becoming infected.
  > ##
  > ## At t = 1, a proportion of 0 individuals are moved to node = 1.
  > u0 <- data.frame(S_1 = c(0, 1),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 0),
  +                  I_3  = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 0,
  +                      proportion = 0,
  +                      select     = 4,
  +                      shift      = 0)
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:2,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > U_expected <- structure(c(0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
  +                           0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L),
  +                         .Dim = c(12L, 3L))
  > 
  > result <- run(model)
  > stopifnot(identical(model@G, result@G))
  > stopifnot(identical(model@S, result@S))
  > stopifnot(identical(trajectory(result, format = "matrix"), U_expected))
  > stopifnot(identical(model@ldata, result@ldata))
  > stopifnot(identical(model@tspan, result@tspan))
  > stopifnot(identical(model@u0, result@u0))
  > stopifnot(identical(model@events, result@events))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     result_omp <- run(model)
  +     set_num_threads(1)
  +     stopifnot(identical(model@G, result_omp@G))
  +     stopifnot(identical(model@S, result_omp@S))
  +     stopifnot(identical(trajectory(result_omp, format = "matrix"), U_expected))
  +     stopifnot(identical(model@ldata, result_omp@ldata))
  +     stopifnot(identical(model@tspan, result_omp@tspan))
  +     stopifnot(identical(model@u0, result_omp@u0))
  +     stopifnot(identical(model@events, result_omp@events))
  + }
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## One individual start in susceptible state in node = 2, with a zero
  > ## probability of becoming infected.
  > ##
  > ## At t = 1, proportion of all (1) individuals are moved to node = 1.
  > u0 <- data.frame(S_1 = c(0, 1),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3  = c(0, 0),
  +                  I_3  = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 1,
  +                      proportion = 0,
  +                      select     = 4,
  +                      shift      = 0)
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:2,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > U_expected <- structure(c(0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
  +                           1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
  +                           1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L),
  +                         .Dim = c(12L, 3L))
  > 
  > result <- run(model)
  > stopifnot(identical(model@G, result@G))
  > stopifnot(identical(model@S, result@S))
  > stopifnot(identical(trajectory(result, format = "matrix"), U_expected))
  > stopifnot(identical(model@ldata, result@ldata))
  > stopifnot(identical(model@tspan, result@tspan))
  > stopifnot(identical(model@u0, result@u0))
  > stopifnot(identical(model@events, result@events))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     result_omp <- run(model)
  +     set_num_threads(1)
  +     stopifnot(identical(model@G, result_omp@G))
  +     stopifnot(identical(model@S, result_omp@S))
  +     stopifnot(identical(trajectory(result_omp, format = "matrix"), U_expected))
  +     stopifnot(identical(model@ldata, result_omp@ldata))
  +     stopifnot(identical(model@tspan, result_omp@tspan))
  +     stopifnot(identical(model@u0, result_omp@u0))
  +     stopifnot(identical(model@events, result_omp@events))
  + }
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## Two individuals start in susceptible state in node = 2, with a zero
  > ## probability of becoming infected.
  > ##
  > ## At t = 1, Nkind = 1, one individual is moved to node = 1.
  > u0 <- data.frame(S_1 = c(0, 2),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 0),
  +                  I_3  = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 1,
  +                      proportion = 0,
  +                      select     = 4,
  +                      shift      = 0)
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:2,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > U_expected <- structure(c(0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L,
  +                           1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
  +                           1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L),
  +                         .Dim = c(12L, 3L))
  > 
  > result <- run(model)
  > stopifnot(identical(model@G, result@G))
  > stopifnot(identical(model@S, result@S))
  > stopifnot(identical(trajectory(result, format = "matrix"), U_expected))
  > stopifnot(identical(model@ldata, result@ldata))
  > stopifnot(identical(model@tspan, result@tspan))
  > stopifnot(identical(model@u0, result@u0))
  > stopifnot(identical(model@events, result@events))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     result_omp <- run(model)
  +     set_num_threads(1)
  +     stopifnot(identical(model@G, result_omp@G))
  +     stopifnot(identical(model@S, result_omp@S))
  +     stopifnot(identical(trajectory(result_omp, format = "matrix"), U_expected))
  +     stopifnot(identical(model@ldata, result_omp@ldata))
  +     stopifnot(identical(model@tspan, result_omp@tspan))
  +     stopifnot(identical(model@u0, result_omp@u0))
  +     stopifnot(identical(model@events, result_omp@events))
  + }
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## Two individuals start in susceptible state and 8 individuals in
  > ## infected state in node = 2, with a zero probability of becoming
  > ## infected.
  > ##
  > ## At t = 1, Nkind = 2, one individual is moved to node = 1.
  > u0 <- data.frame(S_1 = c(0, 2),
  +                  I_1 = c(0, 8),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 0),
  +                  I_3 = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 1,
  +                      proportion = 0,
  +                      select     = 4,
  +                      shift      = 0)
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:2,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 0,
  +                gamma_2   = 0,
  +                gamma_3   = 0,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > U_expected <- structure(c(0L, 0L, 0L, 0L, 0L, 0L, 2L, 8L, 0L, 0L, 0L, 0L,
  +                           0L, 1L, 0L, 0L, 0L, 0L, 2L, 7L, 0L, 0L, 0L, 0L,
  +                           0L, 1L, 0L, 0L, 0L, 0L, 2L, 7L, 0L, 0L, 0L, 0L),
  +                         .Dim = c(12L, 3L))
  > 
  > set.seed(1)
  > result <- run(model)
  > stopifnot(identical(model@G, result@G))
  > stopifnot(identical(model@S, result@S))
  > stopifnot(identical(trajectory(result, format = "matrix"), U_expected))
  > stopifnot(identical(model@ldata, result@ldata))
  > stopifnot(identical(model@tspan, result@tspan))
  > stopifnot(identical(model@u0, result@u0))
  > stopifnot(identical(model@events, result@events))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set.seed(1)
  +     set_num_threads(2)
  +     result_omp <- run(model)
  +     set_num_threads(1)
  +     stopifnot(identical(model@G, result_omp@G))
  +     stopifnot(identical(model@S, result_omp@S))
  +     stopifnot(identical(trajectory(result_omp, format = "matrix"), U_expected))
  +     stopifnot(identical(model@ldata, result_omp@ldata))
  +     stopifnot(identical(model@tspan, result_omp@tspan))
  +     stopifnot(identical(model@u0, result_omp@u0))
  +     stopifnot(identical(model@events, result_omp@events))
  + }
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## Two individuals start in susceptible state in node = 2, with a zero
  > ## probability of becoming infected.
  > ##
  > ## At t = 1, one individual is moved to node = 1 using a select matrix
  > ## that can only select a susceptible from S_1.
  > u0 <- data.frame(S_1 = c(0, 2),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 0),
  +                  I_3 = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 1,
  +                      proportion = 0,
  +                      select     = 1,
  +                      shift      = 0)
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:10,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > U <- structure(
  +     c(0L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
  +       0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
  +       0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
  +       1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
  +       0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
  +       0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L,
  +       1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L,
  +       0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,
  +       0L, 0L, 0L, 0L),
  +     .Dim = c(12L, 11L))
  > 
  > res <- run(model)
  > stopifnot(identical(res@U, U))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     res <- run(model)
  +     set_num_threads(1)
  +     stopifnot(identical(res@U, U))
  + }
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## 6 individuals start in the susceptible compartments in node = 2,
  > ## with a zero probability of becoming infected.
  > ##
  > ## At t = 1, three individuals are moved to node = 1 using a select
  > ## matrix that can select from the susceptible S_1, S_2 and S_3.
  > u0 <- data.frame(S_1 = c(0, 2),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 2),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 2),
  +                  I_3 = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 3,
  +                      proportion = 0,
  +                      select     = 1,
  +                      shift      = 0)
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:10,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > ## Add S_2 and S_3 to first column in select matrix
  > model@events@E[3, 1] <- 1
  > model@events@E[5, 1] <- 1
  > 
  > S_expected <- c(0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)
  > 
  > res <- run(model)
  > S_observed <- colSums(trajectory(res, compartments = c("S_1", "S_2", "S_3"),
  +                                  index = 1, format = "matrix"))
  > stopifnot(identical(S_observed, S_expected))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     res <- run(model)
  +     set_num_threads(1)
  +     S_observed <- colSums(trajectory(res, compartments = c("S_1", "S_2", "S_3"),
  +                                      index = 1, format = "matrix"))
  +     stopifnot(identical(S_observed, S_expected))
  + }
  > 
  > ## 2 Nodes
  > ## 3 Age categories
  > ## 2 Disease-states: Susceptible & Infected
  > ##
  > ## 10 individuals start in susceptible state in node = 2, with a zero
  > ## probability of becoming infected.
  > ##
  > ## At t = 1, a proportion of 0.5 individuals are moved to node = 1.
  > u0 <- data.frame(S_1 = c(0, 10),
  +                  I_1 = c(0, 0),
  +                  S_2 = c(0, 0),
  +                  I_2 = c(0, 0),
  +                  S_3 = c(0, 0),
  +                  I_3 = c(0, 0))
  > 
  > events <- data.frame(event      = 3,
  +                      time       = 1,
  +                      node       = 2,
  +                      dest       = 1,
  +                      n          = 0,
  +                      proportion = 0.5,
  +                      select     = 4,
  +                      shift      = 0)
  > 
  > model <- SISe3(u0        = u0,
  +                tspan     = 0:10,
  +                events    = events,
  +                phi       = rep(0, 2),
  +                upsilon_1 = 0,
  +                upsilon_2 = 0,
  +                upsilon_3 = 0,
  +                gamma_1   = 1,
  +                gamma_2   = 1,
  +                gamma_3   = 1,
  +                alpha     = 0,
  +                beta_t1   = 1,
  +                beta_t2   = 1,
  +                beta_t3   = 1,
  +                beta_t4   = 1,
  +                end_t1    = 91,
  +                end_t2    = 182,
  +                end_t3    = 273,
  +                end_t4    = 365,
  +                epsilon   = 0)
  > 
  > ## In this example, a proportion of 0.5 of 10 animals are scheduled to
  > ## move and this results in 6 being moved because the number of
  > ## animals moved is now sampled from a binomial distribution:
  > set.seed(42)
  > res <- .Call(SimInf:::SISe3_run, model, NULL)
  > stopifnot(identical(res@U[1, 2], 6L))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     set.seed(42)
  +     res <- .Call(SimInf:::SISe3_run, model, NULL)
  +     stopifnot(identical(res@U[1, 2], 6L))
  +     set_num_threads(1)
  + }
  > 
  > ## With a very small proportion, most often, 0 animals are moved:
  > model@events@proportion <- 0.01
  > set.seed(42)
  > res <- .Call(SimInf:::SISe3_run, model, NULL)
  > stopifnot(identical(res@U[1, 2], 0L))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     set.seed(42)
  +     res <- .Call(SimInf:::SISe3_run, model, NULL)
  +     stopifnot(identical(res@U[1, 2], 0L))
  +     set_num_threads(1)
  + }
  > 
  > ## In some cases >0 are moved when 0.01 of 10 animals are scheduled to
  > ## move:
  > set.seed(17)
  > res <- .Call(SimInf:::SISe3_run, model, NULL)
  > stopifnot(identical(res@U[1, 2], 1L))
  > 
  > if (SimInf:::have_openmp() && max_threads > 1) {
  +     set_num_threads(2)
  +     set.seed(17)
  +     res <- .Call(SimInf:::SISe3_run, model, NULL)
  +     stopifnot(identical(res@U[1, 2], 1L))
  +     set_num_threads(1)
  + }
  > 
  > ## 1 Node in a SIR model
  > ##
  > ## One individual starts in S, one in I and one in R with a zero
  > ## probability of becoming infected or recover.
  > ##
  > ## At t = 1, one individual exit, with a higher weight for being
  > ## sampled from the R compartment.
  > model <- SIR(u0 = data.frame(S = 1, I = 1, R = 1),
  +              tspan = 1,
  +              events = data.frame(event      = 0,
  +                                  time       = 1,
  +                                  node       = 1,
  +                                  dest       = 0,
  +                                  n          = 1,
  +                                  proportion = 0,
  +                                  select     = 4,
  +                                  shift      = 0),
  +              beta = 0,
  +              gamma = 0)
  > 
  > ## With equal weight the individual is sampled from the S compartment.
  > set.seed(2)
  > stopifnot(identical(run(model)@U, structure(c(0L, 1L, 1L), .Dim = c(3L, 1L))))
  > 
  > ## With non-equal weight the individual is sampled from the R
  > ## compartment (using the same seed).
  > model@events@E[3, 4] <- 1000
  > set.seed(2)
  > stopifnot(identical(run(model)@U, structure(c(1L, 1L, 0L), .Dim = c(3L, 1L))))
  > 
  > ## Check that an error is raised if there are no non-zero elements in
  > ## the selected column in E.
  > model <- SIR(u0 = data.frame(S = 1, I = 1, R = 1),
  +              tspan = 1,
  +              events = data.frame(event      = 0,
  +                                  time       = 1,
  +                                  node       = 1,
  +                                  dest       = 0,
  +                                  n          = 1,
  +                                  proportion = 0,
  +                                  select     = 4,
  +                                  shift      = 0),
  +              beta = 0,
  +              gamma = 0)
  > 
  > model@events@E <- as(matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0),
  +                             nrow = 3, ncol = 4,
  +                             dimnames = list(c("S", "I", "R"),
  +                                             c("1", "2", "3", "4"))),
  +                      "dgCMatrix")
  > 
  > res <- assertError(run(model))
  No states to sample from.
  Cannot sample 1 for event from 0 individuals.
  
  Current state in node
  ---------------------
  {1, 1, 1}
  
  Scheduled event
  ---------------
  event: 0 (exit event)
  time: 1
  node: 1
  dest: 0
  n: 1
  proportion: 0
  select: 4
  shift: 0
  
  > check_error(res, "Unable to sample individuals for event.")
  > 
  > ## Change to an enter event
  > model@events@event <- 1L
  > res <- assertError(run(model))
  No states to sample from.
  Cannot sample 1 for event from 0 individuals.
  
  Current state in node
  ---------------------
  {1, 1, 1}
  
  Scheduled event
  ---------------
  event: 1 (enter event)
  time: 1
  node: 1
  dest: 0
  n: 1
  proportion: 0
  select: 4
  shift: 0
  
  > check_error(res, "Unable to sample individuals for event.")
  > 
  > ## Change to enter event and n = -1
  > model@events@n <- -1L
  > res <- assertError(run(model))
  No states to sample from.
  Cannot sample -1 individuals for event.
  
  Current state in node
  ---------------------
  {1, 1, 1}
  
  Scheduled event
  ---------------
  event: 1 (enter event)
  time: 1
  node: 1
  dest: 0
  n: -1
  proportion: 0
  select: 4
  shift: 0
  
  > check_error(res, "Unable to sample individuals for event.")
  > 
  > ## Change to enter event and proportion = -1
  > model@events@E <- as(matrix(c(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1),
  +                             nrow = 3, ncol = 4,
  +                             dimnames = list(c("S", "I", "R"),
  +                                             c("1", "2", "3", "4"))),
  +                      "dgCMatrix")
  > model@events@n <- 0L
  > model@events@proportion <- -1
  > res <- assertError(.Call(SimInf:::SIR_run, model, NULL))
  
  Current state in node
  ---------------------
  {1, 1, 1}
  
  Scheduled event
  ---------------
  event: 1 (enter event)
  time: 1
  node: 1
  dest: 0
  n: 0
  proportion: -1
  select: 4
  shift: 0
  
  > check_error(res, "Invalid proportion detected (< 0.0 or > 1.0).")
  > 
  > ## Change to enter event and proportion = 1.1
  > model@events@n <- 0L
  > model@events@proportion <- 1.1
  > res <- assertError(.Call(SimInf:::SIR_run, model, NULL))
  
  Current state in node
  ---------------------
  {1, 1, 1}
  
  Scheduled event
  ---------------
  event: 1 (enter event)
  time: 1
  node: 1
  dest: 0
  n: 0
  proportion: 1.1
  select: 4
  shift: 0
  
  > check_error(res, "Invalid proportion detected (< 0.0 or > 1.0).")
  > 
  > ## Check that proportion works for an enter event.
  > model@events@n <- 0L
  > model@events@proportion <- 0.1
  > model@events@select <- 1L
  > set.seed(3)
  > stopifnot(identical(run(model)@U, structure(c(2L, 1L, 1L), .Dim = c(3L, 1L))))
  > 
  > ## Check that an enter event fails with shift without N.
  > model@events@n <- 1L
  > model@events@shift <- 1L
  > model@events@proportion <- 0
  > res <- assertError(run(model))
  Scheduled event
  ---------------
  event: 1 (enter event)
  time: 1
  node: 1
  dest: 0
  n: 1
  proportion: 0
  select: 1
  shift: 1
  
  > check_error(res, "'N' is invalid.")
  > 
  > ## Check that shift fails for an enter event when the shift is out of
  > ## bounds.
  > model@events@N <- matrix(c(3L, 0L, 0L),
  +                          nrow = 3, ncol = 1,
  +                          dimnames = list(c("S", "I", "R"), "1"))
  > res <- assertError(run(model))
  Scheduled event
  ---------------
  event: 1 (enter event)
  time: 1
  node: 1
  dest: 0
  n: 1
  proportion: 0
  select: 1
  shift: 1
  
  > check_error(res, "'shift' is out of bounds.")
  > 
  > model@events@N <- matrix(c(-1L, 0L, 0L),
  +                          nrow = 3, ncol = 1,
  +                          dimnames = list(c("S", "I", "R"), "1"))
  > res <- assertError(run(model))
  Scheduled event
  ---------------
  event: 1 (enter event)
  time: 1
  node: 1
  dest: 0
  n: 1
  proportion: 0
  select: 1
  shift: 1
  
  > check_error(res, "'shift' is out of bounds.")
  > 
  > ## Check that shift works for an enter event.
  > model@events@N <- matrix(c(1L, 0L, 0L),
  +                          nrow = 3, ncol = 1,
  +                          dimnames = list(c("S", "I", "R"), "1"))
  > stopifnot(identical(run(model)@U, structure(c(1L, 2L, 1L), .Dim = c(3L, 1L))))
  > 
  > proc.time()
     user  system elapsed 
     1.62    0.21    1.85 
Running the tests in 'tests/v0.R' failed.
Complete output:
  > ## This file is part of SimInf, a framework for stochastic
  > ## disease spread simulations.
  > ##
  > ## Copyright (C) 2015 -- 2022 Stefan Widgren
  > ##
  > ## SimInf is free software: you can redistribute it and/or modify
  > ## it under the terms of the GNU General Public License as published by
  > ## the Free Software Foundation, either version 3 of the License, or
  > ## (at your option) any later version.
  > ##
  > ## SimInf is distributed in the hope that it will be useful,
  > ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  > ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  > ## GNU General Public License for more details.
  > ##
  > ## You should have received a copy of the GNU General Public License
  > ## along with this program.  If not, see <https://www.gnu.org/licenses/>.
  > 
  > library(SimInf)
  > library(tools)
  > source("util/check.R")
  > 
  > model <- SIR(u0     = data.frame(S = 1:3, I = 4:6, R = 7:9),
  +              tspan  = 1:10,
  +              events = NULL,
  +              beta   = 0,
  +              gamma  = 0)
  > 
  > res <- assertError(
  +     v0(model) <- data.frame(phi = 10:13))
  > check_error(res, "The number of rows in 'v0' must match nodes in 'model'.")
  > 
  > v0(model) <- data.frame(phi = 1:3)
  > stopifnot(identical(model@v0, matrix(numeric(0), nrow = 0, ncol = 0)))
  > 
  > ## Check that a matrix is coerced to a data.frame.
  > res <- SimInf:::check_v0(matrix(1:9,
  +                                 ncol = 3,
  +                                 dimnames = list(NULL, c("A", "B", "C"))),
  +                          c("A", "B", "C"))
  > stopifnot(identical(res,
  +                     data.frame(A = 1:3,
  +                                B = 4:6,
  +                                C = 7:9)))
  > 
  > ## Create an 'SISe' model with 6 nodes.
  > model <- SISe(u0 = data.frame(S = 100:105, I = 1:6), tspan = 1:10,
  +               phi = rep(0, 6), upsilon = 0.02, gamma = 0.1, alpha = 1,
  +               epsilon = 1.1e-5, beta_t1 = 0.15, beta_t2 = 0.15,
  +               beta_t3 = 0.15, beta_t4 = 0.15, end_t1 = 91, end_t2 = 182,
  +               end_t3 = 273, end_t4 = 365)
  > 
  > res <- assertError(
  +     v0(model) <- data.frame(A = 1:6))
  > check_error(res, "Missing columns in 'v0'.")
  > 
  > v0(model) <- data.frame(phi = 1:6)
  > stopifnot(identical(model@v0,
  +                     matrix(c(1, 2, 3, 4, 5, 6),
  +                            nrow = 1,
  +                            ncol = 6,
  +                            dimnames = list("phi", NULL))))
  > 
  > proc.time()
     user  system elapsed 
     1.26    0.25    1.43