Run stratified analysis on simulated data

run_strat(
  sim,
  length_group = "inherit",
  alk_scale = "division",
  strat_data_fun = strat_data,
  strat_means_fun = strat_means
)

Arguments

sim

Simulation object from sim_survey().

length_group

Size of the length frequency bins used for both abundance-at-length calculations and age-length-key construction. By default, this is inherited from the value defined in sim_abundance() via the closure supplied to sim_length ("inherit"). You may also supply a numeric value; however, mismatches in length groupings may cause issues with strat_error() if true vs. estimated groupings are not aligned.

alk_scale

Spatial scale at which to construct and apply age-length keys: "division" or "strat".

strat_data_fun

Function used to prepare data for stratified analysis (e.g., strat_data()).

strat_means_fun

Function used to calculate stratified means (e.g., strat_means()).

Value

Adds stratified analysis results to the sim list:

  • "total_strat": Results for the total population

  • "length_strat": Results aggregated by length group

  • "age_strat": Results aggregated by age

Details

The strat_data_fun and strat_means_fun arguments allow you to use custom strat_data() and strat_means() functions.

Examples

# \donttest{
sim <- sim_abundance(ages = 1:5, years = 1:5,
                     R = sim_R(log_mean = log(1e+7)),
                     growth = sim_vonB(length_group = 1)) |>
  sim_distribution(grid = make_grid(res = c(20, 20)),
                   ays_covar = sim_ays_covar(sd = 1)) |>
  sim_survey(n_sims = 1, q = sim_logistic(k = 2, x0 = 3)) |>
  run_strat()
# }