project3 {adapt3} | R Documentation |
Project Multiple MPMs With or Without Density Dependence
Description
Function project3
uses pre-existing or function-based MPMs to run
community projection simulations, in which different populations are run as
separate MPMs. Density dependence can be used with individual equivalence
vectors specifying Lotka-Volterra coefficients to adjust overall population
sizes to make them comparable.
Usage
project3(
mpms = NULL,
vrms = NULL,
stageframes = NULL,
supplements = NULL,
equivalence = NULL,
starts = NULL,
years = NULL,
patches = NULL,
tweights = NULL,
format = NULL,
entry_time = NULL,
sp_density = NULL,
ind_terms = NULL,
dev_terms = NULL,
fb_sparse = NULL,
firstage = NULL,
finalage = NULL,
fecage_min = NULL,
fecage_max = NULL,
cont = NULL,
fecmod = NULL,
density = NULL,
density_vr = NULL,
err_check = NULL,
stochastic = FALSE,
integeronly = FALSE,
substoch = 0L,
nreps = 1L,
times = 10000L,
prep_mats = 20L,
force_fb = FALSE,
exp_tol = 700,
theta_tol = 1e+08
)
Arguments
mpms |
An optional list of MPMs. Each MPM must be of class
|
vrms |
An optional list of |
stageframes |
An optional list of stageframes, corresponding in number
and order to the MPMs in argument |
supplements |
An optional list of data frames of class |
equivalence |
An optional numeric vector, list of numeric vectors,
data frame of class |
starts |
An optional list of |
years |
An optional term corresponding either to a single integer vector
of time |
patches |
An optional string vector with length equal to the number of
MPMs, detailing the name of each patch to project for each MPM, in order.
Only a single pop-patch may be projected for each MPM given. A value of
|
tweights |
An optional list composed of numeric vectors or matrices
denoting the probabilities of choosing each matrix in each MPM in a
stochastic projection. If an element of the list is a matrix, then a
first-order Markovian environment is assumed, in which the probability of
choosing a specific annual matrix depends on which annual matrix is
currently chosen. If an element of the list is a vector, then the choice of
annual matrix is assumed to be independent of the current matrix. Defaults
to equal weighting among matrices. If used, then one element per MPM is
required, with equal weighting assumed for any element set to |
format |
An optional integer vector indicating the kind of
function-based MPM to create for each |
entry_time |
An optional integer vector giving the entry time for each
MPM into the projection. Defaults to a zero vector with the length of the
number of MPMs, as given either by argument |
sp_density |
An optional argument for use with |
ind_terms |
An optional argument providing values of individual or
environmental covariate values for |
dev_terms |
An optional list of data frames, one for each
|
fb_sparse |
A logical vector indicating whether function-based MPMs
should be produced in sparse matrix format. Defaults to |
firstage |
An optional integer vector used for function-based Leslie
and age-by-stage MPMs giving the starting ages in such MPMs. Use only if at
least one MPM is both function-based and has age structure. Typically,
the starting age in such MPMs should be set to |
finalage |
An optional integer vector used for function-based Leslie and age-by-stage MPMs giving the final ages in such MPMs. Use only if at least one MPM is both function-based and has age structure. Do not use if no MPM has age structure. |
fecage_min |
An optional integer vector used for function-based Leslie
MPMs giving the first age at which organisms can be reproductive in such
MPMs. Use only if at least one MPM is a function-based Leslie MPM. Defaults
to the values given in |
fecage_max |
An optional integer vector used for function-based Leslie
MPMs giving the final age at which organisms can be reproductive in such
MPMs. Use only if at least one MPM is a function-based Leslie MPM. Defaults
to the values given in |
cont |
An optional vector used for function-based Leslie and
age-by-stage MPMs stating whether the MPM should should include a stasis
transition within the final age. This should be used only when an organism
can maintain the demographic characteristics of the final described age
after reaching that age. Can be entered as a logical vector or an integer
vector. MPMs without age structure should be entered as |
fecmod |
An optional vector used for function-based MPMs giving scalar
multipliers for fecundity terms, when two fecundity variables are used for a
collective fecundity per individual. Each entry refers to each
|
density |
An optional list of data frames of class |
density_vr |
An optional list of data frames of class
|
err_check |
A logical value indicating whether to include an extra list
of output objects for error checking. Can also be set to the text value
|
stochastic |
A logical value indicating whether the projection will be
run as a temporally stochastic projection. Defaults to |
integeronly |
A logical value indicating whether to round the number of
individuals projected in each stage at each occasion in each MPM to the
nearest integer. Defaults to |
substoch |
An integer value indicating whether to force survival-
transition matrices to be substochastic in density dependent and density
independent simulations. Defaults to |
nreps |
The number of replicate projections. Defaults to |
times |
Number of occasions to iterate per replicate. Defaults to
|
prep_mats |
An integer value for use when creating function-based MPM
projections. If using |
force_fb |
A logical value indicating whether to force function-based
MPMs to be developed at each time step even if fewer than |
exp_tol |
A numeric value used to indicate a maximum value to set
exponents to in the core kernel to prevent numerical overflow. Defaults to
|
theta_tol |
A numeric value used to indicate a maximum value to theta as
used in the negative binomial probability density kernel. Defaults to
|
Value
A list of class adaptProj
, with the following elements:
comm_out |
A two-level list with the top level list having number of elements equal to the number of MPMs used as input, and the lower level corresponding to the number of replicates. Each element of the lower level list is a data frame showing the number of individuals in each stage at each time. Rows and columns in the data frames correspond to stages and time steps, respectively. |
N_out |
A list with the number of elements equal to the number of replicates. Each element within this list is data frame showing the number of individuals of each species or genotype alive at each time. The number of rows are equal to the number of MPMs used, and the columns correspond to the time steps. |
stageframe_list |
A list in which each element is the stageframe for each MPM used. |
hstages_list |
A list giving the used |
agestages_list |
A list giving the used |
labels |
A small data frame giving the the population and patch identities for each MPM entered. |
err_check |
An optional list composed of an additional six lists, each
of which has the number of elements equal to the number of MPMs utilized.
List output include |
Notes
This function has been optimized in the function-based approach such that
if there are relatively few matrices required per MPM to run the projection
forward, then these matrices will be made prior to running the projection.
This approach saves time, but only if there are relatively few unique
matrices required for each MPM. If many or only unique MPMs are required at
each time step, then the matrices will be made on the fly during the
projection itself. Such a situation will most likely occur if each time
step requires a new matrix resulting from a unique individual covariate
value, or if the density_vr
argument is used. The key argument
determining this behavior is prep_mats
, which provides the maximum
limit for the number of matrices required per MPM in order to create
matrices prior to projection.
Examples
library(lefko3)
data(cypdata)
data(cypa_data)
sizevector <- c(0, 0, 0, 0, 0, 0, 1, 2.5, 4.5, 8, 17.5)
stagevector <- c("SD", "P1", "P2", "P3", "SL", "D", "XSm", "Sm", "Md", "Lg",
"XLg")
repvector <- c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
obsvector <- c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
matvector <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
immvector <- c(0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
indataset <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 0, 0, 0, 0, 0.5, 0.5, 1, 1, 2.5, 7)
cypframe_raw <- sf_create(sizes = sizevector, stagenames = stagevector,
repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
propstatus = propvector, immstatus = immvector, indataset = indataset,
binhalfwidth = binvec)
cycaraw_v1 <- verticalize3(data = cypdata, noyears = 6, firstyear = 2004,
patchidcol = "patch", individcol = "plantid", blocksize = 4,
sizeacol = "Inf2.04", sizebcol = "Inf.04", sizeccol = "Veg.04",
repstracol = "Inf.04", repstrbcol = "Inf2.04", fecacol = "Pod.04",
stageassign = cypframe_raw, stagesize = "sizeadded", NAas0 = TRUE,
NRasRep = TRUE)
cyparaw_v1 <- verticalize3(data = cypa_data, noyears = 18, firstyear = 1994,
individcol = "plant_id", blocksize = 2, sizeacol = "Inf.94",
sizebcol = "Veg.94", repstracol = "Inf.94", fecacol = "Inf.94",
stageassign = cypframe_raw, stagesize = "sizeadded", NAas0 = TRUE,
NRasRep = TRUE)
cypsupp2r <- supplemental(stage3 = c("SD", "P1", "P2", "P3", "SL", "D",
"XSm", "Sm", "SD", "P1"),
stage2 = c("SD", "SD", "P1", "P2", "P3", "SL", "SL", "SL", "rep",
"rep"),
eststage3 = c(NA, NA, NA, NA, NA, "D", "XSm", "Sm", NA, NA),
eststage2 = c(NA, NA, NA, NA, NA, "XSm", "XSm", "XSm", NA, NA),
givenrate = c(0.10, 0.20, 0.20, 0.20, 0.25, NA, NA, NA, NA, NA),
multiplier = c(NA, NA, NA, NA, NA, NA, NA, NA, 0.5, 0.5),
type =c(1, 1, 1, 1, 1, 1, 1, 1, 3, 3),
stageframe = cypframe_raw, historical = FALSE)
cyp_supp_list1 <- list(cypsupp2r, cypsupp2r)
cycamatrix2r <- rlefko2(data = cycaraw_v1, stageframe = cypframe_raw,
year = "all", patch = "all", stages = c("stage3", "stage2", "stage1"),
size = c("size3added", "size2added"), supplement = cypsupp2r,
yearcol = "year2", patchcol = "patchid", indivcol = "individ")
cypamatrix2r <- rlefko2(data = cyparaw_v1, stageframe = cypframe_raw,
year = "all", stages = c("stage3", "stage2", "stage1"),
size = c("size3added", "size2added"), supplement = cypsupp2r,
yearcol = "year2", patchcol = "patchid", indivcol = "individ")
cyp_mpm_list <- list(cycamatrix2r, cypamatrix2r)
cyca2_start <- start_input(cycamatrix2r, stage2 = c("SD", "P1", "P2"),
value = c(500, 100, 200))
cypa2_start <- start_input(cypamatrix2r, stage2 = c("SD", "P1", "P2"),
value = c(5000, 1000, 2000))
cyp_start_list <- list(cyca2_start, cypa2_start)
cyp2_dv <- density_input(cypamatrix2r, stage3 = c("SD", "P1"),
stage2 = c("rep", "rep"), style = c(1, 1), alpha = c(0.5, 1.2),
beta = c(1.0, 2.0), type = c(2, 1))
cyp_dv_list <- list(cyp2_dv, cyp2_dv)
cyp_comm_proj <- project3(mpms = cyp_mpm_list, starts = cyp_start_list,
density = cyp_dv_list, times = 10)
summary(cyp_comm_proj)