set.seed(42) # set seed for repeatability
# First generate a set of MPMs
mpm_set <- rand_lefko_set(n = 5, n_stages = 5, fecundity = c(
0, 0, 4, 8, 10
), archetype = 4, output = "Type4")
# Now apply sampling error to this set
add_mpm_error(
mat_U = mpm_set$U_list, mat_F = mpm_set$F_list, sample_size =
50
)
# Also works with a single matrix.
mats <- make_leslie_mpm(
survival = c(0.1, 0.2, 0.5),
fecundity = c(0, 1.2, 2.4),
n_stages = 3, split = TRUE
)
# Sample size is a single value
add_mpm_error(mat_U = mats$mat_U, mat_F = mats$mat_F, sample_size = 20)
# Sample size is a list of two matrices
# here with a sample size of 20 for fecundity and 10 for growth/survival.
mpm_set <- rand_lefko_set(
n = 5, n_stages = 3, fecundity = c(0, 2, 4),
archetype = 4, output = "Type4"
)
ssMats <- list(
"mat_F_ss" = matrix(20, nrow = 3, ncol = 3),
"mat_U_ss" = matrix(10, nrow = 3, ncol = 3)
)
# Add sampling error to the matrix models
output <- add_mpm_error(
mat_U = mpm_set$U_list, mat_F = mpm_set$F_list,
sample_size = ssMats
)
# Examine the outputs
names(output)
output
Run the code above in your browser using DataLab