Provided an abundance at age matrix and a survey grid to populate, this function applies correlated space, age and year error to simulate the distribution of the population. The ability to simulate distributions by length is yet to be implemented.

sim_distribution(
  sim,
  grid = make_grid(),
  ays_covar = sim_ays_covar(),
  depth_par = sim_parabola()
)

Arguments

sim

A list with ages, years and an abundance at age matrix like produced by sim_abundance.

grid

A stars object defining the survey grid, like survey_grid or one produced by make_grid

ays_covar

Closure for simulating age-year-space covariance, like sim_ays_covar

depth_par

Closure for defining relationship between abundance and depth, like sim_parabola

Value

Appends three objects to the sim list:

  • grid - A stars object with the grid details

  • grid_xy - Grid details as a data.table in xyz format

  • sp_N - A data.table with abundance split by age, year and cell

Details

This function simulates the probability of simulated fish inhabiting a cell as a function of a parabolic relationship with depth and space, age, and year autocorrelated errors. WARNING: it make take a long time to simulate abundance in a large grid across many ages and years - start small first.

Examples


# \donttest{
sim <- sim_abundance(ages = 1:5, years = 1:5) %>%
           sim_distribution(grid = make_grid(res = c(20, 20)),
                            ays_covar = sim_ays_covar(phi_age = 0.8,
                                                      phi_year = 0.1),
                            depth_par = sim_parabola(mu = 200,
                                                     sigma = 50))
head(sim$sp_N)
#>    age year cell            N
#> 1:   1    1    1 9.258198e+01
#> 2:   2    1    1 1.178602e+01
#> 3:   3    1    1 1.007771e+02
#> 4:   4    1    1 1.839946e+01
#> 5:   5    1    1 5.368109e-01
#> 6:   1    2    1 8.844137e+04
head(sim$grid_xy)
#>       x   y depth cell division strat
#> 1: -130 130    77    1        1    10
#> 2: -110 130   175    2        1    11
#> 3:  -90 130   213    3        1    12
#> 4:  -70 130   214    4        1    12
#> 5:  -50 130   200    5        1    13
#> 6:  -30 130   192    6        1    13
# }