The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
library(MicroMoB)
library(ggplot2)
library(data.table)
library(parallel)
One of the mainstays of mosquito-borne pathogen transmission modeling is the Ross-Macdonald (RM) model and its various elaborations. The various models referred to as the RM model are generically a set of mathematical models, in continuous or discrete time, which consider mosquitoes to take bloodmeals on hosts at some constant rate, experience a latent period between infection and infectiousness (the extrinsic incubation period, EIP), and experience a constant rate of mortality.
In MicroMoB we include a generalized RM model which can fill the interface for the mosquito component. The generalized RM model has both a stochastic and deterministic option for updating state over a time step, which is a daily step.
The model requires the following parameters:
a
: the host blood feeding ratep
: daily survival probability (may be
time-varying)EIP
: duration of incubation period (may be
time-varying, EIP[t]
gives the number of days mosquitoes
infected on day t
must wait before becoming
infectious)psi
: dispersal matrix describing movement between
placesThe state of the model is stored in vectors of length p
(number of places/patches):
M
: total mosquito densityY
: density of infected mosquitoesZ
: density of infectious mosquitoesNote that the number of uninfected mosquitoes is M - Y
and the number of infected but not yet infectious (incubating)
mosquitoes is Y - Z
.
The deterministic model has the following form:
\[\begin{equation} Y_{0} = a \kappa_{t} (M_{t} - Y_{t}) \\ M_{t+1} = (pM_{t}) \cdot \psi +\lambda_{t} \\ Y_{t+1} = p(Y_{t} + Y_{0}) \cdot \psi \\ Z_{t+1} = (pZ_{t} \cdot \psi) + (a \kappa_{t-EIP} (M_{t-EIP} - Y_{t-EIP}) p^{EIP} \cdot \psi^{EIP}) \end{equation}\]
With the minor difference that in the code, the EIP is forward-looking rather than backwards. We also note that \(p\) is allowed to be time-varying, even though here we have represented it as a constant. \(\kappa\) is passed to the mosquito component every day as a parameter, and is the net infectiousness of all hosts to mosquitoes (the probability a mosquito would become infected after biting a random blood host).
\(\lambda_{t}\) is the number of newly emerging adults on that day. It is calculated in the aquatic (immature) component and passed to the mosquito component as a parameter.
The stochastic model is as the deterministic one but all survival probabilities are used in binomial draws (or hypergeometric draws for nested sampling), and \(\psi\) parameterizes a multinomial draw over destination places/patches for mosquitoes leaving their home place. The stochastic model has been designed with care and appropriately tested to make sure that it does not draw inconsistent event histories for mosquitoes (e.g. sampling survival twice for mosquitoes in the same compartment).
Let’s do an example. We’ll need to set up both the aquatic and mosquito components. The example will run for three years. We will make \(\lambda\) a vector giving emergence for each patch, for each day of the year, peaking in the middle of the year with 100 mosquitoes emerging per day, per patch.
We also assume that daily survival p
is sinusoidal, with
a period of 365 days.
We let the EIP be a constant 5 days. We will also set \(\kappa = 0.05\) for each day.
<- 365 * 3
tmax <- 3
p
<- dnorm(x = 1:365, mean = 180, sd = 90)
lambda <- lambda * (100/max(lambda))
lambda <- t(replicate(p, lambda))
lambda
<- (sin((1:365)/365*2*pi) + 1.01)/2 * 0.9
psurv
<- 5
EIP
<- 0.3
f <- 1
q <- matrix(
psi c(
0.9, 0.05, 0.05,
0.05, 0.9, 0.05,
0.05, 0.05, 0.9
nrow = 3, ncol = 3,
), byrow = TRUE
)
par(mar = c(5,5,2,5))
plot(lambda[1, ], type = "l", col = "red", xlab = "Day", ylab = "Lambda (red)")
par(new = TRUE)
plot(psurv, type = "l", axes = F, xlab = NA, ylab = NA, col = "blue")
axis(side = 4)
mtext(side = 4, line = 3, 'Survival Probability (blue)')
Now we can set up the models. Let’s first do a deterministic
simulation. We use make_MicroMoB()
to set up the base model
object and setup_mosquito_RM()
to setup the RM mosquito
model for the mosquito component. setup_aqua_trace()
sets
up the aquatic (immature) component as a simple trace (forced)
model.
<- c(100, 100, 100)
M <- c(0, 0, 0)
Y <- c(0, 0, 0)
Z
<- make_MicroMoB(tmax = tmax, p = 3)
mod setup_mosquito_RM(mod, stochastic = FALSE, f = f, q = q, eip = EIP, p = psurv, psi = psi, M = M, Y = Y, Z = Z)
setup_aqua_trace(model = mod, lambda = lambda, stochastic = FALSE)
<- data.table::CJ(day = 1:tmax, state = c('M', 'Y', 'Z'), patch = 1:3, value = NaN)
det_out <- det_out[c('M', 'Y', 'Z'), on="state"]
det_out ::setkey(det_out, day)
data.table
# run it
while(get_tnow(mod) <= tmax) {
$mosquito$kappa <- rep(0.05, 3)
modstep_aqua(model = mod)
step_mosquitoes(model = mod)
== get_tnow(mod) & state == 'M', value := mod$mosquito$M]
det_out[day == get_tnow(mod) & state == 'Y', value := mod$mosquito$Y]
det_out[day == get_tnow(mod) & state == 'Z', value := mod$mosquito$Z]
det_out[day
$global$tnow <- mod$global$tnow + 1L
mod
}
ggplot(det_out) +
geom_line(aes(x = day, y = value, color = state)) +
facet_grid(patch ~ .)
Now we run 10 stochastic simulations, using the same parameters.
<- mclapply(X = 1:10, FUN = function(runid) {
sto_out
<- make_MicroMoB(tmax = tmax, p = 3)
mod setup_mosquito_RM(mod, stochastic = TRUE, f = f, q = q, eip = EIP, p = psurv, psi = psi, M = M, Y = Y, Z = Z)
setup_aqua_trace(model = mod, lambda = lambda, stochastic = TRUE)
<- data.table::CJ(day = 1:tmax, state = c('M', 'Y', 'Z'), patch = 1:3, value = NaN)
out <- out[c('M', 'Y', 'Z'), on="state"]
out ::setkey(out, day)
data.table
while(get_tnow(mod) <= tmax) {
$mosquito$kappa <- rep(0.05, 3)
modstep_aqua(model = mod)
step_mosquitoes(model = mod)
== get_tnow(mod) & state == 'M', value := mod$mosquito$M]
out[day == get_tnow(mod) & state == 'Y', value := mod$mosquito$Y]
out[day == get_tnow(mod) & state == 'Z', value := mod$mosquito$Z]
out[day
$global$tnow <- mod$global$tnow + 1L
mod
}
'run' := as.integer(runid)]
out[, return(out)
})
<- data.table::rbindlist(sto_out)
sto_out
ggplot(sto_out) +
geom_line(aes(x = day, y = value, color = state, group = interaction(run, state)), alpha = 0.35) +
facet_grid(patch ~ .)
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.