rleslie {lefko3} | R Documentation |
Create Raw Leslie (Age-based) Matrix Projection Model
Description
Function rleslie()
returns raw Leslie MPMs, including the
associated component transition and fecundity matrices, a data frame
describing the ages used, and a data frame describing the population, patch,
and occasion time associated with each matrix.
Usage
rleslie(
data,
start_age = NA,
last_age = NA,
continue = TRUE,
fecage_min = NA,
fecage_max = NA,
alive = c("alive3", "alive2", "alive1"),
repst = c("repstatus3", "repstatus2", "repstatus1"),
fec = c("feca3", "feca2", "feca1"),
agecol = "obsage",
year = "all",
supplement = NULL,
pop = NULL,
patch = NULL,
yearcol = NULL,
popcol = NULL,
patchcol = NULL,
indivcol = NULL,
censor = FALSE,
censorcol = NULL,
censorkeep = 0,
fectime = 2,
fecmod = 1,
prebreeding = TRUE,
reduce = FALSE,
simple = FALSE,
err_check = FALSE,
sparse_output = FALSE
)
Arguments
data |
A vertical demographic data frame, with variables corresponding
to the naming conventions in |
start_age |
The age from which to start the matrix. Defaults to
|
last_age |
The final age to use in the matrix. Defaults to |
continue |
A logical value designating whether to allow continued
survival of individuals past the final age noted in the stageframe, using the
demographic characteristics of the final age. Defaults to |
fecage_min |
The minimum age at which reproduction is possible. Defaults
to |
fecage_max |
The maximum age at which reproduction is possible. Defaults
to |
alive |
A vector of names of binomial variables corresponding to status
as alive ( |
repst |
A vector of names of variables coding reproductive status in
occasions t+1 and t, respectively. Defaults to
|
fec |
A vector of names of variables coding fecundity in occasions
t+1 and t, respectively. Defaults to |
agecol |
The name or column number of the variable coding for age in
|
year |
A variable corresponding to observation occasion, or a set
of such values, given in values associated with the |
supplement |
An optional data frame of class |
pop |
A variable designating which populations will have matrices
estimated. Should be set to specific population names, or to |
patch |
A variable designating which patches or subpopulations will have
matrices estimated. Should be set to specific patch names, or to |
yearcol |
The variable name or column number corresponding to occasion t in the dataset. |
popcol |
The variable name or column number corresponding to the identity of the population. |
patchcol |
The variable name or column number corresponding to patch in the dataset. |
indivcol |
The variable name or column number coding individual identity. |
censor |
If |
censorcol |
The variable name or column number denoting the censor
status. Only needed if |
censorkeep |
The value of the censor variable denoting data elements to
keep. Defaults to |
fectime |
An integer indicating whether to estimate fecundity using
the variable given for |
fecmod |
A scalar multiplier for fecundity. Defaults to |
prebreeding |
A logical value indicating whether the life history model
is a pre-breeding model. Defaults to |
reduce |
A logical value denoting whether to remove ages associated with
only zero transitions. These are removed only if the respective row and
column sums in ALL matrices estimated equal 0. Defaults to |
simple |
A logical value indicating whether to produce |
err_check |
A logical value indicating whether to append extra
information used in matrix calculation within the output list. Defaults to
|
sparse_output |
A logical value indicating whether to output matrices
in sparse format. Defaults to |
Value
If all inputs are properly formatted, then this function will return
an object of class lefkoMat
, which is a list that holds the matrix
projection model and all of its metadata. Its structure is a list with the
following elements:
A |
A list of full projection matrices in order of sorted populations,
patches, and occasions. All matrices output in the |
U |
A list of survival transition matrices sorted as in |
F |
A list of fecundity matrices sorted as in |
hstages |
A data frame matrix showing the pairing of ahistorical stages used to create historical stage pairs. Set to NA for ahistorical matrices. |
agestages |
A data frame showing age-stage pairs. In this function, it
is set to NA. Only used in output to function |
ahstages |
A data frame detailing the characteristics of associated ahistorical stages, in the form of a modified stageframe that includes status as an entry stage through reproduction. |
labels |
A data frame giving the population, patch, and year of each matrix in order. |
dataqc |
A vector showing the numbers of individuals and rows in the vertical dataset used as input. |
matrixqc |
A short vector describing the number of non-zero elements in
|
modelqc |
This is the |
Notes
In order to accomodate survival to time t+1 in the final year of a
study, the maximum age assessed if no input last_age
is provided is
one time step past the final described age.
Users may at times wish to estimate MPMs using a dataset incorporating
multiple patches or subpopulations. Should the aim of analysis be a general
MPM that does not distinguish these patches or subpopulations, the
patchcol
variable should be left to NA
, which is the default.
Otherwise the variable identifying patch needs to be named.
Input options including multiple variable names must be entered in the order of variables in occasion t+1 and t. Rearranging the order WILL lead to erroneous calculations, and may lead to fatal errors.
See Also
flefko3()
flefko2()
aflefko2()
arlefko2()
fleslie()
rlefko3()
rlefko2()
Examples
data(cypdata)
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",
age_offset = 3, NAas0 = TRUE, NRasRep = TRUE)
cyp_rl <- rleslie(data = cypraw_v1, start_age = 0, last_age = 4,
continue = TRUE, fecage_min = 3, year = "all", pop = NA, patch = "all",
yearcol = "year2", patchcol = "patchid", indivcol = "individ")