nosoi (version 1.0.0)

singleContinuous: Single-host pathogen in a structured (continuous) host population

Description

This function runs a single-host transmission chain simulation, with a structured host population (such as spatial features) in a continuous space. 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 passed. The movement of hosts on the continuous space map is a random walk (Brownian motion) that can be modified towards a biased random walk where hosts tend to be attracted to higher values of the environmental variable defined by the raster.

Usage

singleContinuous(length.sim, max.infected, init.individuals,
  init.structure, structure.raster, 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.sdMove = FALSE, timeDep.sdMove = FALSE,
  hostCount.sdMove = FALSE, sdMove, param.sdMove,
  attracted.by.raster = FALSE, 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.

Raster

The structure raster provided provided should of class raster. High values of the environmental variable can attract hosts if attracted.by.raster is TRUE.

Structure Parameters

The pMove function should return a single probability (a number between 0 and 1), and sdMove a real number (keep in mind this number is related to your coordinate space).

The use of diff (switch to TRUE) makes the corresponding function use the argument current.env.value (for "current environmental value").

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.env.value (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 discrete structure, see singleDiscrete. For simulations without any structures, see singleNone.

Examples

Run this code
# NOT RUN {
library(raster)
#Generating a raster the for movement
set.seed(860)

test.raster <- raster(nrows=100, ncols=100, xmn=-50, xmx=50, ymn=-50,ymx=50)
test.raster[] <- runif(10000, -80, 180)
test.raster <- focal(focal(test.raster, w=matrix(1, 5, 5), mean), w=matrix(1, 5, 5), mean)

t_incub_fct <- function(x){rnorm(x,mean = 5,sd=1)}
p_max_fct <- function(x){rbeta(x,shape1 = 5,shape2=2)}
p_Move_fct  <- function(t){return(0.1)}

sdMove_fct = function(t,current.env.value){return(100/(current.env.value+1))}

p_Exit_fct  <- function(t){return(0.08)}

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)}

start.pos <- c(0,0)

test.nosoiA <- nosoiSim(type="single", popStructure="continuous",
                   length=200,
                   max.infected=500,
                   init.individuals=1,
                   init.structure=start.pos,
                   structure.raster=test.raster,
                   pMove=p_Move_fct,
                   param.pMove=NA,
                   diff.sdMove=TRUE,
                   sdMove=sdMove_fct,
                   param.sdMove=NA,
                   attracted.by.raster=TRUE,
                   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 DataCamp Workspace