library(exDE)
library(MASS)
library(expm)
library(deSolve)
library(data.table)
library(ggplot2)
This is the null model of aquatic mosquito dynamics; there are no
endogenous dynamics and the model is simply specified by
Lambda
, the rate at which adult mosquitoes spontaneously
emerge from aquatic habitats.
Below we show an example, taken from the package tests, of using the trace-based aquatic model to keep an adult mosquito model at equilibrium when using unequal numbers of aquatic habitats per patch.
We first calculate equilibrium values following the Ross-Macdonald vignette. We use \(\mathcal{N}\) and \(\mathcal{U}\) to describe how aquatic
habitats are dispersed amongst patches, and how mosquitoes in each patch
disperse eggs to each habitat, respectively. Please note because we have
unequal numbers of aquatic habitats and patches, we use
MASS::ginv
to compute the generalized inverse of \(\mathcal{N}\) to get \(\alpha\) required at equilibrium.
<- 3
nPatches <- 4
nHabitats <- 0.3
f <- 0.9
q <- 1/20
g <- 1/10
sigma <- 11
tau <- 1/2
nu <- 30
eggsPerBatch
<- matrix(0, nPatches, nHabitats)
calN 1,1] <- 1
calN[2,2] <- 1
calN[3,3] <- 1
calN[3,4] <- 1
calN[
<- matrix(0, nHabitats, nPatches)
calU 1,1] <- 1
calU[2,2] <- 1
calU[3:4,3] <- 0.5
calU[
<- matrix(0, nPatches, nPatches)
calK 1, 2:3] <- c(0.2, 0.8)
calK[2, c(1,3)] <- c(0.5, 0.5)
calK[3, 1:2] <- c(0.7, 0.3)
calK[<- t(calK)
calK
<- make_Omega(g, sigma, calK, nPatches)
Omega <- expm::expm(-Omega * tau)
Upsilon
<- c(0.1, 0.075, 0.025)
kappa <- c(5, 10, 8)
Lambda
# equilibrium solutions
<- solve(Omega)
Omega_inv
<- as.vector(Omega_inv %*% Lambda)
M_eq <- as.vector(solve(diag(nu+f, nPatches) + Omega) %*% diag(f, nPatches) %*% M_eq)
G_eq <- as.vector(solve(diag(f*q*kappa) + Omega) %*% diag(f*q*kappa) %*% M_eq)
Y_eq <- as.vector(Omega_inv %*% Upsilon %*% diag(f*q*kappa) %*% (M_eq - Y_eq))
Z_eq
# the "Lambda" for the dLdt model
<- as.vector(ginv(calN) %*% Lambda) alpha
Now we set up the model. Please see the Ross-Macdonald vignette for details on the
adult model. We use alpha
as the Lambda
parameter of our forced emergence model, in
exDE::make_parameters_L_trace
. Again, because we are not
running the full transmission model, we must use
exDE::MosquitoBehavior
to pass the equilibrium values of
those bionomic parameters to exDE::xDE_diffeqn_mosy
.
<- list(
params nPatches = nPatches,
nHabitats = nHabitats,
calU = calU,
calN = calN
)<- list2env(params)
params
# ODE
make_parameters_MYZ_RM_ode(pars = params, g = g, sigma = sigma, calK = calK, tau = tau, f = f, q = q, nu = nu, eggsPerBatch = eggsPerBatch, M0 = rep(0, nPatches), G0 = rep(0, nPatches), Y0 = rep(0, nPatches), Z0 = rep(0, nPatches))
make_parameters_L_trace(pars = params, Lambda = alpha)
make_indices(params)
<- rep(0, max(params$Upsilon_ix))
y0 $M_ix] <- M_eq
y0[params$G_ix] <- G_eq
y0[params$Y_ix] <- Y_eq
y0[params$Z_ix] <- Z_eq
y0[params$Upsilon_ix] <- as.vector(Upsilon)
y0[params
<- MosquitoBehavior(0, y, params)
MosyBehavior
<- deSolve::ode(y = y0, times = 0:50, func = xDE_diffeqn_mosy, parms = params, method = 'lsoda', kappa = kappa, MosyBehavior = MosyBehavior)
out
colnames(out)[params$M_ix+1] <- paste0('M_', 1:params$nPatches)
colnames(out)[params$G_ix+1] <- paste0('G_', 1:params$nPatches)
colnames(out)[params$Y_ix+1] <- paste0('Y_', 1:params$nPatches)
colnames(out)[params$Z_ix+1] <- paste0('Z_', 1:params$nPatches)
<- out[, -c(params$Upsilon_ix+1)]
out
<- as.data.table(out)
out <- melt(out, id.vars = 'time')
out c("Component", "Patch") := tstrsplit(variable, '_', fixed = TRUE)]
out[, := NULL]
out[, variable
ggplot(data = out, mapping = aes(x = time, y = value, color = Patch)) +
geom_line() +
facet_wrap(. ~ Component, scales = 'free') +
theme_bw()