knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(IGPtoy)
Justin Pomeranz r format(Sys.time(), '%d %B, %Y')
This is a developmental package for simulation models for Intra-Guild Predation (IGP). It will be rolled into the mcbrnet
package upon completion.
igp_sim
: Function igp_sim()
simulates trophic dynamics within 3-species communities. By default, it produces a square landscape with patches randomly distributed by sampling x- and y- coordinates from a uniform distribution. Habitat structure can be controlled by supplying a distance matrix. This function follows the framework of Zhou et al. (2013), with the addition of a 3rd species and intraguild predation. See model description below for further details. You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("Jpomz/IGPtoy") library(IGPtoy)
igp_sim()
The key argument is the number of patches (n_patch
). Trophic dynamics are simulated through 1) local dynamics, and 2) dispersal (emigration and immigration).
Example:
igp <- igp_sim(n_patch = 10)
The function returns:
sp_dynamics
a data frame containing simulated trophic dynamics. df_patch
a data frame containing patch attributesfcl_state_prop
a data frame containing the proportion of patches that are in each FCL "state" at each time-step. sim_params
A data frame containing all of the simulation parameters The following script simulates trophic dynamics with n_patch = 5
. By default, igp_sim()
uses 200 time-steps for burn-in and records trophic dynamics for 1000 time steps.
igp <- igp_sim(n_patch = 10)
A named list of return values:
igp
Users can visualize the simulated dynamics in 5 random patches using plot_patch_dynamics = TRUE
. In addition, the proportion of FCL state in all patches across time can be visualized using plot_fcl = TRUE
igp <- igp_sim(n_patch = 10, plot_patch_dynamics = TRUE, plot_fcl = TRUE)
Users may use the following arguments to customize trophic dynamic simulations regarding 1) predation / search effort, 2) conversion efficiency, 3) productivity, and 4) dispersal ability.
Arguments alphabc
, betabc
and alphap
and betap
control the search effort and predation rate for species C and P, respectively. Argument P_pref
controls the preference of predator P for resource B.
The beta
variables control how fast the predation curve reaches the asymptote, and alpha
/ beta
determines the location of the asymptote. See Model Description for more details. Default values for alpha
and beta
parameters are 4 and 20, respectively.
P_pref
: default is NULL, and preference is calculated for each patch at every time step based on prey resource availability (see model description for more details). If a value is supplied, it is assumed constant across space and time and ignores resource availability.
Default values are set such as to make coexistence between all three species likely. For example, coexistence is more likely if C outcompetes P for resource B. We can make P a superior competitor by setting alphap = 10
:
igp_alpha10 <- igp_sim(alphap = 10, plot_patch_dynamics = TRUE)
Here, C generally goes locally extinct, and B and P are prone to extreme oscillations
Arguments ebc
, ebp
, and ecp
, control the efficiency of converting consumed resources into new consumer species. Parameters have the form eij where i is the resource species and j is the consumer species. The default conversion efficiency values are set at 2.
Arguments k_function
, k_base
, and r_max
control the productivity level for the basal species B.
k_function
can be one of (NULL, "environment", "patches-upstream"). If k_function = NULL
, carrying capacity does not vary across patches, and is fixed as k_base
.
k_function = "environment"
: Carrying capacity varies across patches according to an environmental value. The observed carrying capacity, K, for a patch is scaled from 50% to 150% of k_base
value, based on the environmental value. This is designed to work in conjunction with the brnet()
function from the mcbrnet
package (See Custom setting combine brnet and igp_sim below). For 2-dimensional networks (i.e., when a distance matrix is not supplied), an environmental value for each patch is sampled randomly from a normal distribution with mean = 0, and sd = 1. E.g., there is no spatial correlation in environmental values in 2D networks.
r_max
: controls the maximum reproductive value of the basal species, B.
igp1 <- igp_sim(n_patch = 100, k_function = NULL) igp2 <- igp_sim(n_patch = 100, k_function = "environment") c(mean(igp1$df_patch$basal_k), sd(igp1$df_patch$basal_k)) c(mean(igp2$df_patch$basal_k), sd(igp2$df_patch$basal_k)) #plot(density(igp1$df_patch$basal_k)) #plot(density(igp2$df_patch$basal_k))
Arguments p_dispersal
and theta
.
p_dispersal
controls the probability of an individual emigrating from a patch. This can be thought of as the proportion of the population emigrating at the beginning of each time step. If one value is supplied, it is assumed the same for all three species. If a vector of length = 3 is supplied, this sets the probability for B, C and P, respectively. p_dispersal
does not vary across patches or through time.
theta
: controls the rate of exponential decay for distance travelled for emigrants according to $theta$-1}. i.e., theta = 0.1
emigrants travel far, theta = 10
emigrants essentially do not travel.
WIP, below not finished
The number of prey consumed follows a Type II response according to $$W_{ij} = \frac{\alpha_{ij} N_{i} N_{j}} {\beta_{ij} N_{j} + N_{i}}$$
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.