Title: | Framework for Tick Population and Infection Modeling |
Version: | 0.3.0 |
Maintainer: | Myles Stokowski <mylesstokowski@gmail.com> |
Description: | Code to specify, run, and then visualize and analyze the results of Ixodidae (hard-bodied ticks) population and infection dynamics models. Such models exist in the literature, but the source code to run them is not always available. 'IxPopDyMod' provides an easy way for these models to be written and shared. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.2.3 |
URL: | https://github.com/dallenmidd/IxPopDyMod |
Depends: | R (≥ 3.2.4) |
Suggests: | covr, knitr, rmarkdown, testthat (≥ 3.0.0) |
Imports: | magrittr, stats, checkmate |
Language: | en-US |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2023-10-23 20:06:03 UTC; myles |
Author: | Myles Stokowski [aut, cre],
David Allen |
Repository: | CRAN |
Date/Publication: | 2023-10-23 20:20:02 UTC |
Calculate annual growth rate
Description
Calculate annual growth rate
Usage
annual_growth_rate(out)
Arguments
out |
Model output data frame |
Value
Numeric vector of length one representing the annual factor by which the total tick population changes. To use this function, it is best to run the model for at least three years.
Examples
## Not run:
out <- run(ogden2005)
annual_growth_rate(out)
## End(Not run)
Create a config
object
Description
Make a config
object from the input parameters, and ensure that the inputs
meet the requirements for the model. The returned object is a complete
description of a model run scenario.
Usage
config(
cycle,
initial_population,
preds = NULL,
steps = 365L,
max_duration = 365L,
verbose = TRUE
)
Arguments
cycle |
A tick's |
initial_population |
Named numeric vector indicating starting population for each life stage. Life stages not specified are assumed to be 0. |
preds |
Optional input |
steps |
Numeric vector of length one indicating the duration to run the model over in days. |
max_duration |
Numeric vector of length one. Determines the maximum number of days that a duration-based transition can last, after which ticks are removed from the model/die. Default of 365 is likely sensible for most cases. |
verbose |
Boolean; whether to warn about coercion to inputs |
Value
A config
object
Examples
# We build a simple example config
my_config <- config(
cycle = life_cycle(
transition("a", "b", function() 0.1, "probability"),
transition("b", "a", function() 10, "probability")
),
initial_population = c(a = 1)
)
# If we make a change to an existing `config`, it is a good idea to check
# whether it is still valid by calling `config()` on it again. For example,
# here we set the initial_population of a life stage that is not included in
# the life cycle.
my_config$initial_population <- c(a = 1, c = 1)
## Not run:
# Now, we re-run the validations, which will throw an error
do.call(config, my_config)
## End(Not run)
Simple model configuration example
Description
This model configuration uses only non-delay transitions, and no transitions depend on predictors (e.g. weather or host community). Parameter values are selected so that the population is stable over time.
Usage
config_ex_1
Format
A config
Simple model configuration example using delays
Description
This model configuration uses delay transitions for all transitions except
the adult to eggs transition. As in config_ex_1
, no transitions depend
on predictors, and the population is stable over time.
Usage
config_ex_2
Format
A config
Constant function
Description
Constant function
Usage
constant_fun(a)
Arguments
a |
Parameter |
Value
Numeric vector of length 1 equal to input parameter a
Examples
constant_fun(1)
Density dependent mortality
Description
Density dependent mortality
Usage
density_fun(x, y, a, b, c, pref)
Arguments
x |
Predictor 1 in transitions table. Numeric vector indicating host density for each of the host species. Length should be equal to the number of host species. |
y |
Predictor 2 in transitions table. Number of feeding ticks in life stages specified by predictor 2. |
a |
Parameter |
b |
Parameter |
c |
Parameter |
pref |
Parameters named |
Value
Numeric vector of length 1, indicating mortality rate
Examples
density_fun(c(10, 20), 100, .1, .3, .2, c(.5, .8))
Exponential function
Description
Exponential function
Usage
expo_fun(x, a, b)
Arguments
x |
Predictor 1 in transitions table. |
a |
Parameter |
b |
Parameter |
Value
Numeric vector of length 1
Examples
expo_fun(.5, .1, .3)
Probability of actively questing and then finding a host
Description
Probability of actively questing and then finding a host
Usage
feed_fun(x, y, a, pref, q, tmin, tmax)
Arguments
x |
Predictor 1 in transitions table. Numeric vector indicating host density for each of the host species. Length should be equal to the number of host species. |
y |
Predictor 2 in transitions table. Numeric vector of length 1 indicating temperature. |
a |
Parameter |
pref |
Parameters named |
q |
Parameter |
tmin |
Parameter |
tmax |
Parameter |
Details
Product of binomial and Briere functions (prob of finding a host) * (prob of active questing)
Value
Numeric vector of length 1
Examples
feed_fun(10, 30, .001, .1, .5, 20, 40)
Probability of finding a host and successfully feeding on it
Description
Probability of finding a host and successfully feeding on it
Usage
find_n_feed(x, a, pref, feed_success)
Arguments
x |
Predictor 1 in transitions table. Numeric vector indicating host density for each of the host species. Length should be equal to the number of host species. |
a |
Parameter |
pref |
Parameters named |
feed_success |
Parameters named |
Value
Numeric vector of length 1 indicating probability that ticks find any host and then successfully feed on that host.
Examples
find_n_feed(10, .1, 1, .5)
find_n_feed(runif(2) * 10, .1, runif(2), runif(2))
Format a predictor_spec
Description
Format a predictor_spec
Usage
## S3 method for class 'predictor_spec'
format(x, ...)
Arguments
x |
a predictor_spec |
... |
not used |
Value
string representation of input
Get a predictor from input data
Description
Get a predictor from input data
Usage
get_pred_from_table(time, pred, table)
Arguments
time |
Numeric vector of days to get data. Ignored if input is constant over time (as indicated by NA value in 'j_day' column) |
pred |
string specifying the name of the predictor, e.g. "host_den" |
table |
input predictors table |
Value
a numeric vector of predictor values
Calculate multiplicative growth rate of population
Description
Calculate multiplicative growth rate of population
Usage
growth_rate(out)
Arguments
out |
Model output data frame |
Value
Numeric vector of length one representing daily growth rate.
Examples
out <- run(config_ex_1)
growth_rate(out)
Configuration for showing how we can modify host community data
Description
Configuration for showing how we can modify host community data
Usage
host_example_config
Format
A config
Configuration for showing infection dynamics
Description
Configuration for showing infection dynamics
Usage
infect_example_config
Format
A config
Probability that a feeding tick becomes engorged infected or uninfected
Description
Probability that a feeding tick becomes engorged infected or uninfected
Usage
infect_fun(x, from_infected, to_infected, host_rc, pref)
Arguments
x |
Predictor 1 in transitions table. Numeric vector indicating host density for each of the host species. Length should be equal to the number of host species. |
from_infected |
Parameter |
to_infected |
Parameter |
host_rc |
Parameters named |
pref |
Parameters named |
Details
Since density dependent mortality is subtracted later, in this function we assume that all feeding ticks feed successfully and become engorged.
Value
Numeric vector of length 1
Examples
infect_fun(10, 0, 0, .3, 1)
infect_fun(10, 0, 1, .3, 1)
infect_fun(10, 1, 1, .3, 1)
Create a life_cycle
from a collection of transition
s
Description
Create a life_cycle
from a collection of transition
s
Usage
life_cycle(...)
Arguments
... |
A set of |
Value
a life_cycle
Constructor for transition functions
Description
Constructor for transition functions
Usage
new_transition_function(fun)
Arguments
fun |
A function Transition functions must return a numeric vector. See
|
Configuration for Ixodes scapularis population dynamics model from Ogden et al. 2005
Description
This model configuration recreates the Ixodes scapularis (blacklegged tick) population dynamics model from Ogden et al. 2005. This is a relatively complete model of tick population dynamics, including the effects of both temperature and the host community on tick life-stage transitions. We include this configuration to show that our package can be used to recreate existing models.
Usage
ogden2005
Format
A config
Details
In this config, the population starts with 10000 questing adults. The predictor data includes average temperature for each day, and density of hosts over the model run. Here the host community is stable with 20 deer and 200 mice.
See Also
Ogden et al. (2005) doi:10.1016/j.ijpara.2004.12.013
Examples
data(ogden2005)
## Not run:
output <- run(ogden2005)
graph_population_each_group(output)
## End(Not run)
Probability of actively questing times constant host finding probability
Description
Probability of actively questing times constant host finding probability
Usage
ogden_feed_fun(x, a, q, tmin, tmax)
Arguments
x |
Predictor 1 in transitions table. Numeric vector of length 1 indicating temperature. |
a |
Parameter |
q |
Parameter |
tmin |
Parameter |
tmax |
Parameter |
Details
(const prob of finding a host) * (prob of active questing)
Value
Numeric vector of length 1
See Also
Based on Ogden et al. (2005) doi:10.1016/j.ijpara.2004.12.013
Examples
ogden_feed_fun(30, .03, .01, 10, 35)
Create a set of parameters
Description
Create a set of parameters
Usage
parameters(...)
Arguments
... |
A set of named numeric vectors, each corresponding to a parameter. If a parameter is of length > 1, each element must be named. |
Value
a parameters
object
Examples
# create a set of scalar parameters
parameters(a = 1, b = 2)
# parameters of length > 1 may be useful for host-related parameters that
# differ between host species, for example tick feeding success
parameters(a = 1, feeding_success = c(deer = 0.49, squirrel = 0.17))
Specify how a single predictor should be used
Description
Specify how a single predictor should be used
Usage
predictor_spec(pred, first_day_only = TRUE)
Arguments
pred |
String indicating where to get predictor data. Can be one of:
|
first_day_only |
Boolean indicating whether to repeat the predictor data
value from the first day of a |
Value
a predictor_spec
list-based object
Create a table of predictors
Description
A data frame of input data to be used in as predictor values in transition functions.
Usage
predictors(df, verbose = FALSE)
Arguments
df |
input data frame, with columns:
|
verbose |
Boolean; whether to warn about reordering the |
Value
a predictors
object
Print a predictor_spec
Description
Print a predictor_spec
Usage
## S3 method for class 'predictor_spec'
print(x, ...)
Arguments
x |
a predictor_spec |
... |
not used |
Print a transition
Description
Print a transition
Usage
## S3 method for class 'transition'
print(x, ...)
Arguments
x |
A |
... |
not used |
Run the model
Description
Run the model
Usage
run(cfg, progress = TRUE)
Arguments
cfg |
An |
progress |
Boolean indicating whether to log progress every 100 steps |
Value
Data frame of population of ticks of each life stage each day
Examples
run(config_ex_1)
Mortality as a function of whether there is a snow on the ground
Description
Mortality as a function of whether there is a snow on the ground
Usage
snow_cover_fun(x, no_snow_mort, snow_mort)
Arguments
x |
amount of snow on ground |
no_snow_mort |
mortality with no snow on the ground |
snow_mort |
mortality with snow on the ground |
Configuration for showing how we can modify climate data
Description
Configuration for showing how we can modify climate data
Usage
temp_example_config
Format
A config
Create a transition
object
Description
A transition
object represents a single transition between two tick life
stages, or the mortality rate from a life stage.
Usage
transition(
from,
to,
fun,
transition_type,
mortality_type = NULL,
predictors = NULL,
parameters = list()
)
Arguments
from |
The name of the life stage a tick is transitioning from. |
to |
The name of the life stage a tick is transitioning to, or NULL if the transition is representing mortality. |
fun |
The transition function to evaluate.
The inputs of the function are predictors and parameters. The output is
the daily probability of completing the transition, for |
transition_type |
One of:
|
mortality_type |
One of:
|
predictors |
Optional, a named list of |
parameters |
Optional, a |
Value
a transition
object
Configuration for winter tick population dynamics model
Description
This is a model configuration based on a literature search on the factors affect the winter tick life cycle. Many of the transitions and parameters in this configuration are drawn from Drew and Samuel (1986). We include this configuration to show that our package is flexible for modeling multiple tick species with different life histories.
Usage
winter_tick
Format
An object of class config
of length 5.
See Also
Drew and Samuel (1986) doi:10.1139/z86-105
Drew and Samuel (1985) doi:10.7589/0090-3558-21.3.274
Addison and McLaughlin (1988) doi:10.2307/3282188
Ogden et al. (2005) doi:10.1016/j.ijpara.2004.12.013
Examples
data(winter_tick)
## Not run:
output <- run(winter_tick)
graph_population_each_group(winter_tick)
## End(Not run)