Simulate basic population dynamics model

sim_abundance(
  ages = 1:20,
  years = 1:20,
  Z = sim_Z(),
  R = sim_R(),
  N0 = sim_N0(),
  growth = sim_vonB()
)

Arguments

ages

Ages to include in the simulation.

years

Years to include in the simulation.

Z

Total mortality function, like sim_Z, for generating mortality matrix.

R

Recruitment (i.e. abundance at min(ages)) function, like sim_R, for generating recruitment vector.

N0

Starting abundance (i.e. abundance at min(years)) function, like sim_N0, for generating starting abundance vector.

growth

Closure, such as sim_vonB, for simulating length given age. The function is used here to generate a abundance-at-age matrix and it is carried forward for later use in sim_survey to simulate lengths from survey catch at age.

Value

A list of length 9:

  • ages - Vector of ages in the simulation

  • lengths - Vector of length groups (depends on growth function)

  • years - Vector of years in the simulation

  • R - Vector of recruitment values

  • N0 - Vector of starting abundance values

  • Z - Matrix of total mortality values

  • N - Matrix of abundance values

  • N_at_length - Abundance at length matrix

  • sim_length - Function for simulating lengths given ages

Details

Abundance from is calculated using a standard population dynamics model. An abundance-at-length matrix is generated using a growth function coded as a closure like sim_vonB. The function is retained for later use in sim_survey to simulate lengths given simulated catch at age in a simulated survey. The ability to simulate distributions by length is yet to be implemented.

Examples

R_fun <- sim_R(log_mean = log(100000), log_sd = 0.1, random_walk = TRUE, plot = TRUE)
R_fun(years = 1:100)
sim_abundance(R = sim_R(log_mean = log(100000), log_sd = 0.5))
sim_abundance(years = 1:20,
              R = sim_R(log_mean = log(c(rep(100000, 10), rep(10000, 10))), plot = TRUE))

Z_fun <- sim_Z(log_mean = log(0.5), log_sd = 0.1, phi_age = 0.9, phi_year = 0.9, plot = TRUE)
Z_fun(years = 1:100, ages = 1:20)
sim_abundance(Z = sim_Z(log_mean = log(0.5), log_sd = 0.1, plot = TRUE))
Za_dev <- c(-0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.3, 0.2, 0.1, 0)
Zy_dev <- c(-0.2, -0.2, -0.2, -0.2, -0.2, 2, 2, 2, 2, 0.2, 0.2, 0.2, 0.2, 0.2, 0, 0, 0, 0, 0, 0)
Z_mat <- outer(Za_dev, Zy_dev, "+") + 0.5
sim_abundance(ages = 1:10, years = 1:20,
              Z = sim_Z(log_mean = log(Z_mat), plot = TRUE))
sim_abundance(ages = 1:10, years = 1:20,
              Z = sim_Z(log_mean = log(Z_mat), log_sd = 0, phi_age = 0, phi_year = 0, plot = TRUE))

N0_fun <- sim_N0(N0 = "exp", plot = TRUE)
N0_fun(R0 = 1000, Z0 = rep(0.5, 20), ages = 1:20)
sim_abundance(N0 = sim_N0(N0 = "exp", plot = TRUE))

growth_fun <- sim_vonB(Linf = 100, L0 = 5, K = 0.2, log_sd = 0.05, length_group = 1, plot = TRUE)
growth_fun(age = rep(1:15, each = 100))
growth_fun(age = 1:15, length_age_key = TRUE)
sim_abundance(growth = sim_vonB(plot = TRUE))

sim <- sim_abundance()
plot_trend(sim)
plot_surface(sim, mat = "N")
plot_surface(sim, mat = "Z")
plot_surface(sim, mat = "N_at_length", xlab = "Length", zlab = "N")