run_strat function

Run stratified analysis on simulated data

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 from sim_survey

  • length_group: Size of the length frequency bins for both abundance at length calculations and age-length-key construction. By default this value is inherited from the value defined in sim_abundance from the closure supplied to sim_length ("inherit"). A numeric value can also be supplied, however, a mismatch in length groupings will cause issues with strat_error

    as true vs. estimated length groupings will be mismatched.

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

  • strat_data_fun: Function for preparing data for stratified analysis (e.g. strat_data)

  • strat_means_fun: Function for calculating stratified means (e.g. strat_means)

Returns

Adds stratified analysis results for the total population ("total_strat") and the population aggregated by length group and age ("length_strat" and "age_strat", respectively) to the sim list.

Details

The "strat_data_fun" and "strat_means_fun" allow the use of custom strat_data and strat_means functions.

Examples

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()