Title: | Discrete Time Simulation of Mosquito-Borne Pathogen Transmission |
---|---|
Description: | Provides a framework based on S3 dispatch for constructing models of mosquito-borne pathogen transmission which are constructed from submodels of various components (i.e. immature and adult mosquitoes, human populations). A consistent mathematical expression for the distribution of bites on hosts means that different models (stochastic, deterministic, etc.) can be coherently incorporated and updated over a discrete time step. |
Authors: | Sean L. Wu [aut, cre]
|
Maintainer: | Sean L. Wu <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.2 |
Built: | 2025-02-19 04:31:00 UTC |
Source: | https://github.com/cran/MicroMoB |
Read global configuration options
api_config_global(path)
api_config_global(path)
path |
file path to a JSON file |
Check if two numeric values are approximately equal
approx_equal(a, b, tol = sqrt(.Machine$double.eps))
approx_equal(a, b, tol = sqrt(.Machine$double.eps))
a |
a numeric object |
b |
a numeric object |
tol |
the numeric tolerance |
a logical value
This should be run prior to any step
functions to update
components over a time step. It computes various quantities related to
disease transmission between species using the generic interfaces (methods)
provided by each component. It updates the EIR
vector for the human component, and kappa
, the net infectiousness
of hosts for the mosquito component.
compute_bloodmeal(model)
compute_bloodmeal(model)
model |
an object from make_MicroMoB |
no return value
The difference between this and compute_bloodmeal is that this function does not include any computations of alternative blood hosts or visitors and is suitable for models which only include mosquitoes and resident human populations.
compute_bloodmeal_simple(model)
compute_bloodmeal_simple(model)
model |
an object from make_MicroMoB |
no return value
)This method dispatches on the type of model$aqua
compute_emergents(model)
compute_emergents(model)
model |
an object from make_MicroMoB |
a vector of length p
giving the number of newly emerging adult in each patch
This function dispatches on the second class attribute of model$aqua
for stochastic or deterministic behavior.
## S3 method for class 'BH' compute_emergents(model)
## S3 method for class 'BH' compute_emergents(model)
model |
an object from make_MicroMoB |
a vector of length l
giving the number of newly emerging adult in each patch
This function dispatches on the second class attribute of model$aqua
for stochastic or deterministic behavior.
## S3 method for class 'trace' compute_emergents(model)
## S3 method for class 'trace' compute_emergents(model)
model |
an object from make_MicroMoB |
see compute_emergents.trace_deterministic and compute_emergents.trace_stochastic
no return value
Return the column of the lambda matrix for this day.
## S3 method for class 'trace_deterministic' compute_emergents(model)
## S3 method for class 'trace_deterministic' compute_emergents(model)
model |
an object from make_MicroMoB |
a vector of length l
giving the number of newly emerging adult in each patch
Draw a Poisson distributed number of emerging adults with mean parameter from the column of the trace matrix for this day.
## S3 method for class 'trace_stochastic' compute_emergents(model)
## S3 method for class 'trace_stochastic' compute_emergents(model)
model |
an object from make_MicroMoB |
a vector of length l
giving the number of newly emerging adult in each patch
)This method dispatches on the type of model$mosquito
compute_f(model, B)
compute_f(model, B)
model |
an object from make_MicroMoB |
B |
a vector of length |
a vector of length p
giving the per-capita blood feeding rate of mosquitoes in each patch
)Blood feeding rates are modeled as a Holling type 2 (rational) function of blood host availability.
Here is the maximum blood feeding rate and
is a scaling parameter.
## S3 method for class 'BQ' compute_f(model, B)
## S3 method for class 'BQ' compute_f(model, B)
model |
an object from make_MicroMoB |
B |
a vector of length |
a vector of length p
giving the per-capita blood feeding rate of mosquitoes in each blood feeding haunt
)This method simply returns the f
parameter of the mosquito object,
because the RM model assumes a constant blood feeding rate.
## S3 method for class 'RM' compute_f(model, B)
## S3 method for class 'RM' compute_f(model, B)
model |
an object from make_MicroMoB |
B |
a vector of length |
a vector of length p
giving the per-capita blood feeding rate of mosquitoes in each patch
)Compute null mosquito feeding rate ()
## S3 method for class 'trace' compute_f(model, B)
## S3 method for class 'trace' compute_f(model, B)
model |
an object from make_MicroMoB |
B |
a vector of length |
no return value
)This method dispatches on the type of model$human
.
compute_H(model)
compute_H(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the size of each human population stratum
)Compute human population strata sizes for MOI model ()
## S3 method for class 'MOI' compute_H(model)
## S3 method for class 'MOI' compute_H(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the size of each human population stratum
)Compute human population strata sizes for SIP model ()
## S3 method for class 'SIP' compute_H(model)
## S3 method for class 'SIP' compute_H(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the size of each human population stratum
)Compute human population strata sizes for SIR model ()
## S3 method for class 'SIR' compute_H(model)
## S3 method for class 'SIR' compute_H(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the size of each human population stratum
)Compute human population strata sizes for SIS model ()
## S3 method for class 'SIS' compute_H(model)
## S3 method for class 'SIS' compute_H(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the size of each human population stratum
)This method dispatches on the type of model$alternative
.
compute_O(model)
compute_O(model)
model |
an object from make_MicroMoB |
a vector of length p
giving biting availability of other blood hosts at each patch
)Compute available alternative blood hosts for trace model ()
## S3 method for class 'trace' compute_O(model)
## S3 method for class 'trace' compute_O(model)
model |
an object from make_MicroMoB |
a vector of length p
giving biting availability of other blood hosts at each patch
This method dispatches on the type of model$mosquito
compute_oviposit(model)
compute_oviposit(model)
model |
an object from make_MicroMoB |
a vector of length l
giving the total number of eggs laid by adult mosquitoes in each aquatic habitat
This method returns a vector of length l
.
## S3 method for class 'BQ' compute_oviposit(model)
## S3 method for class 'BQ' compute_oviposit(model)
model |
an object from make_MicroMoB |
see compute_oviposit.BQ_deterministic and compute_oviposit.BQ_stochastic
a vector of length l
giving the total number of eggs laid by adult mosquitoes in each aquatic habitat
Compute number of eggs laid from oviposition for each patch for deterministic RM model
## S3 method for class 'BQ_deterministic' compute_oviposit(model)
## S3 method for class 'BQ_deterministic' compute_oviposit(model)
model |
an object from make_MicroMoB |
a vector of length l
giving the total number of eggs laid by adult mosquitoes in each aquatic habitat
Compute number of eggs laid from oviposition for each patch for stochastic RM model
## S3 method for class 'BQ_stochastic' compute_oviposit(model)
## S3 method for class 'BQ_stochastic' compute_oviposit(model)
model |
an object from make_MicroMoB |
a vector of length l
giving the total number of eggs laid by adult mosquitoes in each aquatic habitat
This method returns a vector of length p
.
## S3 method for class 'RM' compute_oviposit(model)
## S3 method for class 'RM' compute_oviposit(model)
model |
an object from make_MicroMoB |
see compute_oviposit.RM_deterministic and compute_oviposit.RM_stochastic
a vector of length p
giving the total number of eggs laid by adult mosquitoes in each patch
Compute number of eggs laid from oviposition for each patch for deterministic RM model
## S3 method for class 'RM_deterministic' compute_oviposit(model)
## S3 method for class 'RM_deterministic' compute_oviposit(model)
model |
an object from make_MicroMoB |
a vector of length p
giving the total number of eggs laid by adult mosquitoes in each patch
Compute number of eggs laid from oviposition for each patch for stochastic RM model
## S3 method for class 'RM_stochastic' compute_oviposit(model)
## S3 method for class 'RM_stochastic' compute_oviposit(model)
model |
an object from make_MicroMoB |
a vector of length l
giving the total number of eggs laid by adult mosquitoes in each patch
This method dispatches on the type of model$mosquito
## S3 method for class 'trace' compute_oviposit(model)
## S3 method for class 'trace' compute_oviposit(model)
model |
an object from make_MicroMoB |
a vector of length p
giving the total number of eggs laid by adult mosquitoes in each patch
)The time at risk matrix is This method dispatches on the type of
model$human
.
compute_Psi(model)
compute_Psi(model)
model |
an object from make_MicroMoB |
a matrix with n
rows and p
columns, the time at risk matrix
)Compute time at risk matrix for MOI model ()
## S3 method for class 'MOI' compute_Psi(model)
## S3 method for class 'MOI' compute_Psi(model)
model |
an object from make_MicroMoB |
a matrix with n
rows and p
columns, the time at risk matrix
)Compute time at risk matrix for SIP model ()
## S3 method for class 'SIP' compute_Psi(model)
## S3 method for class 'SIP' compute_Psi(model)
model |
an object from make_MicroMoB |
a matrix with n
rows and p
columns, the time at risk matrix
)Compute time at risk matrix for SIR model ()
## S3 method for class 'SIR' compute_Psi(model)
## S3 method for class 'SIR' compute_Psi(model)
model |
an object from make_MicroMoB |
a matrix with n
rows and p
columns, the time at risk matrix
)Compute time at risk matrix for SIS model ()
## S3 method for class 'SIS' compute_Psi(model)
## S3 method for class 'SIS' compute_Psi(model)
model |
an object from make_MicroMoB |
a matrix with n
rows and p
columns, the time at risk matrix
)This method dispatches on the type of model$mosquito
compute_q(model, W, Wd, B)
compute_q(model, W, Wd, B)
model |
an object from make_MicroMoB |
W |
a vector of length |
Wd |
a vector of length |
B |
a vector of length |
a vector of length p
giving the proportion of bites taken on human hosts in each patch
)The human blood feeding fraction is simply the proportion of human hosts.
## S3 method for class 'BQ' compute_q(model, W, Wd, B)
## S3 method for class 'BQ' compute_q(model, W, Wd, B)
model |
an object from make_MicroMoB |
W |
a vector of length |
Wd |
a vector of length |
B |
a vector of length |
a vector of length p
giving the proportion of bites taken on human hosts in each blood feeding haunt
)This method simply returns the q
parameter of the mosquito object,
because the RM model assumes a constant fraction of blood meals are taken on
human hosts.
## S3 method for class 'RM' compute_q(model, W, Wd, B)
## S3 method for class 'RM' compute_q(model, W, Wd, B)
model |
an object from make_MicroMoB |
W |
a vector of length |
Wd |
a vector of length |
B |
a vector of length |
a vector of length p
giving the proportion of bites taken on human hosts in each patch
)Compute null human blood feeding fraction ()
## S3 method for class 'trace' compute_q(model, W, Wd, B)
## S3 method for class 'trace' compute_q(model, W, Wd, B)
model |
an object from make_MicroMoB |
W |
a vector of length |
Wd |
a vector of length |
B |
a vector of length |
no return value
)This method dispatches on the type of model$visitor
.
compute_Wd(model)
compute_Wd(model)
model |
an object from make_MicroMoB |
a vector of length p
giving biting availability of visitors at each patch
)Compute available visitors for trace model ()
## S3 method for class 'trace' compute_Wd(model)
## S3 method for class 'trace' compute_Wd(model)
model |
an object from make_MicroMoB |
a vector of length p
giving biting availability of visitors at each patch
)This method dispatches on the type of model$human
.
compute_wf(model)
compute_wf(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the biting weights of human hosts in each stratum
)Compute human biting weights for MOI model ()
## S3 method for class 'MOI' compute_wf(model)
## S3 method for class 'MOI' compute_wf(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the biting weights of human hosts in each stratum
)Compute human biting weights for SIP model ()
## S3 method for class 'SIP' compute_wf(model)
## S3 method for class 'SIP' compute_wf(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the biting weights of human hosts in each stratum
)Compute human biting weights for SIR model ()
## S3 method for class 'SIR' compute_wf(model)
## S3 method for class 'SIR' compute_wf(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the biting weights of human hosts in each stratum
)Compute human biting weights for SIS model ()
## S3 method for class 'SIS' compute_wf(model)
## S3 method for class 'SIS' compute_wf(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the biting weights of human hosts in each stratum
)In a Ross-Macdonald style transmission model, this is computed as
This method dispatches on the type of model$human
.
compute_x(model)
compute_x(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the net infectiousness of human hosts in each stratum
)In the simple MOI (queueing) model here (M/M/inf), net infectiousness is considered not to vary with increasing MOI. It is calculated as
where is the number of uninfected persons (multiplicity of infection of zero).
## S3 method for class 'MOI' compute_x(model)
## S3 method for class 'MOI' compute_x(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the net infectiousness of human hosts in each stratum
)Compute net infectiousness for SIP model ()
## S3 method for class 'SIP' compute_x(model)
## S3 method for class 'SIP' compute_x(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the net infectiousness of human hosts in each stratum
)Compute net infectiousness for SIR model ()
## S3 method for class 'SIR' compute_x(model)
## S3 method for class 'SIR' compute_x(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the net infectiousness of human hosts in each stratum
)Compute net infectiousness for SIS model ()
## S3 method for class 'SIS' compute_x(model)
## S3 method for class 'SIS' compute_x(model)
model |
an object from make_MicroMoB |
a vector of length n
giving the net infectiousness of human hosts in each stratum
)This method dispatches on the type of model$visitor
.
compute_xd(model)
compute_xd(model)
model |
an object from make_MicroMoB |
a vector of length p
giving net infectiousness of visitors at each patch
)Compute net infectiousness of visitors for trace model ()
## S3 method for class 'trace' compute_xd(model)
## S3 method for class 'trace' compute_xd(model)
model |
an object from make_MicroMoB |
a vector of length p
giving net infectiousness of visitors at each patch
)This method dispatches on the type of model$mosquito
.
is also known as the "sporozoite rate" in malariology.
compute_Z(model)
compute_Z(model)
model |
an object from make_MicroMoB |
a vector of length p
giving the density of infected and infectious mosquitoes in each patch
)This method returns Z
.
## S3 method for class 'BQ' compute_Z(model)
## S3 method for class 'BQ' compute_Z(model)
model |
an object from make_MicroMoB |
a vector of length p
giving the density of infected and infectious mosquitoes in each blood feeding haunt
)This method returns Z
.
## S3 method for class 'RM' compute_Z(model)
## S3 method for class 'RM' compute_Z(model)
model |
an object from make_MicroMoB |
a vector of length p
giving the density of infected and infectious mosquitoes in each patch
)Compute null density of infective mosquitoes ()
## S3 method for class 'trace' compute_Z(model)
## S3 method for class 'trace' compute_Z(model)
model |
an object from make_MicroMoB |
no return value
Distribute items into bins as evenly as possible
distribute(n, p)
distribute(n, p)
n |
number of bins |
p |
number of items |
a numeric vector of bin sizes
Division of integers
divmod(a, b)
divmod(a, b)
a |
the dividend |
b |
the divisor |
a list with two elements, quo
(quotient) and rem
(remainder)
Warning: this function does no argument checking. Ensure the arguments are as follows.
draw_multinom(n, prob)
draw_multinom(n, prob)
n |
an integer giving the number of balls to distribute in bins |
prob |
a vector of probabilities for each bin, which must sum to one |
an integer vector of length equal to the length of prob
This function uses the algorithm presented in: Startek, Michał. "An asymptotically optimal, online algorithm for weighted random sampling with replacement." arXiv preprint arXiv:1611.00532 (2016).
The JSON config file should have two entries:
O: vector or matrix (see time_patch_varying_parameter for valid dimensions)
For interpretation of the entries, please read setup_alternative_trace.
get_config_alternative_trace(path)
get_config_alternative_trace(path)
path |
a file path to a JSON file |
a named list
# to see an example of proper JSON input, run the following library(jsonlite) par <- list( "O" = rep(1, 5) ) toJSON(par, pretty = TRUE)
# to see an example of proper JSON input, run the following library(jsonlite) par <- list( "O" = rep(1, 5) ) toJSON(par, pretty = TRUE)
The JSON config file should have two entries:
stochastic: a boolean value
molt: a scalar, vector, or matrix (row major)
surv: a scalar, vector, or matrix (row major)
K: a scalar, vector, or matrix (row major)
L: a vector
Please see time_patch_varying_parameter for allowed dimensions of entries
molt
, surv
, and K
. L
should be of length equal to the number of patches.
For interpretation of the entries, please read setup_aqua_BH.
get_config_aqua_BH(path)
get_config_aqua_BH(path)
path |
a file path to a JSON file |
a named list
# to see an example of proper JSON input, run the following library(jsonlite) p <- 5 # number of patches t <- 10 # number of days to simulate par <- list( "stochastic" = FALSE, "molt" = 0.3, "surv" = rep(0.5, 365), "K" = matrix(rpois(n = t * p, lambda = 100), nrow = p, ncol = t), "L" = rep(10, p) ) toJSON(par, pretty = TRUE)
# to see an example of proper JSON input, run the following library(jsonlite) p <- 5 # number of patches t <- 10 # number of days to simulate par <- list( "stochastic" = FALSE, "molt" = 0.3, "surv" = rep(0.5, 365), "K" = matrix(rpois(n = t * p, lambda = 100), nrow = p, ncol = t), "L" = rep(10, p) ) toJSON(par, pretty = TRUE)
The JSON config file should have two entries:
stochastic: a boolean value
lambda: a scalar, vector, or matrix (row major). It will be passed to time_patch_varying_parameter, see that function's documentation for appropriate dimensions.
For interpretation of the entries, please read setup_aqua_trace.
get_config_aqua_trace(path)
get_config_aqua_trace(path)
path |
a file path to a JSON file |
a named list
# to see an example of proper JSON input, run the following library(jsonlite) t <- 10 # number of days to simulate par <- list( "stochastic" = FALSE, "lambda" = rpois(n = t, lambda = 10) ) toJSON(par, pretty = TRUE)
# to see an example of proper JSON input, run the following library(jsonlite) t <- 10 # number of days to simulate par <- list( "stochastic" = FALSE, "lambda" = rpois(n = t, lambda = 10) ) toJSON(par, pretty = TRUE)
The JSON config file should have 9 entries:
stochastic: a boolean value
theta: matrix (row major)
wf: vector
H: vector
MOI: matrix (row major)
b: scalar
c: scalar
r: scalar
sigma: scalar
For interpretation of the entries, please read setup_humans_MOI.
get_config_humans_MOI(path)
get_config_humans_MOI(path)
path |
a file path to a JSON file |
a named list
# to see an example of proper JSON input, run the following library(jsonlite) n <- 6 # number of human population strata p <- 5 # number of patches theta <- matrix(rexp(n*p), nrow = n, ncol = p) theta <- theta / rowSums(theta) H <- rep(10, n) MOI <- matrix(0, nrow = 10, ncol = n) MOI[1, ] <- H par <- list( "stochastic" = FALSE, "theta" = theta, "wf" = rep(1, n), "H" = H, "MOI" = MOI, "b" = 0.55, "c" = 0.15, "r" = 1/200, "sigma" = 1 ) toJSON(par, pretty = TRUE)
# to see an example of proper JSON input, run the following library(jsonlite) n <- 6 # number of human population strata p <- 5 # number of patches theta <- matrix(rexp(n*p), nrow = n, ncol = p) theta <- theta / rowSums(theta) H <- rep(10, n) MOI <- matrix(0, nrow = 10, ncol = n) MOI[1, ] <- H par <- list( "stochastic" = FALSE, "theta" = theta, "wf" = rep(1, n), "H" = H, "MOI" = MOI, "b" = 0.55, "c" = 0.15, "r" = 1/200, "sigma" = 1 ) toJSON(par, pretty = TRUE)
The JSON config file should have 8 entries:
stochastic: a boolean value
theta: matrix (row major)
wf: vector
H: vector
SIR: matrix (row major)
b: scalar
c: scalar
gamma: scalar
For interpretation of the entries, please read setup_humans_SIR.
get_config_humans_SIR(path)
get_config_humans_SIR(path)
path |
a file path to a JSON file |
a named list
# to see an example of proper JSON input, run the following library(jsonlite) n <- 6 # number of human population strata p <- 5 # number of patches theta <- matrix(rexp(n*p), nrow = n, ncol = p) theta <- theta / rowSums(theta) H <- rep(10, n) SIR <- matrix(0, nrow = n, ncol = 3) SIR[, 1] <- H par <- list( "stochastic" = FALSE, "theta" = theta, "wf" = rep(1, n), "H" = H, "SIR" = SIR, "b" = 0.55, "c" = 0.15, "gamma" = 1/7 ) toJSON(par, pretty = TRUE)
# to see an example of proper JSON input, run the following library(jsonlite) n <- 6 # number of human population strata p <- 5 # number of patches theta <- matrix(rexp(n*p), nrow = n, ncol = p) theta <- theta / rowSums(theta) H <- rep(10, n) SIR <- matrix(0, nrow = n, ncol = 3) SIR[, 1] <- H par <- list( "stochastic" = FALSE, "theta" = theta, "wf" = rep(1, n), "H" = H, "SIR" = SIR, "b" = 0.55, "c" = 0.15, "gamma" = 1/7 ) toJSON(par, pretty = TRUE)
The JSON config file should have 8 entries:
stochastic: a boolean value
theta: matrix (row major)
wf: vector
H: vector
X: vector
b: scalar
c: scalar
r: scalar
For interpretation of the entries, please read setup_humans_SIS.
get_config_humans_SIS(path)
get_config_humans_SIS(path)
path |
a file path to a JSON file |
a named list
# to see an example of proper JSON input, run the following library(jsonlite) n <- 6 # number of human population strata p <- 5 # number of patches theta <- matrix(rexp(n*p), nrow = n, ncol = p) theta <- theta / rowSums(theta) H <- rep(10, n) X <- rep(3, n) par <- list( "stochastic" = FALSE, "theta" = theta, "wf" = rep(1, n), "H" = H, "X" = X, "b" = 0.55, "c" = 0.15, "r" = 1/200 ) toJSON(par, pretty = TRUE)
# to see an example of proper JSON input, run the following library(jsonlite) n <- 6 # number of human population strata p <- 5 # number of patches theta <- matrix(rexp(n*p), nrow = n, ncol = p) theta <- theta / rowSums(theta) H <- rep(10, n) X <- rep(3, n) par <- list( "stochastic" = FALSE, "theta" = theta, "wf" = rep(1, n), "H" = H, "X" = X, "b" = 0.55, "c" = 0.15, "r" = 1/200 ) toJSON(par, pretty = TRUE)
The JSON config file should have 8 entries:
stochastic: a boolean value
f: scalar
q: scalar
eip: scalar or vector; see time_varying_parameter for valid formats
p: scalar or vector; see time_varying_parameter for valid formats
psi: matrix
nu: scalar
M: vector
Y: vector
Z: vector
For interpretation of the entries, please read setup_mosquito_RM.
get_config_mosquito_RM(path)
get_config_mosquito_RM(path)
path |
a file path to a JSON file |
a named list
# to see an example of proper JSON input, run the following library(jsonlite) t <- 10 # days to simulate p <- 5 # number of patches EIP <- rep(5, t) p_surv <- 0.95 psi <- matrix(rexp(p^2), nrow = p, ncol = p) psi <- psi / rowSums(psi) par <- list( "stochastic" = FALSE, "f" = 0.3, "q" = 0.9, "eip" = EIP, "p" = p_surv, "psi" = psi, "nu" = 20, "M" = rep(100, p), "Y" = rep(20, p), "Z" = rep(5, p) ) toJSON(par, pretty = TRUE)
# to see an example of proper JSON input, run the following library(jsonlite) t <- 10 # days to simulate p <- 5 # number of patches EIP <- rep(5, t) p_surv <- 0.95 psi <- matrix(rexp(p^2), nrow = p, ncol = p) psi <- psi / rowSums(psi) par <- list( "stochastic" = FALSE, "f" = 0.3, "q" = 0.9, "eip" = EIP, "p" = p_surv, "psi" = psi, "nu" = 20, "M" = rep(100, p), "Y" = rep(20, p), "Z" = rep(5, p) ) toJSON(par, pretty = TRUE)
The JSON config file should have 1 entry:
oviposit: vector
For interpretation of the entries, please read setup_mosquito_trace.
get_config_mosquito_trace(path)
get_config_mosquito_trace(path)
path |
a file path to a JSON file |
a named list
# to see an example of proper JSON input, run the following library(jsonlite) par <- list( "oviposit" = rep(1, 5) ) toJSON(par, pretty = TRUE)
# to see an example of proper JSON input, run the following library(jsonlite) par <- list( "oviposit" = rep(1, 5) ) toJSON(par, pretty = TRUE)
The JSON config file should have two entries:
Wd: vector or matrix (see time_patch_varying_parameter for valid dimensions)
xd: vector or matrix (see time_patch_varying_parameter for valid dimensions)
For interpretation of the entries, please read setup_visitor_trace.
get_config_visitor_trace(path)
get_config_visitor_trace(path)
path |
a file path to a JSON file |
a named list
# to see an example of proper JSON input, run the following library(jsonlite) par <- list( "Wd" = rep(1, 5), "xd" = rep(0.01, 365) ) toJSON(par, pretty = TRUE)
# to see an example of proper JSON input, run the following library(jsonlite) par <- list( "Wd" = rep(1, 5), "xd" = rep(0.01, 365) ) toJSON(par, pretty = TRUE)
Get extrinsic incubation period for Ross-Macdonald mosquito model
get_eip_mosquito_RM(model, times)
get_eip_mosquito_RM(model, times)
model |
an object from make_MicroMoB |
times |
vector of times to return |
no return value
Get feeding rate for Ross-Macdonald mosquito model
get_f_mosquito_RM(model)
get_f_mosquito_RM(model)
model |
an object from make_MicroMoB |
a vector
Get carrying capacity for Beverton-Holt aquatic mosquito model
get_K_aqua_BH(model, times, places)
get_K_aqua_BH(model, times, places)
model |
an object from make_MicroMoB |
times |
vector of times to get values |
places |
vector of places to get values |
a matrix
Get kappa for Ross-Macdonald mosquito model
get_kappa_mosquito_RM(model)
get_kappa_mosquito_RM(model)
model |
an object from make_MicroMoB |
a vector
Get daily emergence for Beverton-Holt aquatic mosquito model
get_lambda_aqua_trace(model, times, places)
get_lambda_aqua_trace(model, times, places)
model |
an object from make_MicroMoB |
times |
vector of times to get values |
places |
vector of places to get values |
a matrix
Get daily maturation probability for Beverton-Holt aquatic mosquito model
get_molt_aqua_BH(model, times, places)
get_molt_aqua_BH(model, times, places)
model |
an object from make_MicroMoB |
times |
vector of times to get values |
places |
vector of places to get values |
a matrix
Get number of eggs laid per oviposition for Ross-Macdonald mosquito model
get_nu_mosquito_RM(model)
get_nu_mosquito_RM(model)
model |
an object from make_MicroMoB |
a vector
Get daily survival probability for Ross-Macdonald mosquito model
get_p_mosquito_RM(model, times, places)
get_p_mosquito_RM(model, times, places)
model |
an object from make_MicroMoB |
times |
vector of times to get values |
places |
vector of places to get values |
a matrix
Get mosquito dispersal matrix for Ross-Macdonald mosquito model
get_psi_mosquito_RM(model)
get_psi_mosquito_RM(model)
model |
an object from make_MicroMoB |
a matrix
Get human blood feeding fraction for Ross-Macdonald mosquito model
get_q_mosquito_RM(model)
get_q_mosquito_RM(model)
model |
an object from make_MicroMoB |
a vector
Get daily survival probability for Beverton-Holt aquatic mosquito model
get_surv_aqua_BH(model, times, places)
get_surv_aqua_BH(model, times, places)
model |
an object from make_MicroMoB |
times |
vector of times to get values |
places |
vector of places to get values |
a matrix
Get maximum time of simulation from model object
get_tmax(model)
get_tmax(model)
model |
an object from make_MicroMoB |
Get current time of simulation from model object
get_tnow(model)
get_tnow(model)
model |
an object from make_MicroMoB |
Does a numeric object consist of only zeros and ones?
is_binary(x)
is_binary(x)
x |
a numeric object |
a logical value
The model object is a hashed environment. By default it contains
a single list, model$global
storing global state.
make_MicroMoB(tmax, p, l = p)
make_MicroMoB(tmax, p, l = p)
tmax |
number of days to simulate |
p |
number of places |
l |
number of aquatic habitats (optional, will be set to |
an object of class environment
Discrete time simulation of mosquito-borne pathogen transmission
Maintainer: Sean L. Wu [email protected] (ORCID)
Authors:
David L. Smith [email protected] (ORCID)
Other contributors:
Sophie Libkind [contributor]
Useful links:
Report bugs at https://github.com/dd-harp/MicroMoB/issues
This method dispatches on the type of model$human
.
observe_pfpr(model, parameters)
observe_pfpr(model, parameters)
model |
an object from make_MicroMoB |
parameters |
a named list, should have elements |
an array of counts, with actual condition as first dimension and tested condition as the second dimension, and the third dimension is the human strata
Observe PfPR in human strata for SIP model
## S3 method for class 'SIP' observe_pfpr(model, parameters)
## S3 method for class 'SIP' observe_pfpr(model, parameters)
model |
an object from make_MicroMoB |
parameters |
a named list, should have elements |
an array of counts, with actual condition as first dimension and tested condition as the second dimension, and the third dimension is the human strata
Observe PfPR in human strata for SIS model
## S3 method for class 'SIS' observe_pfpr(model, parameters)
## S3 method for class 'SIS' observe_pfpr(model, parameters)
model |
an object from make_MicroMoB |
parameters |
a named list, should have elements |
an array of counts, with actual condition as first dimension and tested condition as the second dimension, and the third dimension is the human strata
This method dispatches on the type of model$aqua
. It returns
the current state of the aquatic component.
output_aqua(model)
output_aqua(model)
model |
an object from make_MicroMoB |
Return a data.frame.
## S3 method for class 'BH' output_aqua(model)
## S3 method for class 'BH' output_aqua(model)
model |
an object from make_MicroMoB |
a data.frame with columns L
(immature) and A
(emerging pupae)
This function returns an empty data.frame as trace models do not have endogenous dynamics.
## S3 method for class 'trace' output_aqua(model)
## S3 method for class 'trace' output_aqua(model)
model |
an object from make_MicroMoB |
This method dispatches on the type of model$mosquito
. It returns
the current state of the adult mosquito component.
output_mosquitoes(model)
output_mosquitoes(model)
model |
an object from make_MicroMoB |
Return a data.frame.
## S3 method for class 'RM' output_mosquitoes(model)
## S3 method for class 'RM' output_mosquitoes(model)
model |
an object from make_MicroMoB |
a data.frame with columns M
(all adult mosquitoes), Y
(infected mosquitoes), and Z
(infectious mosquitoes), and rows
correspond to places.
This function returns an empty data.frame as trace models do not have endogenous dynamics.
## S3 method for class 'trace' output_mosquitoes(model)
## S3 method for class 'trace' output_mosquitoes(model)
model |
an object from make_MicroMoB |
x
is a matrix with arbitrary number of rows but whose columns
are equal to the number of bins that the stochastic matrix prob
parameterizes
a distribution over. Each row of x
gives a distribution of counts over bins
and is resampled according to prob
. It is conceptually similar to
"stochastically" distributing the matrix as x %*% prob
, which gives the
expectation.
sample_stochastic_matrix(x, prob)
sample_stochastic_matrix(x, prob)
x |
a matrix |
prob |
a matrix, it must have number of columns equal to the number of columns of |
a matrix whose dimensions equal the original x
Given a vector of counts in cells, x
and a stochastic matrix prob
, each
row of which describes a probability distribution of how that cell should be
distributed among bins, sample destination bins for each cell count, and return
a vector giving the number of counts in bins. It is conceptually similar to
"stochastically" distributing the vector as x %*% prob
, which gives the
expectation.
sample_stochastic_vector(x, prob)
sample_stochastic_vector(x, prob)
x |
a vector |
prob |
a matrix, it must have number of rows equal to |
a vector of length equal to the number of columns of prob
Change the extrinsic incubation period parameter eip
for some
set of times. The new values eip
should either be a scalar or a vector
of length equal to the length of times
.
set_eip_mosquito_RM(model, eip, times)
set_eip_mosquito_RM(model, eip, times)
model |
an object from make_MicroMoB |
eip |
new extrinsic incubation period values |
times |
vector of times to set the new values |
no return value
Change the feeding rate parameter f
.
set_f_mosquito_RM(model, f)
set_f_mosquito_RM(model, f)
model |
an object from make_MicroMoB |
f |
new blood feeding rate |
no return value
Change the carrying capacity parameter K
for some times
and places. The parameter K
is stored internally as a matrix so that times
and places
are used to modify a submatrix, therefore the new value K
should
either be a scalar value to update the entire submatrix or a matrix of places
rows
and times
columns.
set_K_aqua_BH(model, K, times, places)
set_K_aqua_BH(model, K, times, places)
model |
an object from make_MicroMoB |
K |
new carrying capacity |
times |
vector of times to set the new values |
places |
vector of places to set the new values |
no return value
Change kappa
.
set_kappa_mosquito_RM(model, kappa)
set_kappa_mosquito_RM(model, kappa)
model |
an object from make_MicroMoB |
kappa |
new value of |
no return value
Change the daily emergence parameter lambda
for some times
and places. The parameter lambda
is stored internally as a matrix so that times
and places
are used to modify a submatrix, therefore the new value lambda
should
either be a scalar value to update the entire submatrix or a matrix of places
rows
and times
columns.
set_lambda_aqua_trace(model, lambda, times, places)
set_lambda_aqua_trace(model, lambda, times, places)
model |
an object from make_MicroMoB |
lambda |
new emergence |
times |
vector of times to set the new values |
places |
vector of places to set the new values |
no return value
Change the daily maturation probability parameter molt
for some times
and places. The parameter molt
is stored internally as a matrix so that times
and places
are used to modify a submatrix, therefore the new value molt
should
either be a scalar value to update the entire submatrix or a matrix of places
rows
and times
columns.
set_molt_aqua_BH(model, molt, times, places)
set_molt_aqua_BH(model, molt, times, places)
model |
an object from make_MicroMoB |
molt |
new daily maturation probability |
times |
vector of times to set the new values |
places |
vector of places to set the new values |
no return value
Change the number of eggs laid per oviposition parameter nu
.
set_nu_mosquito_RM(model, nu)
set_nu_mosquito_RM(model, nu)
model |
an object from make_MicroMoB |
nu |
new number of eggs laid per oviposition |
no return value
Change the daily survival probability parameter p
for some times
and places. The parameter p
is stored internally as a matrix so that times
and places
are used to modify a submatrix, therefore the new value p
should
either be a scalar value to update the entire submatrix or a matrix of places
rows
and times
columns.
set_p_mosquito_RM(model, p, times, places)
set_p_mosquito_RM(model, p, times, places)
model |
an object from make_MicroMoB |
p |
new human blood feeding fraction |
times |
vector of times to set the new values |
places |
vector of places to set the new values |
no return value
Change the mosquito dispersal matrix parameter psi
.
set_psi_mosquito_RM(model, psi)
set_psi_mosquito_RM(model, psi)
model |
an object from make_MicroMoB |
psi |
new mosquito dispersal matrix |
no return value
Change the human blood feeding fraction parameter q
.
set_q_mosquito_RM(model, q)
set_q_mosquito_RM(model, q)
model |
an object from make_MicroMoB |
q |
new human blood feeding fraction |
no return value
Change the daily survival probability parameter surv
for some times
and places. The parameter surv
is stored internally as a matrix so that times
and places
are used to modify a submatrix, therefore the new value surv
should
either be a scalar value to update the entire submatrix or a matrix of places
rows
and times
columns.
set_surv_aqua_BH(model, surv, times, places)
set_surv_aqua_BH(model, surv, times, places)
model |
an object from make_MicroMoB |
surv |
new daily survival probability |
times |
vector of times to set the new values |
places |
vector of places to set the new values |
no return value
This model complies with the visitors component interface. It adds
a named list model$alternative
.
setup_alternative_trace(model, O = NULL)
setup_alternative_trace(model, O = NULL)
model |
an object from make_MicroMoB |
O |
a time varying trace passed to time_patch_varying_parameter
or |
no return value
A single compartment for all aquatic stages is modeled which suffers density dependent mortality like the Beverton-Holt model.
setup_aqua_BH(model, stochastic, molt, surv, K, L)
setup_aqua_BH(model, stochastic, molt, surv, K, L)
model |
an object from make_MicroMoB |
stochastic |
should the model update deterministically or stochastically? |
molt |
proportion of immature stages which will mature and emerge as adults each day (may be time and patch varying see time_patch_varying_parameter) |
surv |
daily survival probability (may be time and patch varying see time_patch_varying_parameter) |
K |
carrying capacity (may be time and patch varying see time_patch_varying_parameter) |
L |
initial number of immature mosquitoes |
All parameters can be passed either as a vector of length equal to l
, a matrix with l
rows
and tmax
columns, or a matrix with l
rows and 365
columns.
no return value
Emergence is passed as a (possibly time varying) parameter which is
decoupled from the adult mosquito dynamics. This module assumes l
and p
are equivalent, as emergence rates are given for p
.
setup_aqua_trace(model, lambda, stochastic)
setup_aqua_trace(model, lambda, stochastic)
model |
an object from make_MicroMoB |
lambda |
daily emergence of mosquitoes, may be time and patch varying, see time_patch_varying_parameter |
stochastic |
should the model update deterministically or stochastically? |
no return value
This is a queueing model (M/M/inf) of superinfection in humans.
setup_humans_MOI( model, stochastic, theta, wf = NULL, H, MOI, b = 0.55, c = 0.15, r = 1/200, sigma = 1 )
setup_humans_MOI( model, stochastic, theta, wf = NULL, H, MOI, b = 0.55, c = 0.15, r = 1/200, sigma = 1 )
model |
an object from make_MicroMoB |
stochastic |
should the model update deterministically or stochastically? |
theta |
a time spent matrix |
wf |
biting weights |
H |
vector of strata population sizes |
MOI |
a matrix giving the distribution of persons across strata (columns) and multiplicity of infection (rows). |
b |
transmission efficiency (mosquito to human) |
c |
transmission efficiency (human to mosquito) |
r |
recovery rate (inverse of infectious duration) |
sigma |
control non-independence of pathogen clearance; |
no return value
The step_humans method for the MOI model will grow the MOI
matrix (add rows) if an individual's MOI exceeds the size of the matrix; therefore
it's a good idea to pad the input matrix with extra empty rows to avoid
reallocating memory during the simulation as much as possible.
A simple SIP (Susceptible-Infected-Protected) model
setup_humans_SIP( model, stochastic, theta, wf = NULL, SIP, b = 0.55, c = 0.15, r = 1/200, rho = 0.07, eta = 1/32 )
setup_humans_SIP( model, stochastic, theta, wf = NULL, SIP, b = 0.55, c = 0.15, r = 1/200, rho = 0.07, eta = 1/32 )
model |
an object from make_MicroMoB |
stochastic |
should the model update deterministically or stochastically? |
theta |
a time spent matrix |
wf |
biting weights |
SIP |
matrix of strata (rows) by health states (SIP) |
b |
transmission efficiency (mosquito to human) |
c |
transmission efficiency (human to mosquito) |
r |
recovery rate (inverse of infectious duration) |
rho |
probability of treatment upon infection |
eta |
rate at which prophylaxis decays |
no return value
A simple SIR (Susceptible-Infected-Recovered) model
setup_humans_SIR( model, stochastic, theta, wf = NULL, H, SIR, b = 0.55, c = 0.15, gamma = 1/5 )
setup_humans_SIR( model, stochastic, theta, wf = NULL, H, SIR, b = 0.55, c = 0.15, gamma = 1/5 )
model |
an object from make_MicroMoB |
stochastic |
should the model update deterministically or stochastically? |
theta |
a time spent matrix |
wf |
biting weights |
H |
vector of strata population sizes |
SIR |
a matrix giving S, I, R counts (columns) for each strata (rows) |
b |
transmission efficiency (mosquito to human) |
c |
transmission efficiency (human to mosquito) |
gamma |
rate of recovery |
no return value
A simple SIS (Susceptible-Infected-Susceptible) model
setup_humans_SIS( model, stochastic, theta, wf = NULL, H, X, b = 0.55, c = 0.15, r = 1/200 )
setup_humans_SIS( model, stochastic, theta, wf = NULL, H, X, b = 0.55, c = 0.15, r = 1/200 )
model |
an object from make_MicroMoB |
stochastic |
should the model update deterministically or stochastically? |
theta |
a time spent matrix |
wf |
biting weights |
H |
vector of strata population sizes |
X |
number of infectious persons in each strata |
b |
transmission efficiency (mosquito to human) |
c |
transmission efficiency (human to mosquito) |
r |
recovery rate (inverse of infectious duration) |
no return value
This is a behavioral state model which allows for time varying EIP and survival probability. Mosquitoes transition between blood feeding (B) and oviposition (Q) depending on the success (or not) of those biological activities. It complies with the mosquito component interface, and may be simulated deterministically or stochastically.
setup_mosquito_BQ( model, stochastic, eip, pB, pQ, psiQ, Psi_bb, Psi_bq, Psi_qb, Psi_qq, nu = 25, M, Y )
setup_mosquito_BQ( model, stochastic, eip, pB, pQ, psiQ, Psi_bb, Psi_bq, Psi_qb, Psi_qq, nu = 25, M, Y )
model |
an object from make_MicroMoB |
stochastic |
should the model update deterministically or stochastically? |
eip |
the Extrinsic Incubation Period (may be time varying see time_varying_parameter) |
pB |
daily survival probability during blood feeding (may be time and patch varying see time_patch_varying_parameter) |
pQ |
daily survival probability during oviposition (may be time and patch varying see time_patch_varying_parameter) |
psiQ |
oviposition success probability (may be time and patch varying see time_patch_varying_parameter) |
Psi_bb |
movement matrix from blood feeding haunts to blood feeding haunts (columns must sum to 1, |
Psi_bq |
movement matrix from blood feeding haunts to aquatic habitats (columns must sum to 1, |
Psi_qb |
movement matrix from aquatic habitats to blood feeding haunts (columns must sum to 1, |
Psi_qq |
movement matrix from aquatic habitats to aquatic habitats (columns must sum to 1, |
nu |
number of eggs laid per oviposition |
M |
number of susceptible mosquitoes (vector of length |
Y |
number of incubating mosquitoes (matrix with |
no return value
This is a generalized RM model which allows for time varying EIP and survival probability. It complies with the mosquito component interface, and may be simulated deterministically or stochastically.
setup_mosquito_RM( model, stochastic, f = 0.3, q = 0.9, eip, p, psi, nu = 25, M, Y, Z, N = NULL )
setup_mosquito_RM( model, stochastic, f = 0.3, q = 0.9, eip, p, psi, nu = 25, M, Y, Z, N = NULL )
model |
an object from make_MicroMoB |
stochastic |
should the model update deterministically or stochastically? |
f |
the blood feeding rate |
q |
the human blood feeding fraction |
eip |
the Extrinsic Incubation Period (may be time varying see time_varying_parameter) |
p |
daily survival probability (may be time and patch varying see time_patch_varying_parameter) |
psi |
a mosquito dispersal matrix (rows must sum to 1) |
nu |
number of eggs laid per oviposition |
M |
total mosquito density per patch (vector of length |
Y |
density of incubating mosquitoes per patch (vector of length |
Z |
density of infectious mosquitoes per patch (vector of length |
N |
|
no return value
This is a null model of mosquito dynamics that is only for testing/verifying aquatic models. It implements a single method compute_oviposit.trace and all other methods throw an error.
setup_mosquito_trace(model, oviposit)
setup_mosquito_trace(model, oviposit)
model |
an object from make_MicroMoB |
oviposit |
a vector of length |
no return value
This model complies with the visitors component interface. It adds
a named list model$visitor
.
setup_visitor_trace(model, Wd = NULL, xd = NULL)
setup_visitor_trace(model, Wd = NULL, xd = NULL)
model |
an object from make_MicroMoB |
Wd |
a time varying trace of visitor host availability passed to time_patch_varying_parameter
or |
xd |
a time varying trace of visitor net infectiousness passed to time_patch_varying_parameter
or |
no return value
This method dispatches on the type of model$aqua
step_aqua(model)
step_aqua(model)
model |
an object from make_MicroMoB |
no return value
This function dispatches on the second class attribute of model$aqua
for stochastic or deterministic behavior.
## S3 method for class 'BH' step_aqua(model)
## S3 method for class 'BH' step_aqua(model)
model |
an object from make_MicroMoB |
no return value
Run a deterministic state update.
## S3 method for class 'BH_deterministic' step_aqua(model)
## S3 method for class 'BH_deterministic' step_aqua(model)
model |
an object from make_MicroMoB |
no return value
Run a stochastic state update.
## S3 method for class 'BH_stochastic' step_aqua(model)
## S3 method for class 'BH_stochastic' step_aqua(model)
model |
an object from make_MicroMoB |
no return value
This function does nothing as trace models do not have endogenous dynamics.
## S3 method for class 'trace' step_aqua(model)
## S3 method for class 'trace' step_aqua(model)
model |
an object from make_MicroMoB |
no return value
This method dispatches on the type of model$human
.
step_humans(model)
step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update MOI human model
## S3 method for class 'MOI' step_humans(model)
## S3 method for class 'MOI' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update MOI human model (deterministic)
## S3 method for class 'MOI_deterministic' step_humans(model)
## S3 method for class 'MOI_deterministic' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update MOI human model (stochastic)
## S3 method for class 'MOI_stochastic' step_humans(model)
## S3 method for class 'MOI_stochastic' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update SIP human model
## S3 method for class 'SIP' step_humans(model)
## S3 method for class 'SIP' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update SIP human model (deterministic)
## S3 method for class 'SIP_deterministic' step_humans(model)
## S3 method for class 'SIP_deterministic' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update SIP human model (stochastic)
## S3 method for class 'SIP_stochastic' step_humans(model)
## S3 method for class 'SIP_stochastic' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update SIR human model
## S3 method for class 'SIR' step_humans(model)
## S3 method for class 'SIR' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update SIR human model (deterministic)
## S3 method for class 'SIR_deterministic' step_humans(model)
## S3 method for class 'SIR_deterministic' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update SIR human model (stochastic)
## S3 method for class 'SIR_stochastic' step_humans(model)
## S3 method for class 'SIR_stochastic' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update SIS human model
## S3 method for class 'SIS' step_humans(model)
## S3 method for class 'SIS' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update SIS human model (deterministic)
## S3 method for class 'SIS_deterministic' step_humans(model)
## S3 method for class 'SIS_deterministic' step_humans(model)
model |
an object from make_MicroMoB |
no return value
Update SIS human model (stochastic)
## S3 method for class 'SIS_stochastic' step_humans(model)
## S3 method for class 'SIS_stochastic' step_humans(model)
model |
an object from make_MicroMoB |
no return value
This method dispatches on the type of model$mosquito
step_mosquitoes(model)
step_mosquitoes(model)
model |
an object from make_MicroMoB |
no return value
This function dispatches on the second argument of model$mosquito
for stochastic or deterministic behavior.
## S3 method for class 'BQ' step_mosquitoes(model)
## S3 method for class 'BQ' step_mosquitoes(model)
model |
an object from make_MicroMoB |
see step_mosquitoes.BQ_deterministic and step_mosquitoes.BQ_stochastic
no return value
Update blood feeding & oviposition (BQ) behavioral state mosquitoes (deterministic)
## S3 method for class 'BQ_deterministic' step_mosquitoes(model)
## S3 method for class 'BQ_deterministic' step_mosquitoes(model)
model |
an object from make_MicroMoB |
no return value
Update blood feeding & oviposition (BQ) behavioral state mosquitoes (stochastic)
## S3 method for class 'BQ_stochastic' step_mosquitoes(model)
## S3 method for class 'BQ_stochastic' step_mosquitoes(model)
model |
an object from make_MicroMoB |
no return value
This function dispatches on the second argument of model$mosquito
for stochastic or deterministic behavior.
## S3 method for class 'RM' step_mosquitoes(model)
## S3 method for class 'RM' step_mosquitoes(model)
model |
an object from make_MicroMoB |
see step_mosquitoes.RM_deterministic and step_mosquitoes.RM_stochastic
no return value
Update Ross-Macdonald mosquitoes (deterministic)
## S3 method for class 'RM_deterministic' step_mosquitoes(model)
## S3 method for class 'RM_deterministic' step_mosquitoes(model)
model |
an object from make_MicroMoB |
no return value
Update Ross-Macdonald mosquitoes (stochastic)
## S3 method for class 'RM_stochastic' step_mosquitoes(model)
## S3 method for class 'RM_stochastic' step_mosquitoes(model)
model |
an object from make_MicroMoB |
no return value
Update null mosquito population
## S3 method for class 'trace' step_mosquitoes(model)
## S3 method for class 'trace' step_mosquitoes(model)
model |
an object from make_MicroMoB |
no return value
If input is given as a matrix of population counts per strata (columns) and patch (rows), this function calculates the residency matrix and population size for the overall stratification of both residency and strata.
strata_to_residency_counts(H_counts)
strata_to_residency_counts(H_counts)
H_counts |
a matrix of population counts |
a list with three elements:
J
: the residency matrix mapping elements in H
to patches
H
: the overall population distribution over strata and patches
# taken from package tests J <- matrix( c(0.3, 0.5, 0.2, 0.1, 0.6, 0.3), nrow = 3, ncol = 2, byrow = FALSE ) H <- c(50, 60) H_overall <- J %*% diag(H) residency <- strata_to_residency_proportion(H_strata = H, J_strata = J)
# taken from package tests J <- matrix( c(0.3, 0.5, 0.2, 0.1, 0.6, 0.3), nrow = 3, ncol = 2, byrow = FALSE ) H <- c(50, 60) H_overall <- J %*% diag(H) residency <- strata_to_residency_proportion(H_strata = H, J_strata = J)
If input is given as a vector of population sizes per-strata, lumped over patches, and a separate matrix whose columns describe how each strata is distributed over patches, this function calculates the residency matrix and population size for the overall stratification of both residency and strata.
strata_to_residency_proportion(H_strata, J_strata)
strata_to_residency_proportion(H_strata, J_strata)
H_strata |
a vector of population size by strata |
J_strata |
a matrix whose columns sum to one giving the distribution of strata (columns) populations over patches (rows) |
a list with three elements:
assignment_indices
: provides a mapping from patch (rows) and strata (columns)
into the "unrolled" vector H
J
: the residency matrix mapping elements in H
to patches
H
: the overall population distribution over strata and patches
# taken from package tests J <- matrix( c(0.3, 0.5, 0.2, 0.1, 0.6, 0.3), nrow = 3, ncol = 2, byrow = FALSE ) H <- c(50, 60) # get the overall assignment of strata (cols) across patches (rows) H_overall <- J %*% diag(H) residency <- strata_to_residency_proportion(H_strata = H, J_strata = J)
# taken from package tests J <- matrix( c(0.3, 0.5, 0.2, 0.1, 0.6, 0.3), nrow = 3, ncol = 2, byrow = FALSE ) H <- c(50, 60) # get the overall assignment of strata (cols) across patches (rows) H_overall <- J %*% diag(H) residency <- strata_to_residency_proportion(H_strata = H, J_strata = J)
Input parameters that may vary by time and patch
time_patch_varying_parameter(param, p, tmax)
time_patch_varying_parameter(param, p, tmax)
param |
if given a matrix, it must have nrows equal to |
p |
number of patches |
tmax |
number of time steps |
a matrix with p
rows and tmax
columns
Input parameters that may vary by time
time_varying_parameter(param, tmax)
time_varying_parameter(param, tmax)
param |
a vector of length |
tmax |
number of time steps |
a vector with tmax
elements