Simulates a stratified-random survey on a population produced by sim_distribution(). Supports optional catchability functions, sampling caps, and custom set locations.

sim_survey(
  sim,
  n_sims = 1,
  q = sim_logistic(),
  trawl_dim = c(1.5, 0.02),
  resample_cells = FALSE,
  binom_error = TRUE,
  min_sets = 2,
  set_den = 2/1000,
  lengths_cap = 500,
  ages_cap = 10,
  age_sampling = "stratified",
  age_length_group = 1,
  age_space_group = "division",
  custom_sets = NULL,
  light = TRUE
)

Arguments

sim

A simulation object returned by sim_distribution().

n_sims

Number of surveys to simulate. Be cautious: large values may consume significant memory. Use sim_survey_parallel() if many simulations are needed.

q

A closure (e.g., sim_logistic()) for simulating catchability at age. Returned values must range between 0 and 1.

trawl_dim

Trawl width and distance (same units as the grid).

resample_cells

Logical. If TRUE, allows grid cells to be resampled. May introduce bias, as depletion is applied at the cell level.

binom_error

Logical. Should binomial error be imposed? If FALSE, stratified estimates at older ages may be biased due to rounding zeros.

min_sets

Minimum number of sets per stratum.

set_den

Set density (sets per grid unit squared). Warning: May error if set_den is high and resample_cells = FALSE, because allocated sets may exceed available cells.

lengths_cap

Maximum number of lengths measured per set.

ages_cap

Cap on the number of ages to sample, depending on age_sampling type:

  • If "stratified": maximum per length bin (via age_length_group) and per age_space_group (e.g., "division", "strat").

  • If "random": maximum number of fish aged per set.

age_sampling

Type of age sampling strategy: "stratified" (default) or "random".

age_length_group

Width of length bins for stratified age sampling. Ignored if age_sampling = "random".

age_space_group

Spatial scale for stratified age sampling. Options: "division" (default), "strat", or "set". Ignored if age_sampling = "random".

custom_sets

A data.table of set locations (same structure as returned by sim_sets()). If NULL, set locations are generated automatically.

light

Logical. If TRUE, drops some objects from output to reduce memory footprint.

Value

A list including:

  • Rounded simulation results

  • Set location details

  • Sampling results

Includes:

  • N: true population

  • I: individuals available to the survey

  • n: individuals caught by the survey

Examples

# \donttest{
sim <- sim_abundance(ages = 1:5, years = 1:5) |>
  sim_distribution(grid = make_grid(res = c(20, 20))) |>
  sim_survey(n_sims = 5, q = sim_logistic(k = 2, x0 = 3))

plot_survey(sim, which_year = 3, which_sim = 1)
#> No trace type specified:
#>   Based on info supplied, a 'scatter' trace seems appropriate.
#>   Read more about this trace type -> https://plotly.com/r/reference/#scatter
# }