View source: R/matrixcreation.R
| rlefko2 | R Documentation |
Function rlefko2() returns raw ahistorical MPMs, including the
associated component transition and fecundity matrices, a data frame
describing the ahistorical stages used, and a data frame describing the
population, patch, and occasion time associated with each matrix.
rlefko2(
data,
stageframe,
year = "all",
pop = NULL,
patch = NULL,
censor = FALSE,
stages = NULL,
alive = c("alive3", "alive2"),
obsst = NULL,
size = c("sizea3", "sizea2"),
sizeb = NULL,
sizec = NULL,
repst = c("repstatus3", "repstatus2"),
matst = c("matstatus3", "matstatus2"),
fec = c("feca3", "feca2"),
supplement = NULL,
repmatrix = NULL,
overwrite = NULL,
yearcol = NULL,
popcol = NULL,
patchcol = NULL,
indivcol = NULL,
censorcol = NULL,
censorkeep = 0,
NRasRep = FALSE,
reduce = FALSE,
simple = FALSE,
err_check = FALSE,
sparse_output = FALSE
)
data |
A vertical demographic data frame, with variables corresponding
to the naming conventions in functions |
stageframe |
A stageframe object that includes information on the size, observation status, propagule status, reproduction status, immaturity status, and maturity status of each ahistorical stage. |
year |
A variable corresponding to observation occasion, or a set
of such values, given in values associated with the |
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 |
censor |
If |
stages |
An optional vector denoting the names of the variables within
the main vertical dataset coding for the stages of each individual in
occasions t+1 and t. The names of stages in these variables
should match those used in the |
alive |
A vector of names of binomial variables corresponding to status
as alive ( |
obsst |
A vector of names of binomial variables corresponding to
observation status in occasions t+1, t, and t-1,
respectively. Defaults to |
size |
A vector of names of variables coding the primary size variable
in occasions t+1 and t, respectively. Defaults to
|
sizeb |
A vector of names of variables coding the secondary size
variable in occasions t+1 and t, respectively. Defaults to
|
sizec |
A vector of names of variables coding the tertiary size
variable in occasions t+1 and t, respectively. Defaults to
|
repst |
A vector of names of variables coding reproductive status in
occasions t+1 and t, respectively. Defaults to
|
matst |
A vector of names of variables coding maturity 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 |
supplement |
An optional data frame of class |
repmatrix |
An optional reproduction matrix. This matrix is composed
mostly of 0s, with non-zero entries acting as element identifiers and
multipliers for fecundity (with 1 equaling full fecundity). If left blank,
and no |
overwrite |
An optional data frame developed with the
|
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. |
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 |
NRasRep |
If |
reduce |
A logical value denoting whether to remove ahistorical stages
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 |
If the user inputs a standard hfv_data object in argument
data, then this function will return an object of class
lefkoMat. If the user inputs an object of class hfv_list in
argument data, then the output will be an object of class
lefkoMatList, in which each element is an object of class
lefkoMat.
A lefkoMat object is a list that holds one full matrix projection
model and all of its metadata. The structure has 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 |
The default behavior of this function is to estimate fecundity with regards
to transitions specified via associated fecundity multipliers in the
supplement. If this field is left empty, then fecundity will be
estimated at full for all transitions leading from reproductive stages to
immature and propagule stages.
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.
Although this function is capable of assigning stages given an input
stageframe, it lacks the power of verticalize3() and
historicalize3() in this regard. Users are strongly
encouraged to use the latter two functions for stage assignment.
mpm_create()
flefko3()
flefko2()
aflefko2()
arlefko2()
fleslie()
rlefko3()
rleslie()
# Lathyrus example
data(lathyrus)
sizevector <- c(0, 100, 13, 127, 3730, 3800, 0)
stagevector <- c("Sd", "Sdl", "VSm", "Sm", "VLa", "Flo", "Dorm")
repvector <- c(0, 0, 0, 0, 0, 1, 0)
obsvector <- c(0, 1, 1, 1, 1, 1, 0)
matvector <- c(0, 0, 1, 1, 1, 1, 1)
immvector <- c(1, 1, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0)
indataset <- c(0, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 100, 11, 103, 3500, 3800, 0.5)
lathframe <- sf_create(sizes = sizevector, stagenames = stagevector,
repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
immstatus = immvector, indataset = indataset, binhalfwidth = binvec,
propstatus = propvector)
lathvert <- verticalize3(lathyrus, noyears = 4, firstyear = 1988,
patchidcol = "SUBPLOT", individcol = "GENET", blocksize = 9,
juvcol = "Seedling1988", sizeacol = "Volume88", repstracol = "FCODE88",
fecacol = "Intactseed88", deadacol = "Dead1988", nonobsacol = "Dormant1988",
stageassign = lathframe, stagesize = "sizea", censorcol = "Missing1988",
censorkeep = NA, censor = TRUE)
lathsupp2 <- supplemental(stage3 = c("Sd", "Sdl", "Sd", "Sdl"),
stage2 = c("Sd", "Sd", "rep", "rep"),
givenrate = c(0.345, 0.054, NA, NA),
multiplier = c(NA, NA, 0.345, 0.054),
type = c(1, 1, 3, 3), stageframe = lathframe, historical = FALSE)
ehrlen2 <- rlefko2(data = lathvert, stageframe = lathframe, year = "all",
stages = c("stage3", "stage2"), supplement = lathsupp2, yearcol = "year2",
indivcol = "individ")
# Cypripedium example
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)
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)
# Here we use supplemental() to provide overwrite and reproductive info
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)
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.