Example MACRO Simulation

Initialize the Classes Needed for MACRO

In this simulation run we will use the PfSI enhanced SIS module of Plasmodium falciparum transmission. Additionally because mosquitoes are not simulated individually in MACRO (they are simulated by integer-valued difference equations), we need the SimBitePfSI module to queue infectious bites on human hosts. We also need to initialize the Aquatic Ecology module we wish to use, in this case we choose Emerge. To fully initialize all interacting classes we need to run the following code:

# attach the MASH package
library(MASH)

# initialize classes for MACRO
MACRO.Humans.Setup()

# setup class methods for PfSI and SimBite modules
# MACRO relies on SimBitePfSI module for adding bites to humans
PfSI.Setup()
SimBitePfSI.Setup()

# MACRO Patch initialization
MACRO.Patch.Emerge.Setup() # 'Emerge' model

Generate MACRO Objects

Now that all classes have had the necessary methods, fields, and pointers added to their R6Class Class generator objects, we need to instantiate the specific objects for our simulation run. We can do that as follows on a simple metapopulation tile of 10 patches.

# 10 patches in the tile
nPatch = 10

tileParameters = MACRO.Tile.Parameters(N = nPatch,aquaModel = "emerge",aquaPars = list(N=nPatch,lambda=rep(50,nPatch)))
tileParameters$MacroMosquitoPop_PAR$M_density = rep(200,nPatch)
tile = MacroTile$new(MacroTile_PAR = tileParameters)

Simulate MACRO

We are finally ready to run the main simulation. There is only one last step and that is to initialize the human infection for PfSI module. We will run for 500 days.

tile$init_PfSI(PfPR = rep(0.15,nPatch))
tile$simMacro(5e2)

Analysis of Output

pfsiHist = tile$get_HumanPop()$get_History()
plot_PfSI(pfsiHist)

travelHist = tile$get_HumanPop()$get_travelHistory()
# tile$get_HumanPop()$json_travelHistory(con = file(description = "/Users/slwu89/Desktop/OUTPUT/humanTravel.json",open = "wt"))


smitdave/MASH documentation built on May 30, 2019, 5:02 a.m.