Set up the recruitment module and associated processes
Source:R/setup_recruitment.R
Setup_Mod_Rec.RdSets the stock-recruit form and density dependence, steepness and its prior,
\(\sigma_R\), annual and initial deviations, regional and seasonal
apportionment, spawning movement, stray rates, sex ratio, the equilibrium
initialization and the bias ramp. Call after Setup_Mod_Dim and
Setup_Mod_Biologicals.
Usage
Setup_Mod_Rec(
input_list,
rec_model,
rec_dd = "global",
rec_lag = 1,
SR_ref_yr = 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,
dont_pen_recdev_first = 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)),
init_F_form = "prop",
init_F_spec = "fix",
sigmaR_spec = "est_all",
InitDevs_spec = NULL,
InitDevs_sex_spec = "est_shared_s",
RecDevs_spec = NULL,
RecDevs_model = "iid",
RecDevs_rho_spec = "fix",
RecDevs_rw_init_sigma = 5,
RecDevs_pen_center = "fixed",
Use_rec_level_pen = 0,
rec_level_pen_sigma = 1,
rec_level_pen_center = "own_mean",
rec_level_pen_yrs = NULL,
Use_init_sex_pen = 0,
init_sex_pen_sigma = 1,
sr_penalty = "none",
sr_pen_sigma = 1,
sr_pen_yrs = NULL,
sr_R0_spec = "shared",
InitDevs_pen_center = "fixed",
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,
R0_blocks = NULL,
R0_ref_block = 1,
use_r0_prior = 0,
r0_prior = NULL,
Use_rinit_pen = 0,
rinit_pen_sd = 1,
...,
ln_global_R0_spec = "est"
)Arguments
- input_list
Named list with
$data,$par,$mapand$verbose. Dimensions must already be set in$data.- rec_model
Character, required.
"mean_rec"(steepness fixed and not estimated),"bh_rec", or"ricker_rec". Steepness is not interchangeable between the last two, seeGet_Det_Recruitment.- rec_dd
Density dependence.
"local"is one stock-recruit relationship per population, required whenn_pop > 1."global"(default) pools across regions and restrictsh_spec,RecDevs_specandInitDevs_specto shared or fixed options whenn_regions > 1.- rec_lag
Integer lag in seasons between spawning biomass and recruitment.
1(default) uses SSB from that many seasons prior.0is age-0 recruitment on the same year's SSB, so recruits may only enter inspawn_seasor later.- SR_ref_yr
Integer year index supplying every input to unfished spawning biomass per recruit, and so to
S0and the curve's scale: weight-at-age, maturity, natural mortality, movement, stray rate, sex ratio, and what enters throughinit_F.R0is the exception and is always the year's own value. Default1. Ignored underrec_model = "mean_rec".- Use_h_prior
Integer (0/1). Normal priors on steepness. Default
0.- h_prior
Data frame with columns
pop,region,muandsd. DefaultNULL.- rec_region_prop_spec
Character or
NULL. Regional recruitment dispersal structure, defaultNULL(all estimated freely). Stored as$data$rec_region_prop_spec,0= full dispersal,1= none. Seedo_rec_region_prop_mapping.- use_rec_region_prop_prior
Integer (0/1). Dirichlet priors on regional recruitment proportions. Not valid when
n_regions = 1. Default0.- rec_region_prop_prior
Data frame of Dirichlet concentrations with columns
popandalpha, a list-column of length-n_regionsvectors. DefaultNULL.- rec_seas_prop_spec
Character or
NULL. Seasonal apportionment structure, default"fix". Seedo_rec_seas_prop_mapping.- use_rec_seas_prop_prior
Integer (0/1). Dirichlet priors on seasonal proportions. Not valid when
n_seas = 1. Evaluated only overspawn_seas:n_seaswhenrec_lag = 0andspawn_seas > 1. Default0.- rec_seas_prop_prior
Data frame of Dirichlet concentrations with columns
popandalpha. DefaultNULL.- use_fixed_rec_seas_prop
Integer (0/1). Whether
fixed_rec_seas_propis used. Reset to0with a warning ifrec_seas_prop_specestimates. Default1.- fixed_rec_seas_prop
Array
[n_pop x n_seas]of fixed seasonal proportions, default all recruitment in season 1. Must be zero beforespawn_seaswhenrec_lag = 0andspawn_seas > 1.- do_rec_bias_ramp
Integer (0/1). Whether a bias ramp is applied to
ln_RecDevs. Under0every penalty is centered on the full \(-\sigma_R^2/2\), under1the center follows the ramp. Default0.- bias_year
Numeric calendar year at which the ramp reaches its maximum correction. Default
NA.- max_bias_ramp_fct
Numeric in \([0, 1]\), the maximum correction applied at
bias_year. Default1.- sigmaR_switch
Integer year index at which \(\sigma_R\) switches from the early to the late value. \(\leq 1\) (default) uses one value throughout.
- dont_est_recdev_last
Non-negative integer. Terminal years for which recruitment deviations are not estimated. Forced to
0whenn_proj_yrs_devs > 0, refused underRecDevs_model = "dsem". Default0.- dont_pen_recdev_first
Integer. How many leading years of recruitment deviations are estimated but left out of the penalty.
0(default) penalizes every year.- init_age_strc
Initialization method, default
2.0/"iterative"iterates to approximate equilibrium,1/"scalar_no_move"is a scalar geometric series without movement,2/"matrix"is the matrix series with movement, and3/"scalar_plus_only"moves only the plus group; all four treatln_InitDevsas multiplicative deviations from the equilibrium.4/"free"projects no equilibrium: ages 2 and older areexp(ln_InitDevs)apportioned by sex ratio, so the deviations are on the scale of numbers andequil_init_age_strcbecomes a prior on log abundance.- equil_init_age_strc
Plus-group treatment during stochastic initialization, default
1.0/"equil"estimates noln_InitDevs,1/"stoch_no_plus"estimates every age but the plus group,2/"stoch_all"estimates every age,3/"stoch_shared_ages"shares ages throughinit_age_devs_shared(non-NULLrequired; the plus group is not fixed automatically), and4/"stoch_all_no_pen"estimates every age and penalizes none, for pairing withinit_age_strc = "free".- init_F_prop
Numeric array
[n_regions x n_seas x n_fish_fleets]. Legacy interface. A non-zero value withoutinit_F_paris converted toinit_F_par = qlogis(init_F_prop)withinit_F_form = "prop", so each value must be below one. Preferinit_F_par. Default zero.- init_F_form
What
init_F_parmeans."prop"(default) givesinit_F = plogis(init_F_par) * exp(ln_F_mean), a proportion of the estimated mean F bounded to \((0, 1)\)."abs"givesinit_F = exp(init_F_par), independent ofln_F_mean. Use"abs"when bridging an assessment with a separate historical F; under"prop"the two collapse into one parameter and catch constrains only their product.- init_F_spec
"fix"(default) or"est", whetherinit_F_paris estimated. Sets only the mapping, so it combines freely withinit_F_form. Refused underinit_age_strc = "free". The value comes frominit_F_par[n_regions x n_seas x n_fish_fleets], passed through..., on the logit scale under"prop"and the log scale under"abs".- sigmaR_spec
Character. Estimation structure for \(\sigma_R\), stored in
ln_sigmaR[2 x n_pop x n_regions]with index 1 the initial period and 2 the annual period. Default"est_all", seedo_sigmaR_mapping.- InitDevs_spec
Character or
NULL. Sharing structure forln_InitDevs[n_pop x n_regions x (n_ages - 1) x n_sexes]. DefaultNULL(all independent), seedo_InitDevs_mapping.- InitDevs_sex_spec
"est_shared_s"(default) estimates one initial age deviation curve read by every sex;"est_all"gives each sex its own, pooling the level across sexes under an"own_mean"InitDevs_pen_center. Requiresn_sexes > 1.- RecDevs_spec
Character or
NULL. Sharing structure forln_RecDevs[n_pop x n_regions x n_years]. DefaultNULL(all independent), seedo_RecDevs_mapping.- RecDevs_model
Process error on
ln_RecDevs."iid"(default) is independent about the prior mean,"rw"centers each deviation on the previous one with a diffuse first year,"ar1"reverts toward zero at rateRecDevs_rhowith a stationary first year, and"dsem"takes the density from the arrows inSetup_Mod_DSEM. Steps span estimated years, not calendar years."rw"and"ar1"are refused alongsidedo_rec_bias_ramp = 1orRecDevs_pen_center = "own_mean";"dsem"readssigmaRoff the arrows, sosigmaR_specother than"fix",dont_est_recdev_last > 0and a nonzero ramp are refused.- RecDevs_rho_spec
Sharing structure for
RecDevs_rho[n_pop x n_regions]:"est_all","est_shared_pop","est_shared_r","est_shared_pop_r"or"fix"(default). Only read underRecDevs_model = "ar1", seedo_RecDevs_rho_mapping.- RecDevs_rw_init_sigma
Standard deviation given to year one of a random walk, which sets the level of the series. Default
5;NAinstead starts the walk at zero under its own sigma. Only read underRecDevs_model = "rw".- RecDevs_pen_center, InitDevs_pen_center
Where the recruitment and initial age deviation penalties are centered.
"fixed"(default) centers on zero or the bias-corrected \(-\sigma_R^2/2\);"own_mean"centers on the estimated deviations' own mean, leaving their level free to be set elsewhere. Cannot be combined withdo_rec_bias_ramp = 1.- Use_rec_level_pen
Integer (0/1). Whether the log recruitment series itself is penalized, separately from the deviation penalty. Default
0.- rec_level_pen_sigma
Numeric standard deviation of that penalty. A sum of squares with weight \(w\) corresponds to \(1/\sqrt{2w}\). Default
1.- rec_level_pen_center
"own_mean"(default) centers on the mean of the log recruitment series,"fixed"centers on zero.- rec_level_pen_yrs
Years the penalty applies over, or
NULL(default) for every year.- Use_init_sex_pen
Integer (0/1). Whether each later sex's initial age deviations are tied to the first sex's by a Gaussian on their difference. Requires
n_sexes > 1andInitDevs_sex_spec = "est_all". Enters the objective unweighted. Default0.- init_sex_pen_sigma
Numeric standard deviation of that tie. Default
1.- sr_penalty
Character.
"none"(default),"bh"or"ricker". Only valid underrec_model = "mean_rec". Fits the curve as a likelihood on \(\log R_y - \log\widehat{R}_y\) without letting it generate recruitment.- sr_pen_sigma
Numeric standard deviation of that residual.
- sr_pen_yrs
Years the stock-recruit penalty applies over, or
NULL(default) for every year with a lagged spawning biomass. Naming a year without one is an error.- sr_R0_spec
Character.
"shared"(default) takes the curve's scale fromln_global_R0,"est"gives it its ownln_sr_R0, and"rinit"takes it fromln_rinitand requiresuse_rinit = 1.- h_spec
Character or
NULL. Sharing structure forsteepness_h[n_pop x n_regions], on a logit scale bounded to \((0.2, 1)\). DefaultNULL, ignored underrec_model = "mean_rec". Seedo_h_mapping.- sgl_seas_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 row-stochastic.NA(default) assumes complete natal homing and builds the array internally.- t_spawn
Numeric fraction of the spawning season elapsed before spawning.
0(default) spawns before any mortality,1after all of it.- stray_rate_spec
Estimation structure for
stray_rate_pars[n_pop x max_stray_blocks]on the logit scale."fix"(default) holds every value,"est_all"estimates per population and block, and"est_shared_pop"gives one parameter per block shared across populations, which requires identical block structures. Ignored whenuse_fixed_stray_rate = 1orn_pop = 1.- stray_rate_blocks
Character vector of length
n_pop, either"none_Pop_x"for one block or"Block_k_Year_a-b_Pop_x", with"terminal"allowed as the end year. Default one block each. Stray rate is generally unidentifiable from fisheries data alone, so useuse_stray_rate_priorwheneverstray_rate_spec != "fix".- use_fixed_stray_rate
Integer (0/1). Whether stray rates come from
fixed_stray_raterather than being estimated. Default1.- fixed_stray_rate
Array
[n_pop x n_years]of stray rates in \([0, 1]\). Default0.- use_stray_rate_prior
Integer (0/1). Beta priors on estimated stray rates. Only relevant when
use_fixed_stray_rate = 0andn_pop > 1; an error is raised alongsideuse_fixed_stray_rate = 1. Default0.- stray_rate_prior
Data frame with columns
pop,block,muin \((0,1)\) andsd, one row per population and block. DefaultNULL.- spawn_seas
Integer season index in which spawning occurs. Default
1.- sexratio_spec
Estimation structure for
sexratio_pars[n_pop x n_regions x n_blocks]. Default"fix", which is required whenn_sexes = 1. Seedo_sexratio_pars_mapping.- sexratio_blocks
Character vector, one entry per population and region, either
"none_Pop_x_Region_x"or"Block_k_Year_a-b_Pop_x_Region_x", with"terminal"allowed as the end year. Default one block each.- use_rinit
Integer (0/1). Whether
ln_rinitinitializes the population separately fromln_global_R0. Under0(default)ln_rinitis fixed andln_global_R0does both jobs.Integer vector of length
n_ages - 1giving the factor level of each age position forln_InitDevs; positions sharing a value share one parameter. Read underequil_init_age_strc = 3, and also respected byInitDevs_spec = "est_shared_r"(applied per population, with a population offset) and"est_shared_pop_r"(applied globally, no offset).c(1:42, rep(42, 9))gives 42 free parameters for a 52-age model with 43 data ages. DefaultNULL.- R0_blocks
Character vector of time blocks for
R0, one per population, in the selectivity block vocabulary:"none_Pop_<p>"or"Block_<b>_Year_<a>-<e>_Pop_<p>"on 1-based year indices, with"terminal"allowed. Under"mean_rec"a block is a productivity regime; under a stock-recruit form it makes the curve time-varying, soS0, depletion and any reference point step at the boundary. DefaultNULL.- R0_ref_block
Integer, the block whose
R0is used wherever a single value is needed: the initial age structure, the regional apportionment, theR0prior, theln_rinitpenalty, and the stock-recruit scale undersr_R0_spec = "shared". Default 1.- use_r0_prior
Integer (0/1). Lognormal prior on
R0. Default 0.- r0_prior
Data frame with columns
pop,muon the natural scale andsdon the log scale. Required whenuse_r0_prior = 1.- Use_rinit_pen
Integer (0/1). Whether \(\log(R_{init} / R_0)\) is penalized under
use_rinit = 1. An equilibrium recruitment stands for an average of several years, so \(\sigma_R / (1 / M - 0.5)\) is a reasonable sd. Default 0.- rinit_pen_sd
Standard deviation of that penalty, log scale. Default 1.
- ...
Optional named starting values:
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]on the bounded logit scale,ln_InitDevs[n_pop x n_regions x (n_ages - 1) x n_sexes](a 3-D array is expanded across sexes),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].- ln_global_R0_spec
"est"(default) or"fix"."fix"mapsln_global_R0off at its starting value, so the deviations hold log recruitment outright. Underrec_model = "mean_rec"a random walk withdont_pen_recdev_first >= 1leaves the level unidentified and is refused; a walk with the first year still penalized is accepted with a warning.
Value
input_list with recruitment fields set in $data and
$par, and maps built in $map for rec_region_prop_pars,
rec_seas_prop_pars, ln_sigmaR, ln_InitDevs,
ln_RecDevs, RecDevs_rho, steepness_h, sexratio_pars
and stray_rate_pars. Character codes for init_age_strc and
equil_init_age_strc are converted to integers 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()