Set up the recruitment module and associated processes
Setup_Mod_Rec.RdConfigures all recruitment-related components of the estimation model:
stock-recruit relationship type and density-dependence structure,
Beverton-Holt steepness and priors, recruitment variability
(\(\sigma_R\)), annual and initial age-structure deviations, regional
and seasonal recruitment apportionment, spawning movement and stray rates,
sex ratio dynamics, equilibrium initialisation method, and the recruitment
bias ramp. Delegates parameter mapping to a family of internal helpers
(do_sigmaR_mapping, do_RecDevs_mapping,
do_InitDevs_mapping, do_h_mapping,
do_sexratio_pars_mapping,
do_rec_region_prop_mapping,
do_rec_seas_prop_mapping). Must be called after
Setup_Mod_Dim and Setup_Mod_Biologicals, and
before model compilation.
Usage
Setup_Mod_Rec(
input_list,
rec_model,
rec_dd = "global",
rec_lag = 1,
Use_h_prior = 0,
h_prior = NULL,
rec_region_prop_spec = NULL,
use_rec_region_prop_prior = 0,
rec_region_prop_prior = NULL,
rec_seas_prop_spec = "fix",
use_rec_seas_prop_prior = 0,
rec_seas_prop_prior = NULL,
use_fixed_rec_seas_prop = 1,
fixed_rec_seas_prop = {
rec_seas_prop = array(0, dim = c(input_list$data$n_pop,
input_list$data$n_seas))
rec_seas_prop[, 1] <- 1
rec_seas_prop
},
do_rec_bias_ramp = 0,
bias_year = NA,
max_bias_ramp_fct = 1,
sigmaR_switch = 1,
dont_est_recdev_last = 0,
init_age_strc = 2,
equil_init_age_strc = 1,
init_F_prop = array(0, dim = c(input_list$data$n_regions, input_list$data$n_seas,
input_list$data$n_fish_fleets)),
sigmaR_spec = "est_all",
InitDevs_spec = NULL,
RecDevs_spec = NULL,
h_spec = NULL,
sgl_seas_spawning_movement = NA,
t_spawn = 0,
stray_rate_spec = "fix",
stray_rate_blocks = paste0("none_Pop_", seq_len(input_list$data$n_pop)),
use_fixed_stray_rate = if (stray_rate_spec != "fix") 0 else 1,
fixed_stray_rate = array(0, dim = c(input_list$data$n_pop,
length(input_list$data$years))),
use_stray_rate_prior = 0,
stray_rate_prior = NULL,
spawn_seas = 1,
sexratio_spec = "fix",
sexratio_blocks = {
grid <- expand.grid(region = 1:input_list$data$n_regions, pop
= 1:input_list$data$n_pop)
blks <- paste0("none_Pop_", grid$pop, "_Region_",
grid$region)
blks
},
use_rinit = 0,
init_age_devs_shared = NULL,
use_r0_prior = 0,
r0_prior = NULL,
...
)Arguments
- input_list
Named list with
$data,$par,$map, and$verbosesublists, as returned by upstream setup functions. Population, region, age, year, and season dimensions must already be defined in$data.- rec_model
Character string (required). Stock-recruit relationship:
"mean_rec"Fixed mean recruitment; no stock-recruit relationship. Steepness is automatically fixed and not estimated.
"bh_rec"Beverton-Holt stock-recruit relationship.
- rec_dd
Density-dependence structure. Default
"global"."local"Independent stock-recruit relationship per population. Required when
n_pop > 1."global"Single pooled spawner-recruit relationship across all regions. Constrains
h_spec,RecDevs_spec, andInitDevs_specto shared or fixed options whenn_regions > 1.
- rec_lag
Integer. Lag between spawning biomass and recruitment (in seasons).
1(default) is the classic lagged case: recruitment uses SSB fromrec_lagseasons prior and may enter in any season.0is age-0 recruitment: recruitment uses the SAME year's SSB, and because that SSB isn't known untilspawn_seasis reached, recruits may only enter inspawn_seasitself or a later season – whenuse_fixed_rec_seas_prop = 1,fixed_rec_seas_propmust be zero beforespawn_seas; when estimated, this is enforced structurally via a restricted softmax (seedo_rec_seas_prop_mapping).- Use_h_prior
Integer (0/1). Whether normal priors on steepness are applied. Only relevant for
rec_model = "bh_rec". Default0.- h_prior
Data frame of steepness prior parameters. Required columns:
pop,region,mu,sd. Ignored whenUse_h_prior = 0. DefaultNULL.- rec_region_prop_spec
Character or
NULL. Regional recruitment dispersal structure. DefaultNULL(estimate all proportions freely). Seedo_rec_region_prop_mappingfor full option descriptions including"no_dispersal". Stored as$data$rec_region_prop_spec:0= full dispersal,1= no dispersal.- use_rec_region_prop_prior
Integer (0/1). Whether Dirichlet priors are applied to regional recruitment proportions. Not valid when
n_regions = 1. Default0.- rec_region_prop_prior
Data frame of Dirichlet prior concentration parameters. Required columns:
popandalpha, wherealphais a list-column of length-n_regionsvectors. Ignored whenuse_rec_region_prop_prior = 0. DefaultNULL.- rec_seas_prop_spec
Character or
NULL. Seasonal recruitment apportionment structure. Default"fix". Seedo_rec_seas_prop_mappingfor full option descriptions including"est_shared_pop".- use_rec_seas_prop_prior
Integer (0/1). Whether Dirichlet priors are applied to seasonal recruitment proportions. Not valid when
n_seas = 1. Whenrec_lag = 0andspawn_seas > 1, the prior is evaluated only over seasonsspawn_seas:n_seas(the seasons beforespawn_seasare structurally zero, not estimated). Default0.- rec_seas_prop_prior
Data frame of Dirichlet prior concentration parameters for seasonal proportions. Required columns:
popandalpha. Ignored whenuse_rec_seas_prop_prior = 0. DefaultNULL.- use_fixed_rec_seas_prop
Integer (0/1). Whether fixed (non-estimated) seasonal proportions from
fixed_rec_seas_propare used. Automatically reset to0with a warning ifrec_seas_prop_specrequests estimation. Default1.- fixed_rec_seas_prop
Array
[n_pop x n_seas]. Fixed seasonal recruitment proportions used whenuse_fixed_rec_seas_prop = 1. Default: all recruitment assigned to season 1. Whenrec_lag = 0andspawn_seas > 1, must be zero for every season beforespawn_seas– an error is raised otherwise.- do_rec_bias_ramp
Integer (0/1). Whether a recruitment bias ramp is applied to
ln_RecDevsto account for reduced information in early and terminal years. Default0.- bias_year
Numeric. Calendar year at which the bias ramp reaches its maximum correction. Only used when
do_rec_bias_ramp = 1. DefaultNA.- max_bias_ramp_fct
Numeric in \([0, 1]\). Maximum bias correction factor applied at
bias_year. Default1.- sigmaR_switch
Integer. Year index at which \(\sigma_R\) switches from the early-period value (index 1) to the late-period value (index 2). If \(\leq 1\), a single \(\sigma_R\) is applied throughout. Default
1.- dont_est_recdev_last
Non-negative integer. Number of terminal years for which recruitment deviations are not estimated. Automatically overridden to
0ifn_proj_yrs_devs > 0, since projected deviation years are penalised toward the mean and are effectively estimated regardless. Default0.- init_age_strc
Equilibrium initialisation method. Default
2.0/"iterative"Iterates the population to approximate equilibrium. Slowest but most general.
1/"scalar_no_move"Scalar geometric series assuming no movement.
2/"matrix"Matrix geometric series incorporating movement. Recommended default for spatial models.
3/"scalar_plus_only"Scalar geometric series with movement only in the plus group.
- equil_init_age_strc
Plus-group treatment during stochastic initialisation. Default
1.0/"equil"Deterministic equilibrium; no
ln_InitDevsare estimated.1/"stoch_no_plus"Stochastic deviations for all ages except the plus group.
2/"stoch_all"Stochastic deviations for all ages including the plus group.
3/"stoch_shared_ages"Stochastic deviations with user-defined age sharing via
init_age_devs_shared. Deviations are estimated independently across all populations and regions, but ages sharing the same value ininit_age_devs_sharedare constrained to a single parameter. The plus group is not automatically fixed; include anNAininit_age_devs_sharedat the plus-group position to fix it, or share it with the preceding age by repeating that index (e.g.c(1:42, rep(42, 9))). Requiresinit_age_devs_sharedto be non-NULL.
- init_F_prop
Numeric array
[n_regions x n_seas x n_fish_fleets]. Seasonal distribution of fishing mortality applied during equilibrium initialisation by fleet. Default: zero for all seasons and fleets.- sigmaR_spec
Character. Estimation structure for \(\sigma_R\), stored in
ln_sigmaR[2 x n_pop x n_regions], where index 1 = initial deviation period and index 2 = annual deviation period. Default"est_all". Seedo_sigmaR_mappingfor full option descriptions.- InitDevs_spec
Character or
NULL. Sharing structure for initial age-structure deviationsln_InitDevs[n_pop x n_regions x (n_ages - 1)]. DefaultNULL(estimate all independently). Seedo_InitDevs_mappingfor full option descriptions.- RecDevs_spec
Character or
NULL. Sharing structure for annual recruitment deviationsln_RecDevs[n_pop x n_regions x n_years]. DefaultNULL(estimate all independently). Seedo_RecDevs_mappingfor full option descriptions.- h_spec
Character or
NULL. Sharing structure for Beverton-Holt steepnesssteepness_h[n_pop x n_regions], parameterised in bounded logit space \((0.2, 1)\). DefaultNULL(estimate by population whenn_pop > 1, by region whenn_pop = 1). Ignored whenrec_model = "mean_rec". Seedo_h_mappingfor full option descriptions.- sgl_seas_spawning_movement
Spawning movement array
[n_pop x n_regions x n_regions x n_years x n_ages x n_sexes]. Each[p, , r, y, a, s]slice is a row-stochastic movement matrix giving the probability of fish from each origin region spawning in regionr. IfNA(default), 100% natal homing is assumed and the array is constructed internally.- t_spawn
Numeric. Spawn timing as a fraction of the season elapsed before spawning.
0(default) = spawning before any mortality;1= spawning after all mortality.- stray_rate_spec
Character string. Estimation structure for
stray_rate_pars[n_pop x max_stray_blocks], parameterised on the logit scale. Ignored whenuse_fixed_stray_rate = 1orn_pop = 1. Default"fix". Options:"fix"All parameters fixed at starting values (mapped to
NA). Use this alongsideuse_fixed_stray_rate = 0to hold stray rates at a specified value without estimating."est_all"Estimate independently per population x block. Produces one parameter per population per unique block.
"est_shared_pop"Single parameter per block, shared across all populations. Requires identical block structures across all populations – an error is raised if block indices differ.
- stray_rate_blocks
Character vector of length
n_popdefining the temporal block structure for stray rate parameters. Valid formats:"none_Pop_x"Constant stray rate for population
xacross all years (single block)."Block_k_Year_a-b_Pop_x"Block
kapplies to yearsathroughbfor populationx. Use"terminal"in place of the end year to extend through the final model year.
Default: a single constant block for every population. Note: stray rate is generally unidentifiable from fisheries data alone. Time-blocking is provided for completeness but regularisation via
use_stray_rate_priorin the penalty setup is strongly recommended wheneverstray_rate_spec != "fix".- use_fixed_stray_rate
Integer (0/1). Whether stray rates are supplied as a fixed external array (
fixed_stray_rate) rather than estimated as model parameters. Default1(fixed), preserving existing behaviour. Set to0to estimate stray rates viastray_rate_pars.- fixed_stray_rate
Array
[n_pop x n_years]. Fixed stray rate values used whenuse_fixed_stray_rate = 1. Values should be in \([0, 1]\). Default:0(no straying) for all populations and years. Ignored whenuse_fixed_stray_rate = 0.- use_stray_rate_prior
Integer (0/1). Whether Beta priors are applied to estimated stray rate parameters. Only relevant when
use_fixed_stray_rate = 0andn_pop > 1. An error is raised ifuse_stray_rate_prior = 1alongsideuse_fixed_stray_rate = 1sincestray_rate_parswould not be estimated. Default0.- stray_rate_prior
Data frame of Beta prior parameters for stray rates. Required columns:
pop(population index),block(block index matchingstray_rate_blocks),mu(prior mean, in \((0,1)\)),sd(prior standard deviation). One row per population x block combination to penalise. Ignored whenuse_stray_rate_prior = 0. DefaultNULL.- spawn_seas
Integer. Season index in which spawning occurs. Default
1.- sexratio_spec
Character. Estimation structure for sex ratio parameters
sexratio_pars[n_pop x n_regions x n_blocks]. Default"fix". Seedo_sexratio_pars_mappingfor full option descriptions. Must be"fix"whenn_sexes = 1.- sexratio_blocks
Character vector defining temporal block structure for sex ratio parameters. One entry per population-region combination. Valid formats:
"none_Pop_x_Region_x"Constant sex ratio for population
xand regionx(single block across all years)."Block_k_Year_a-b_Pop_x_Region_x"Block
kapplies to yearsathroughb. Use"terminal"in place of the end year to extend through the final model year.
Default: a single constant block for every population-region combination.
- use_rinit
Integer (0/1). Whether a separate initial recruitment scalar
ln_rinitis used to initialise the population independently of the recruitmentln_global_R0. When0(default),ln_rinitis fixed andln_global_R0governs both initialisation and recruitment. When1, bothln_rinitandln_global_R0are estimated, withln_rinitused exclusively for equilibrium initialisation andln_global_R0used for the stock-recruit relationship.Integer vector of length
n_ages - 1specifying an explicit parameter-sharing structure forln_InitDevsalong the age dimension. Each element gives the factor level assigned to that age position; positions sharing the same integer value are constrained to a single estimated parameter. Used in conjunction withequil_init_age_strc = 3("stoch_shared_ages"), which activates user-defined age sharing while still estimating deviations independently across populations and regions. The sharing structure is also respected byInitDevs_specoptions:"est_shared_r"applies the vector per population (with a population-level offset so pops remain independent), and"est_shared_pop_r"applies it globally (no offset, all pops and regions share the same parameters). A typical use case is replicating ADMB models where ages beyond the data plus group share the last estimated deviation, e.g.c(1:42, rep(42, 9))for a 52-age model with 43 data ages, giving 42 free parameters. WhenNULL(default), age sharing follows the standard behaviour determined byequil_init_age_strcalone.- use_r0_prior
Integer (0/1). Whether to apply a lognormal prior on R0 for any populations. Default 0.
- r0_prior
Data frame with columns
pop(population index),mu(prior mean on natural scale), andsd(prior SD on log scale). Required whenuse_r0_prior = 1.- ...
Optional named starting values for parameters. Any of:
ln_global_R0[n_pop],ln_rinit[n_pop],rec_region_prop_pars[n_pop x (n_regions - 1)],rec_seas_prop_pars[n_pop x (n_seas - 1)],steepness_h[n_pop x n_regions](bounded logit scale),ln_InitDevs[n_pop x n_regions x (n_ages - 1)],ln_RecDevs[n_pop x n_regions x n_years],ln_sigmaR[2 x n_pop x n_regions],sexratio_pars[n_pop x n_regions x n_blocks]. Unspecified parameters use internal defaults.
Value
The input input_list with all recruitment-related fields
populated in $data and $par, and factor maps constructed
in $map for: rec_region_prop_pars, rec_seas_prop_pars,
ln_sigmaR, ln_InitDevs, ln_RecDevs,
steepness_h, sexratio_pars, and stray_rate_pars. Character-coded inputs
for init_age_strc and equil_init_age_strc are converted to
integer codes before storage.
See also
Other Model Setup:
Setup_Mod_Biologicals(),
Setup_Mod_Catch_and_F(),
Setup_Mod_Dim(),
Setup_Mod_Discard_Comps(),
Setup_Mod_FishIdx_and_Comps(),
Setup_Mod_Fishsel_and_Q(),
Setup_Mod_Movement(),
Setup_Mod_Retsel(),
Setup_Mod_SrvIdx_and_Comps(),
Setup_Mod_Srvsel_and_Q(),
Setup_Mod_Tagging(),
Setup_Mod_Weighting()