The MY Component
Models for Adult Mosquito Ecology and Infection Dynamics
Source:vignettes/MY-interface.Rmd
MY-interface.Rmd
The MY component was designed to model adult mosquito ecology and infection dynamics.
This vignette takes a deep dive into the design and structure of the MY component. It is useful for anyone who wants to learn more about how the code works.
Overview
The MY component adult mosquito ecology and infection dynamics. We let M describe a state space describing mosquito ecology, and Y an embedded state space describing parasite or pathogen infection dynamics. Since Y is embedded within M, the two processes are handled together.
The Y component interacts with X through blood feeding and transmission:
All Y components are developed around net-infectiousness, or \(\kappa,\) the probability of becoming infected after blood feeding on a human.
Each module must supply a function \(F_Z\) that computes the expected number of infectious bites on humans. This is processed by the XY interface and transformed into the daily EIR for all the XH component strata.
The M component interacts with L through egg laying and emergence.
The M component is developed around the net emergence rate of adult mosquitoes, or \(\Lambda.\)
Each M component must supply a function \(F_G\) that computes the number of eggs laid by the adult mosquito population in a patch. The ML-interface determines how the eggs are apportioned among all the habitats in a patch.
A functiondMYdt
computes the derivatives for differential equation modules.Update_MYt
updates the variables for discrete time systems.
Two important issues for MY components are adult mosquito demography, including mortality and dispersal and the method for handling mosquito bionomics as a baseline that is modified by control
Mosquito Demography
There are some built-in functions to compute a mosquito demographic matrix, \(\Omega,\) and a matrix that computes survival and dispersal through the EIP: \[\Upsilon = e^{-\Omega \tau}\]
For most of these models:: \[\Omega = -g - \sigma + (1-\mu) \sigma K\]
Mosquito Bionomics
The core challenge for implementing mosquito bionomics was how to handle time-varying parameters affected by two or more processes: a baseline value affected by resource availability or weather; and a new value that has been modified by the presence of vector control. This challenge applies to all mosquitoes, whether adult or immature, so it is handled separately: Bionomics.
Required Functions
Each MY module includes XX required functions and some optional ones.
Some of these required functions are S3
class functions
in adult-MY-interface.R. Others are defined for each
module.
One good example is the SI
module, posted in the
ramp.xds
github repository human-MY-SI.R.
The required functions deal with various tasks for model building and solving: constructing the MY model object; the dynamics; the parameters; the variables and their initial values; computing terms and standard outputs; and consistency checks. Optional outputs include other metrics; functions to compute steady states; and module specific functions to visualize the outputs.
Each module is defined by a string, generically called
MYname,
that identifies the module: e.g.
SI.
Dynamics
-
The dynamics are defined by at least one of the following is required, depending on whether the model family is a system of differential equations or a discrete time system:
dMYdt.MYname
:: differential equations are defined by a function that computes the derivatives. Inramp.xds
these are encoded in a function calleddMYdt.
The function is set up to be solved bydeSolve::ode
ordeSolve::dede.
Update_MYt.MYname
:: discrete time systems are defined by the function that updates the state variables in one time step. Inramp.xds
these are encoded in a function calledUpdate_MYt
that computes and returns the state variables. The forms mimic the ones used for differential equations.
MY Model Object
Each module has a pair of functions that set up a structured list
called the MY model object. The object is a list that
is assigned to a class
that dispatches the S3
functions described below. It is a compound list, where some of the
sub-lists are assigned their own class
that dispatch other
S3
functions.
-
make_MY_obj_MYname
:: returns a structured list called an MY model object:bionomic parameter values or bionomic parameter objects. In most models, the value of baseline bionomic parameters are functions of time, or exogenous variables that vary with time.
class(MY_obj)
=MYname
the indices for the model variables are stored as
MY_obj$ix
the initial values are stored as
MY_obj$inits
anything else that is needed can be configured here
setup_MY_obj.MYname
is a wrapper that callsmake_MY_obj_MYname
and (for the \(i^{th}\) species) attaches the object asxds_obj$MY_obj[[i]]
Parameters
change_MY_pars.MYname
changes the values of some parameters. It is designed to be used after setup. New parameter values are passed by name in a list calledoptions.
get_MY_pars.MYname
is a utility to inspect the values of the parameters.
Variables
Since the MY component is one of three, a function sets up the indices for all the variables in a model.
Two other functions use those indices: one pulls the variables from
the state variable vector \(y\); the
other one pulls the variables by name from an output matrix returned by
xds_solve.
After pulling, both functions return the variables in by name in a list to make it easy to inspect or use.
setup_MY_ix.MYname
- is the function that assigns an index to each variable in the model, and stores it asxds_obj$MY_obj[[i]]$ix.
The indices are returned as a named list.get_MY_vars.MYname
- retrieves the value of variables from the state variables vector \(y\) at a point in time and returns the values by name in a list; the function gets called bydMYdt
and bychange_MY_inits
and it can be useful in other contexts.parse_MY_orbits.MYname
- this function is likeget_MY_vars
but it parses the matrix of outputs returned byxds_solve.
Initial Values
A set of functions is sets up or changes the initial values for the state variables.
make_MY_inits_MYname
- each model must include a function that makes a set of initial values as a named list. This function does not belong to anyS3
class, so it can take any form. The function should supply default initial values for all the variables. These can be overwritten by passing new initial values inoptions.
setup_MY_inits.MYname
- is a wrapper, that gets called byxds_setup
and that callsmake_MY_inits_MYname.
The setupoptions
are passed to overwrite default values. The initial values are stored asMY_obj$inits.
change_MY_inits.MYname
- a utility to change the initial values.
Dynamical Terms
These functions compute dynamical terms – the outputs passed to an interface.
F_fqZ.MYname
-F_fqM.MYname
-F_eggs.MYname
-
Standard Outputs
Each module must output a few key quantities:
F_prevalence.MYname
- compute prevalenceF_ni.MYname
- compute net infectiousness (NI) for each stratum. If \(F_X \rightarrow X\) and \(F_H \rightarrow H\), then \(F_{ni} \rightarrow X/H.\) The function gets called after solving, and the NI is attached as a term for inspection and visualization.HTC.MYname
- compute the human transmitting capacity. This is used by functions inramp.work
that compute threshold conditions.
Consistency Checks
Some modules in ramp.xds
or
ramp.library
have been included for
various reasons. Not all of those models are capable of being extended.
To help users avoid using models in ways that are not appropriate, we
developed two function classes:
skill_set_MY.MYname
:: describes model capabilities and limitationscheck_MY.MYname
:: at the end ofxds_setup
and at the beginning ofxds_solve,
this function gets run to ensure that some quantities have been properly updated, and to see if anything has been added to a model that is not in its skill set.
Optional Functions
The MY interface also sets up S3
classes for some optional functions, but these might not be appropriate
for all models. If a function is not in the skill set of the
module, then the limitation should be noted in the documentation of
skill_set_MY.MYname
with information in the list.
Steady States
Methods are defined to compute various steady states under static parameter values.
steady_state_M.MYname
:: pass the emergence rate of adult mosquitoes and compute steady states for the M component.steady_state_MY.MYname
:: pass the emergence rate of adult mosquitoes and net infectiousness, and compute the steady states for the MY component.steady_state_Y.MYname
:: pass adult mosquito population density and net infectiousness, and compute the steady states for the Y component.