set.seed(42) # set seed for repeatability
# A single vital rate and a single driver
driven_vital_rate(
driver = 14,
baseline_value = 0.5,
slope = .4,
baseline_driver = 10,
error_sd = 0,
link = "logit"
)
# A single vital rate and a time series of drivers
driven_vital_rate(
driver = runif(10, 5, 15),
baseline_value = 0.5,
slope = .4,
baseline_driver = 10,
error_sd = 0,
link = "logit"
)
# A matrix of survival values (U submatrix of a Leslie model)
# with a series of drivers, and matrices of slopes and errors
lt1 <- model_survival(params = c(b_0 = 0.4, b_1 = 0.5), model = "Gompertz")
lt1$fecundity <- model_fecundity(
age = 0:max(lt1$x), params = c(A = 10),
maturity = 3, model = "step"
)
mats <- make_leslie_mpm(
survival = lt1$px, fecundity = lt1$fecundity, n_stages =
nrow(lt1), split = TRUE
)
mats$mat_U
mat_dim <- nrow(mats$mat_U)
driven_vital_rate(
driver = runif(5, 5, 15),
baseline_value = mats$mat_U,
slope = matrix(.4,
nrow = mat_dim,
ncol = mat_dim
),
baseline_driver = 10,
error_sd = matrix(1, nrow = mat_dim, ncol = mat_dim),
link = "logit"
)
Run the code above in your browser using DataLab