View source: R/matrixcreation.R
fleslie  R Documentation 
Function fleslie()
returns agebased (Leslie) MPMs corresponding to
the patches and occasions given, including the associated component
transition and fecundity matrices, data frames detailing the characteristics
of the exact ages corresponding to rows and columns in estimated matrices,
and a data frame characterizing the patch and occasion combinations
corresponding to these matrices.
fleslie(
year = "all",
patch = NULL,
prebreeding = TRUE,
data = NULL,
modelsuite = NULL,
surv_model = NULL,
fec_model = NULL,
paramnames = NULL,
supplement = NULL,
start_age = NA,
last_age = NA,
fecage_min = NA,
fecage_max = NA,
continue = TRUE,
inda = NULL,
indb = NULL,
indc = NULL,
surv_dev = 0,
fec_dev = 0,
density = NA,
fecmod = 1,
random.inda = FALSE,
random.indb = FALSE,
random.indc = FALSE,
negfec = FALSE,
reduce = FALSE,
simple = FALSE,
err_check = FALSE,
exp_tol = 700,
theta_tol = 1e+08,
sparse_output = FALSE
)
year 
A variable corresponding to observation occasion, or a set
of such values, given in values associated with the year term used in linear
model development. Defaults to 
patch 
A variable designating which patches or subpopulations will have
matrices estimated. Defaults to 
prebreeding 
A logical value indicating whether the life history model
is a prebreeding model. Defaults to 
data 
The historical vertical demographic data frame used to estimate
vital rates (class 
modelsuite 
One of two optional lists. THe first is an optional

surv_model 
A linear model predicting survival probability. This can be
a model of class 
fec_model 
A linear model predicting fecundity. This can be a model of
class 
paramnames 
A data frame with three columns, the first describing all
terms used in linear modeling, the second (must be called 
supplement 
An optional data frame of class 
start_age 
The age from which to start the matrix. Defaults to

last_age 
The final age to use in the matrix. 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 
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 
inda 
Can be a single value to use for individual covariate 
indb 
Can be a single value to use for individual covariate 
indc 
Can be a single value to use for individual covariate 
surv_dev 
A numeric value to be added to the yintercept in the linear
model for survival probability. Defaults to 
fec_dev 
A numeric value to be added to the yintercept in the linear
model for fecundity. Defaults to 
density 
A numeric value indicating density value to use to propagate
matrices. Only needed if density is an explanatory term used in linear
models. Defaults to 
fecmod 
A scalar multiplier of fecundity. Defaults to 
random.inda 
A logical value denoting whether to treat individual
covariate 
random.indb 
A logical value denoting whether to treat individual
covariate 
random.indc 
A logical value denoting whether to treat individual
covariate 
negfec 
A logical value denoting whether fecundity values estimated to
be negative should be reset to 
reduce 
A logical value denoting whether to remove ages associated
solely with 
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

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

sparse_output 
A logical value indicating whether to output matrices
in sparse format. Defaults to 
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 has the following
elements:
A 
A list of full projection matrices in order of sorted patches and
occasions. All matrices output in R's 
U 
A list of survival transition matrices sorted as in 
F 
A list of fecundity matrices sorted as in 
hstages 
Set to 
agestages 
Set to 
ahstages 
A data frame detailing the characteristics of associated ages, in the form of a modified stageframe including reproduction status. 
labels 
A data frame giving the patch and year of each matrix in order.
In 
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 nonzero elements in

modelqc 
This is the 
prob_out 
An optional element only added if 
Unlike rlefko2()
, rlefko3()
,
arlefko2()
, and rleslie()
, this function does not
currently distinguish populations.
This function will yield incorrect estimates if the models utilized incorporate state in occasion t1, or any size or reproductive status terms.
Users may at times wish to estimate MPMs using a dataset incorporating
multiple patches or subpopulations, but without discriminating between those
patches or subpopulations. Should the aim of analysis be a general MPM that
does not distinguish these patches or subpopulations, the
modelsearch()
run should not include patch terms.
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.
Care should be taken to match the random status of year and patch to the states of those variables within the modelsuite. If they do not match, then they will be treated as zeroes in vital rate estimation.
Individual covariates are treated as categorical only if they are set as
random terms. Fixed categorical individual covariates are currently not
allowed. However, such terms may be supplied if the modelsuite
option
is set to a vrm_input
object. In that case, the user should also set
the logical random switch for the individual covariate to be used to
TRUE
(e.g., random.inda = TRUE
).
mpm_create()
flefko3()
flefko2()
aflefko2()
arlefko2()
rlefko3()
rlefko2()
rleslie()
data(lathyrus)
lathvert_base < verticalize3(lathyrus, noyears = 4, firstyear = 1988,
patchidcol = "SUBPLOT", individcol = "GENET", blocksize = 9,
sizeacol = "Volume88", repstracol = "FCODE88", fecacol = "Intactseed88",
deadacol = "Dead1988", censorcol = "Missing1988", censorkeep = NA,
censor = TRUE, NAas0 = TRUE, NRasRep = TRUE, NOasObs = TRUE)
lathvert_base$feca3 < round(lathvert_base$feca3)
lathvert_base$feca2 < round(lathvert_base$feca2)
lathvert_base$feca1 < round(lathvert_base$feca1)
lathvert_age < subset(lathvert_base, firstseen > 1988)
lath_survival < glm(alive3 ~ obsage + as.factor(year2), data = lathvert_age,
family = "binomial")
lath_fecundity < glm(feca2 ~ obsage + as.factor(year2), data = lathvert_age,
family = "poisson")
mod_params < create_pm(name_terms = TRUE)
mod_params$modelparams[22] < "obsage"
lathmat2fleslie < fleslie(year = "all", data = lathvert_age,
surv_model = lath_survival, fec_model = lath_fecundity,
paramnames = mod_params, fecage_min = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.