| batch_project3 | R Documentation |
Function batch_project3 runs function project3() across series
of differing beginning conditions. Currently used to run sensitivity
analyses.
batch_project3(
used_mpms = NULL,
givenrate = NULL,
offset = NULL,
multiplier = NULL,
all_elems = NULL,
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,
benchmark = NULL,
stochastic = FALSE,
integeronly = FALSE,
substoch = 0L,
nreps = 1L,
times = 10000L,
prep_mats = 20L,
force_fb = FALSE,
exp_tol = 700,
theta_tol = 1e+08
)
used_mpms |
An integer vector detailing the MPMs entered in argument
|
givenrate |
A numeric vector giving values to replace targeted matrix
elements with. If used, then arguments |
offset |
A numeric vector giving the values to offset matrix elements
by. If used, then arguments |
multiplier |
A numeric vector giving values to multiply targeted matrix
elements by. If used, then arguments |
all_elems |
A logical value indicating whether to use the alterations
specified in argument |
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 with each projection. Can also be set
to the text value |
benchmark |
A logical value indicating whether to issue messages during
projection indicating progress. Defaults to |
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
|
A list of class adaptProjBatch, which is composed of three
elements:
proj_out |
A multi-layered list, with the top number of elements equal
to the number of |
ref |
A list with the same structure as |
control |
An integer vector giving the identities of the MPM altered in each top list. |
This function is currently used to run sensitivity analyses, in which the slope of the final population size is regressed against the the starting offset values for each element. Each regression is run on the offset values within each element.
The only arguments unique to this function are arguments used_mpms,
givenrate, offset, multiplier, and all_elems.
All others are passed to function project3.
Setting all_elems = TRUE will lead to very time-intensive analysis.
We encourage users to break down their analyses into smaller batches, in
order to make them more tractable.
library(lefko3)
data(cypdata)
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)
sizevector <- c(0, 0, 3.0, 15)
stagevector <- c("P1", "D", "Sm", "Lg")
repvector <- c(0, 0, 1, 1)
obsvector <- c(0, 0, 1, 1)
matvector <- c(0, 1, 1, 1)
immvector <- c(1, 0, 0, 0)
indataset <- c(0, 1, 1, 1)
binvec <- c(0, 0.5, 2.5, 9.5)
cypframe_small_raw <- sf_create(sizes = sizevector, stagenames = stagevector,
repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
immstatus = immvector, indataset = indataset, binhalfwidth = binvec)
cypraw_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)
cypraw_v2 <- 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_small_raw, stagesize = "sizeadded", NAas0 = TRUE,
NRasRep = TRUE)
cypraw_v3 <- 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",
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, 1500, 500),
type =c(1, 1, 1, 1, 1, 1, 1, 1, 3, 3),
stageframe = cypframe_raw, historical = FALSE)
cypmatrix2r <- rlefko2(data = cypraw_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")
cypmean <- lmean(cypmatrix2r)
cypsupp2r_small <- supplemental(stage3 = c("D", "Sm", "Lg", "P1"),
stage2 = c("P1", "P1", "P1", "rep"), eststage3 = c(NA, "Sm", "Lg", NA),
eststage2 = c(NA, "D", "D", NA), givenrate = c(0.05, NA, NA, NA),
offset = c(NA, NA, -0.1, NA), multiplier = c(NA, NA, NA, 0.5),
type =c(1, 1, 1, 3), stageframe = cypframe_small_raw, historical = FALSE)
cypmatrix2r_small <- rlefko2(data = cypraw_v2, stageframe = cypframe_small_raw,
year = "all", patch = "all", stages = c("stage3", "stage2", "stage1"),
size = c("size3added", "size2added"), supplement = cypsupp2r_small,
yearcol = "year2", patchcol = "patchid", indivcol = "individ")
cypmean_small <- lmean(cypmatrix2r_small)
cypmatrixL_small <- rleslie(data = cypraw_v3, start_age = 1, last_age = 4,
continue = TRUE, fecage_min = 3, year = "all", pop = NA, patch = "all",
yearcol = "year2", patchcol = "patchid", indivcol = "individ")
cyp_mpms1 <- list(cypmatrix2r, cypmatrix2r_small, cypmatrixL_small)
c2d_4 <- density_input(cypmean, stage3 = c("P1", "P1"), stage2= c("SD", "rep"),
style = 1, time_delay = 1, alpha = 1, beta = 0.0005, type = c(2, 2))
c2d_4a <- density_input(cypmean_small, stage3 = c("P1", "P1"), stage2= c("P1", "rep"),
style = 1, time_delay = 1, alpha = 1, beta = 0.0005, type = c(2, 2))
cypL_dv <- density_input(cypmatrixL_small, stage3 = c("Age1"), stage2 = c("rep"),
style = c(1), alpha = c(0.5), beta = c(1.0), type = c(2))
cyp_density <- list(c2d_4, c2d_4a, cypL_dv)
cyp_start1 <- start_input(cypmatrix2r, stage2 = c("SD", "P1", "D"),
value = c(100, 200, 4))
cyp_start2 <- start_input(cypmatrix2r_small, stage2 = c("P1", "D"),
value = c(10, 2000))
cypL_start_1 <- start_input(cypmatrixL_small, stage2 = c("Age1"),
value = c(200))
cyp_start <- list(cyp_start1, cyp_start2, cypL_start_1)
new_supplement_cyp2_small <- sup_skeleton(2)
new_supplement_cyp2_small$stage3 <- c("D", "Sm")
new_supplement_cyp2_small$stage2 <- c("Lg", "Lg")
new_supplement_cyp2_small$convtype <- c(1, 1)
used_supplements <- list(new_supplement_cyp2_small,
new_supplement_cyp2_small, NULL)
aaa1_prj_batch2 <- batch_project3(used_mpms = "all", all_elems = FALSE,
mpms = cyp_mpms1, entry_time = c(0, 5, 8), times = 15, nreps = 3,
supplement = used_supplements, integeronly = TRUE, density = cyp_density)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.