This function, that can be wrapped within nosoiSim
, runs a dual-host transmission chain simulation, without any structure features in both hosts populations. The simulation stops either at
the end of given time (specified by length.sim
) or when the number of hosts infected threshold (max.infected
) is crossed.
dualNone( length.sim, max.infected.A, max.infected.B, init.individuals.A, init.individuals.B, pExit.A, param.pExit.A, timeDep.pExit.A = FALSE, nContact.A, param.nContact.A, timeDep.nContact.A = FALSE, pTrans.A, param.pTrans.A, timeDep.pTrans.A = FALSE, prefix.host.A = "H", pExit.B, param.pExit.B, timeDep.pExit.B = FALSE, nContact.B, param.nContact.B, timeDep.nContact.B = FALSE, pTrans.B, param.pTrans.B, timeDep.pTrans.B = FALSE, prefix.host.B = "V", print.progress = TRUE, print.step = 10 )
length.sim | specifies the length (in unit of time) over which the simulation should be run. |
---|---|
max.infected.A | specifies the maximum number of individual hosts A that can be infected in the simulation. |
max.infected.B | specifies the maximum number of individual hosts B that can be infected in the simulation. |
init.individuals.A | number of initially infected individuals (hosts A). |
init.individuals.B | number of initially infected individuals (hosts B). |
pExit.A | function that gives the probability to exit the simulation for an infected host A (either moving out, dying, etc.). |
param.pExit.A | parameter names (list of functions) for the pExit for host-type A. |
timeDep.pExit.A | is pExit of host-type A dependent on the absolute time of the simulation (TRUE/FALSE)? |
nContact.A | function that gives the number of potential transmission events per unit of time for host-type A. |
param.nContact.A | parameter names (list of functions) for param.nContact for host-type A. |
timeDep.nContact.A | is nContact of host-type A dependent on the absolute time of the simulation (TRUE/FALSE)? |
pTrans.A | function that gives the probability of transmit a pathogen as a function of time since infection for host A. |
param.pTrans.A | parameter names (list of functions) for the pExit for host A. |
timeDep.pTrans.A | is pTrans of host-type A dependent on the absolute time of the simulation (TRUE/FALSE)? |
prefix.host.A | character(s) to be used as a prefix for the host A identification number. |
pExit.B | function that gives the probability to exit the simulation for an infected host B (either moving out, dying, etc.). |
param.pExit.B | parameter names (list of functions) for the pExit for host-type B. |
timeDep.pExit.B | is pExit of host-type B dependent on the absolute time of the simulation (TRUE/FALSE)? |
nContact.B | function that gives the number of potential transmission events per unit of time for host B. |
param.nContact.B | parameter names (list of functions) for param.nContact for host-type B. |
timeDep.nContact.B | is nContact of host-type B dependent on the absolute time of the simulation (TRUE/FALSE)? |
pTrans.B | function that gives the probability of transmit a pathogen as a function of time since infection for host B. |
param.pTrans.B | parameter names (list of functions) for the pExit for host-type B. |
timeDep.pTrans.B | is pTrans of host-type B dependent on the absolute time of the simulation (TRUE/FALSE)? |
prefix.host.B | character(s) to be used as a prefix for the host B identification number. |
print.progress | if TRUE, displays a progress bar (current time/length.sim). |
print.step | print.progress is TRUE, step with which the progress message will be printed. |
An object of class nosoiSim
, containing all results of the simulation.
The pExit
and pTrans
functions should return a single probability (a number between 0 and 1), and nContact
a positive natural number (positive integer) or 0.
The param
arguments should be a list of functions or NA. Each item name in the parameter list should have the same name as the argument in the corresponding function.
The use of timeDep
(switch to TRUE
) makes the corresponding function use the argument prestime
(for "present time").
The suffix .A
or .B
specifies if the considered function or parameter concerns host type A or B.
The user specified function's arguments should follow this order: t
(mandatory), prestime
(optional, only if timeDep is TRUE), parameters
specified in the list.
For simulations with a discrete structured host population, see dualDiscrete
. For simulations with a structured population in continuous space, dualContinuous
# \donttest{ #Host A t_infectA_fct <- function(x){rnorm(x,mean = 12,sd=3)} pTrans_hostA <- function(t,t_infectA){ if(t/t_infectA <= 1){p=sin(pi*t/t_infectA)} if(t/t_infectA > 1){p=0} return(p) } p_Exit_fctA <- function(t,t_infectA){ if(t/t_infectA <= 1){p=0} if(t/t_infectA > 1){p=1} return(p) } time_contact_A = function(t){sample(c(0,1,2),1,prob=c(0.2,0.4,0.4))} #Host B t_incub_fct_B <- function(x){rnorm(x,mean = 5,sd=1)} p_max_fct_B <- function(x){rbeta(x,shape1 = 5,shape2=2)} p_Exit_fct_B <- function(t,prestime){(sin(prestime/12)+1)/5} pTrans_hostB <- function(t,p_max,t_incub){ if(t <= t_incub){p=0} if(t >= t_incub){p=p_max} return(p) } time_contact_B = function(t){round(rnorm(1, 3, 1), 0)} set.seed(90) test.nosoi <- nosoiSim(type="dual", popStructure="none", length.sim=40, max.infected.A=100, max.infected.B=200, init.individuals.A=1, init.individuals.B=0, pExit.A = p_Exit_fctA, param.pExit.A = list(t_infectA = t_infectA_fct), timeDep.pExit.A=FALSE, nContact.A = time_contact_A, param.nContact.A = NA, timeDep.nContact.A=FALSE, pTrans.A = pTrans_hostA, param.pTrans.A = list(t_infectA=t_infectA_fct), timeDep.pTrans.A=FALSE, prefix.host.A="H", pExit.B = p_Exit_fct_B, param.pExit.B = NA, timeDep.pExit.B=TRUE, nContact.B = time_contact_B, param.nContact.B = NA, timeDep.nContact.B=FALSE, pTrans.B = pTrans_hostB, param.pTrans.B = list(p_max=p_max_fct_B, t_incub=t_incub_fct_B), timeDep.pTrans.B=FALSE, prefix.host.B="V")#>#>#>#>#>#>#>#>test.nosoi#> A nosoiSim object, representing a simulated epidemy for a dual host with no structure. #> The simulation has run for 39 units of time and a total of 71 (A) and 71 (B) hosts have been infected. #> Use function 'summary' for summary statistics, and functions 'getTableHosts' and 'getTableState' to extract the generated data.# }