nosoi (version 1.0.0)

singleDiscrete: Single-host pathogen in a structured (discrete) host population

Description

This function, that can be wrapped within nosoiSim, runs a single-host transmission chain simulation, with a discrete host population structure (e.g. spatial, socio-economic, etc.). 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.

Usage

singleDiscrete(length.sim, max.infected, init.individuals, init.structure,
  structure.matrix, diff.pExit = FALSE, timeDep.pExit = FALSE,
  hostCount.pExit = FALSE, pExit, param.pExit, diff.pMove = FALSE,
  timeDep.pMove = FALSE, hostCount.pMove = FALSE, pMove, param.pMove,
  diff.nContact = FALSE, timeDep.nContact = FALSE,
  hostCount.nContact = FALSE, nContact, param.nContact,
  diff.pTrans = FALSE, timeDep.pTrans = FALSE,
  hostCount.pTrans = FALSE, pTrans, param.pTrans, prefix.host = "H",
  print.progress = TRUE, print.step = 10)

Value

An object of class nosoiSim, containing all results of the simulation.

Structure Matrix

The structure matrix provided provided should of class matrix, with the same number of rows and columns, rows representing departure state and column the arrival state. All rows should add to 1.

Structure Parameters

The pMove function should return a single probability (a number between 0 and 1).

The use of diff (switch to TRUE) makes the corresponding function use the argument current.in (for "currently in"). Your function should in that case give a result for every possible discrete state.

The use of hostCount (switch to TRUE) makes the corresponding function use the argument host.count.

Order of Arguments

The user specified function's arguments should follow this order: t (mandatory), prestime (optional, only if timeDep is TRUE), current.in (optional, only if diff is TRUE), host.count (optional, only if hostCount is TRUE) and parameters specified in the list.

Details

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").

See Also

For simulations with a structure in continuous space, see singleContinuous. For simulations without any structures, see singleNone.

Examples

Run this code
# NOT RUN {
t_incub_fct <- function(x){rnorm(x,mean = 5,sd=1)}
p_max_fct <- function(x){rbeta(x,shape1 = 5,shape2=2)}
p_Exit_fct  <- function(t){return(0.08)}
p_Move_fct  <- function(t){return(0.1)}

proba <- function(t,p_max,t_incub){
 if(t <= t_incub){p=0}
 if(t >= t_incub){p=p_max}
 return(p)
}

time_contact = function(t){round(rnorm(1, 3, 1), 0)}

transition.matrix = matrix(c(0,0.2,0.4,0.5,0,0.6,0.5,0.8,0),
                           nrow = 3, ncol = 3,
                           dimnames=list(c("A","B","C"),c("A","B","C")))

set.seed(805)
test.nosoiA <- nosoiSim(type="single", popStructure="discrete",
                       length=20,
                       max.infected=100,
                       init.individuals=1,
                       init.structure="A",
                       structure.matrix=transition.matrix,
                       pMove=p_Move_fct,
                       param.pMove=NA,
                       nContact=time_contact,
                       param.nContact=NA,
                       pTrans = proba,
                       param.pTrans = list(p_max=p_max_fct,
                                           t_incub=t_incub_fct),
                      pExit=p_Exit_fct,
                      param.pExit=NA)
# }

Run the code above in your browser using DataLab