Provided with an abundance-at-age matrix and a survey grid, this function applies correlated space–age–year error to simulate the spatial distribution of a population. Simulation by length is not yet implemented.
sim_distribution(
sim,
grid = make_grid(),
ays_covar = sim_ays_covar(),
depth_par = sim_parabola()
)
A list with ages
, years
, and an abundance-at-age matrix,
like one produced by sim_abundance()
.
A stars
object defining the survey grid, such as survey_grid
or one created with make_grid()
.
A closure that simulates age-year-space covariance, such as sim_ays_covar()
.
A closure that defines the relationship between abundance and depth,
such as sim_parabola()
.
Appends the following objects to the sim
list:
grid
: A stars
object with grid details
grid_xy
: A data.table
representation of the grid in XYZ format
sp_N
: A data.table
of abundance split by age, year, and cell
This function simulates the probability of fish inhabiting a cell based on a parabolic relationship with depth and spatially/temporally autocorrelated noise across age and year.
Warning: Simulating a large grid across many ages and years may be computationally intensive. Start with smaller simulations to test your setup.
# \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)
#> Key: <cell>
#> age year cell N
#> <num> <num> <num> <num>
#> 1: 1 1 1 0.1293681
#> 2: 2 1 1 0.1021903
#> 3: 3 1 1 33.7226965
#> 4: 4 1 1 24.2905118
#> 5: 5 1 1 0.3708926
#> 6: 1 2 1 3310.5485563
head(sim$grid_xy)
#> Key: <cell>
#> x y depth cell division strat
#> <num> <num> <num> <int> <num> <num>
#> 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
# }