rand_lefko_set {mpmsim} | R Documentation |
Generate lists of Lefkovitch matrix population models (MPMs) based on life history archetypes
Description
This function generates a list of n
MPMs according to the specified
criteria. Criteria include the archetype
, and the acceptable constraining
criteria, which could include lambda, generation time or any other metric
derived from an A matrix. The function attempts to find matrices that fulfil
the criteria, discarding unacceptable matrices. By default, if it takes more
than 1000 attempts to find a suitable matrix model, then an error is
produced. However, the number of attempts can be altered with the attempts
parameter.
Usage
rand_lefko_set(
n_models = 5,
n_stages = 3,
archetype = 1,
fecundity = 1.5,
output = "Type1",
max_surv = 0.99,
constraint = NULL,
attempts = 1000
)
Arguments
n_models |
An integer indicating the number of MPMs to generate. |
n_stages |
The number of stages for the MPMs. Default is |
archetype |
The archetype of the MPMs. Default is |
fecundity |
Fecundity is the average number of offspring produced. Values can be provided in 4 ways:
In the latter case, a fecundity value will be drawn from a uniform distribution for the defined range. If there is no reproduction in a particular age class, use a value of 0 for both the lower and upper limit. |
output |
Character string indicating the type of output.
|
max_surv |
The maximum acceptable survival value, calculated across all
transitions from a stage. Defaults to |
constraint |
An optional data frame with 4 columns named |
attempts |
An integer indicating the number of attempts To be made when simulating matrix model. The default is 1000. If it takes more than 1000 attempts to make a matrix that satisfies the conditions set by the other arguments, then a warning is produced. |
Value
A compadreDB
object or list of MPMs that meet the specified
criteria.
Author(s)
Owen Jones jones@biology.sdu.dk
References
Caswell, H. (2001). Matrix Population Models: Construction, Analysis, and Interpretation. Sinauer.
Lefkovitch, L. P. (1965). The study of population growth in organisms grouped by stages. Biometrics, 21(1), 1.
Takada, T., Kawai, Y., & Salguero-Gómez, R. (2018). A cautionary note on elasticity analyses in a ternary plot using randomly generated population matrices. Population Ecology, 60(1), 37–47.
See Also
rand_lefko_mpm()
which this function is essentially a wrapper for.
Other Lefkovitch matrices:
generate_mpm_set()
,
rand_lefko_mpm()
,
random_mpm()
Examples
set.seed(42) # set seed for repeatability
# Basic operation, without splitting matrices and with no constraints
rand_lefko_set(
n_models = 3, n_stages = 5, fecundity = c(0, 0, 4, 8, 10),
archetype = 4, output = "Type5"
)
# Constrain outputs to A matrices with lambda between 0.9 and 1.1
library(popbio)
constrain_df <- data.frame(
fun = "lambda", arg = NA, lower = 0.9, upper =
1.1
)
rand_lefko_set(
n_models = 10, n_stages = 5, fecundity = c(0, 0, 4, 8, 10),
archetype = 4, constraint = constrain_df, output = "Type5"
)
# As above, but using popdemo::eigs function instead of popbio::lambda
# to illustrate use of argument
library(popdemo)
constrain_df <- data.frame(
fun = "eigs", arg = "lambda", lower = 0.9, upper = 1.1
)
rand_lefko_set(
n_models = 10, n_stages = 5, fecundity = c(0, 0, 4, 8, 10),
archetype = 4, constraint = constrain_df, output = "Type5"
)
# Multiple constraints
# Constrain outputs to A matrices with lambda between 0.9 and 1.1, generation
# time between 3 and 5 and damping ratio between 1 and 7.
library(popbio)
constrain_df <- data.frame(
fun = c("lambda", "generation.time", "damping.ratio"),
arg = c(NA, NA, NA),
lower = c(0.9, 3.0, 1.0),
upper = c(1.1, 5.0, 7.0)
)
rand_lefko_set(
n_models = 10, n_stages = 5, fecundity = c(0, 0, 4, 8, 10),
archetype = 4, constraint = constrain_df, output = "Type5"
)