0. Model options and functionality
Grant Adams
Source:vignettes/model-options-and-functionality.Rmd
model-options-and-functionality.RmdThis is the menu of options you choose between when configuring a
data_list and the arguments to fit_mod().
Vignette 1, Rceattle: An Introduction,
fits a model end to end; vignette 8, Model parameterizations, is the
equation-level reference (in progress); and vignettes 2-7 cover HCRs and
MSEs, diagnostics, projections and reference points, single-
vs. multi-species models, building a data object in R, and Stock
Synthesis migration.
1. Model dimensions and operating mode
Equations: see vignette 8 §Population dynamics.
| Switch | Where set | Role |
|---|---|---|
nspp, nages, nsex,
nlengths
|
data_list |
Population structure |
styr, endyr, projyr
|
data_list |
Time horizon (hindcast + projection) |
msmMode |
fit_mod() |
Single- vs. multi-species |
initMode |
fit_mod() |
Initial age structure |
estimateMode |
fit_mod() |
Estimate / project / debug |
random_rec, random_q,
random_sel
|
fit_mod() |
Random-effects toggles |
msmMode, single-species vs. multi-species
| Value | Meaning | Status |
|---|---|---|
0 |
Single-species (M = M1 only) | Validated |
1 |
Multi-species, MSVPA Type II predation | Validated |
2 |
Multi-species, MSVPA Type III predation | Validated |
3:9 |
Kinzey & Punt (2009) functional responses (Holling I/II/III, predator interference, predator preemption, Hassell-Varley, Ecosim) |
Not implemented: fit_mod() rejects
them as invalid msmMode codes |
initMode, initial age structure
Codes (also accept the string aliases listed):
| Value | Alias | Description |
|---|---|---|
0 |
"FreeParams" |
Initial N-at-age estimated as free parameters, started at the unfished equilibrium of R0 and female M1 (at log numbers 0, i.e. 1 thousand fish per age, under a single-species stock-recruit curve) |
1 |
"Equilibrium" |
Unfished equilibrium, no init devs, Finit = 0 |
2 (default) |
"NonEquilibrium" |
Unfished equilibrium with initial deviations |
3 |
"FishedNonEquilibrium" |
Fished non-equilibrium with init devs; Finit is added to M inside geometric series |
4 |
"FishedNonEquilibriumScaled" |
Fished non-equilibrium with init devs and R0-scaled by Finit |
5 |
"OffsetEquilibrium" |
Unfished equilibrium, Finit = 0, displaced by the year-1 recruitment deviation instead of sitting at Rinit; init devs off, no init-dev penalty (Cole Monnahan / AFSC GOA pollock convention) |
6 |
"FishedNonEquilibriumSelected" |
As 3, but Finit is weighted by the fishery’s
selectivity at age before it accumulates, so the first year decays with
∑(M1 + Finit sa). Stock Synthesis’s InitF
convention; Finit is the apical initial F. Use this where the
fishery is size-selective, since 3 charges unselected young
ages the full Finit and 4 applies it once |
Finit is one per species (SS3 carries one per fleet), so
under mode 6 a species with more than one fishery decays
its initial age structure at the mean selectivity of
those fisheries, Finit is the apical initial F of none of
them, and data_check() warns.
The initial equilibrium catch
Modes 3, 4 and 6 estimate
Finit, but nothing identifies it without an observation: the
catch taken under it in the year before the hindcast. Enter it as an
ordinary catch_data row at styr - 1, with the
fleet’s Catch and Log_sd. It is read
only under mode 6, the one mode that builds the
initial age structure with the mortality the prediction uses (Baranov at
Finit × selectivity); under any other mode the row is
dropped, and data_check() says so.
That year also holds ordinary catch history, so
data_check() names the fleets whose rows it reads. It
refuses two rows for one fleet, a non-positive catch or
Log_sd, a fleet that is not an active fishery, and a
species with more than one fishery. clean_data() moves the
row into data_list$equil_catch_data, and
write_data() writes it back into the catch sheet. The
prediction is quantities$equil_catch_hat, scored on the
jnll_comp row "Initial equilibrium catch".
estimateMode, what does fit_mod() actually
do?
| Value | Behavior |
|---|---|
0 |
Estimate hindcast and projection parameters via nlminb
/ TMB::sdreport (default). |
1 |
Estimate only the hindcast parameters via nlminb /
TMB::sdreport. |
2 |
Hold the hindcast fixed and run only the projection under the
supplied HCR. |
3 |
Evaluate the report once at inits (debug / mapping
check). |
4 |
Run through MakeADFun and nlminb with all
parameters mapped out (debug / mapping check). |
2. Predation: suitMode (per predator)
Equations: see vignette 8 §Predation sub-model (suitability, predation mortality, consumption / bioenergetics).
suitMode sets how prey preference is modelled; length 1
(all predators) or nspp.
| Value | String | Description | Available? |
|---|---|---|---|
0 |
"Empirical" |
Empirical proportions from observed stomach data (MSVPA-style; Holsman et al. 2016) | Yes |
1 |
"GammaLength" |
Gamma suitability on prey length-at-age | Not yet |
2 |
"GammaWeight" |
Gamma suitability on prey weight-at-age | Yes |
3 |
"LognormalLength" |
Log-normal suitability on prey length-at-age | Not yet |
4 |
"LognormalWeight" |
Log-normal suitability on prey weight-at-age | Yes |
5 |
"NormalLength" |
Normal suitability on prey length-at-age | Not yet |
6 |
"NormalWeight" |
Normal suitability on prey weight-at-age | Yes |
Where year-specific diet data are not supplied (Year = 0
in diet_data), suitability is averaged across
suit_styr:suit_endyr, the full hindcast by default.
A predicted diet needs estimated suitability
and a predation model: suitMode 2, 4 or 6
with msmMode > 0. Under suitMode = 0
suitability is read from diet_data, and under
msmMode = 0 no predation is computed, so neither has a
fitted diet; residuals(source = "diet"),
plot_diet_comp(), plot_diet_comp1() and
plot_diet_comp2() refuse on such a fit.
3. Selectivity (per fleet)
Equations: see vignette 8 §Selectivity parameterizations.
Set the Selectivity column of
fleet_control; integers and strings both work:
| Value | String | Notes |
|---|---|---|
0 |
"Fixed" |
Selectivity supplied via the emp_sel data sheet |
1 |
"Logistic" |
Two-parameter ascending logistic |
2 |
"NonParametric" |
Age- or length-bin-indexed; penalties via
Sel_curve_pen1 / Sel_curve_pen2
|
3 |
"DoubleLogistic" |
Dome-shaped (ascending + descending logistic) |
4 |
"DescendingLogistic" |
Descending only |
5 |
"Hake" |
Non-parametric à la Taylor et al. (2015; Pacific hake) |
6 |
"2DAR1" |
2D AR(1) bin × year (deviations as in Xu et al. 2019, around a non-parametric base) |
7 |
"3DAR1" |
3D AR(1) bin × year × cohort (the weight-at-age Gaussian Markov random field, GMRF, of Cheng et al. 2023, applied to selectivity) |
8 |
"DoubleNormal" |
Four-parameter double normal: peak, ascending and descending widths, and a right-tail floor (the Stock Synthesis pattern 24 shape without its initial-selectivity and plateau-width parameters) |
9 |
"NonParametricPM" |
Ianelli non-parametric with the ADMB AMAK (“pm”) penalty; see
Sel_avgsel_pen, Sel_cap_bin
|
11 |
"LogisticPM" |
AMAK (“pm”) logistic: multiplicative inflection/slope deviations plus a free age-1 log-selectivity |
13 |
"NonParametricIntegrable" |
The NonParametric base curve whose deviations have a
proper density: the shape penalties are charged once on the base, so
random_sel = TRUE integrates them |
15 |
"DoubleNormalSS3" |
Stock Synthesis size pattern 24 (Methot and Wetzel 2013): the
six-parameter double normal, each parameter on SS3’s own scale (peak;
logit top width; log ascending and descending widths; logit initial and
final selectivity) in its own array sel_dn6. An end left at
SS3’s -999 is unscaled and fixed. Not normalized, as in SS3. All six
take selectivity linkages under the SS3 manual’s names;
Time_varying_sel must be "Off"
|
Codes 10, 12 and 14 are
unused.
The AR(1) forms reuse the Sel_curve_pen columns as
logit-scale correlations, one per dimension: Sel_curve_pen1
across selectivity bins (ages or length bins, per
Selectivity_dimension), Sel_curve_pen2 across
years, and Sel_curve_pen3 across
cohorts for 3DAR1.
Time-varying behavior is set by Time_varying_sel (per
fleet):
| Value | String | Behavior |
|---|---|---|
0 |
"Off" |
Time-invariant |
1 |
"IID" |
Independent annual deviations |
2 |
"AR1" |
Removed in 5.16.0: data_check() errors
on it. Set "IID" for the same fit, or see the replacement
below. |
3 |
"Block" |
Time block |
4 |
"RandomWalk" |
Random walk |
5 |
"RandomWalkAscending" |
Random walk on ascending portion of double logistic |
Not every mode applies to every selectivity form:
| Selectivity | Modes accepted |
|---|---|
Logistic, DoubleLogistic,
DescendingLogistic, DoubleNormal
|
Off, IID, Block,
RandomWalk; RandomWalkAscending on
DoubleLogistic only. On another form, link its ascending
parameters instead (peak / sigma_asc for
DoubleNormal, inf_asc / slp_asc
for the logistic family) with ~ rw(1 \| Year)
|
NonParametric |
Off, IID, RandomWalk
|
NonParametricPM |
Off, RandomWalk: its deviates are
the walk increments, so IID would describe a different
curve than the model builds |
NonParametricIntegrable |
Off, IID, RandomWalk;
Off estimates no deviations |
Hake |
Off, IID
|
2DAR1, 3DAR1
|
none; the field’s correlations come from Sel_curve_pen,
and its conditional sd from Time_varying_sel_sd, which they
always need |
The two non-parametric modes differ in what they are a deviation
of, and fit_mod() refuses
random_sel = TRUE on both:
-
"IID"scores each annual coefficient deviation about an estimated base curve. The density is proper, but the AMAK shape penalties (Sel_curve_pen1,Sel_curve_pen2) and the always-on average-selectivity term are charged on each year’s realized curve, and none scales withTime_varying_sel_sd, so the estimated sd is biased low whatever the penalty weights. -
"RandomWalk"scores the year-to-year change in the realized selectivity, which is renormalized to mean 1 within each year. Its density says nothing about the level of a year’s coefficients, so those directions are improper and the deviation standard deviation collapses to zero.
Fit them with random_sel = FALSE, the penalized
formulation the AMAK model intends, or use
NonParametricIntegrable (code 13 above) with
random_sel = TRUE.
Even under NonParametricIntegrable, the Laplace
approximation underestimates the deviation SD on small multinomial
samples (a true 0.35 came back at 0.24 to 0.26 on
Atka2022’s fishery), so read it as a lower bound unless the
compositions are well sampled.
Time_varying_sel is soft-deprecated as a
whole, and data_check() says so on use. The
linkage grammar expresses the same IID, random-walk and AR(1) deviations
((1 | Year), rw(1 | Year),
ar1(1 | Year)) and time
blocks (~ cut(Year, ...)) per selectivity
parameter rather than per fleet, and lets the deviation
standard deviation be estimated, given a prior, or held fixed:
build_selectivity(linkages = list(
inf_asc = linkage_spec(~ ar1(1 | Year), by = ~ fleet)))Name whichever parameter should vary: slp_asc,
inf_asc, slp_desc, inf_desc, or a
DoubleNormal alias. apical, the height of one
sex’s curve relative to the other’s, is available on every estimated
form except 2DAR1 and 3DAR1, on a two-sex
species; see Environmental
linkages and priors.
Bin indexing: with non-parametric and AR(1) forms, selectivity is
indexed over N_sel_bins.
Sel_norm_bin says where selectivity is normalized to 1.
Set it to "Max" to normalize by the largest value
(non-differentiable), to "Off" to leave the curve
unnormalized, or to a bin to normalize there. Give
Sel_norm_bin_upper as well and the reference is mean
selectivity over that range instead.
A numeric Sel_norm_bin is read on the fleet’s own
Selectivity_dimension: an absolute age for
an age-based fleet (6 means age 6, not the sixth bin) or a
1-based length-bin ordinal for a length-based one,
matching Age_first_selected and
Bin_first_selected respectively. Because the curve is
zeroed below the first selected bin, a value below it is read as
"Max" ("All" on a "LogisticPM"
fleet): legacy -1 and -999, and 0
unless the fleet is age-based and selects age 0. Blank is
"Off".
Sharing a selectivity between fleets
Fleets given the same Selectivity_index share one
selectivity parameter block, and its penalties and priors are
accumulated once, on the group’s first non-Off fleet. The
columns that shape the curve are still read per fleet,
so they have to agree across the group or the fleets end up with
different selectivities:
| Column | If it differs within the group |
|---|---|
Selectivity, Selectivity_dimension,
Age_first_selected, Bin_first_selected,
N_sel_bins, Sel_norm_bin,
Sel_norm_bin_upper, Sel_norm_scope,
Sel_cap_bin
|
The fleets get different curves: mirroring fails |
Time_varying_sel |
Resolved to the lead fleet’s setting |
Sel_start_year |
Resolved to the group’s earliest year |
Time_varying_sel_sd |
Honoured per fleet while it is fixed. Under
random_sel = TRUE the group estimates one deviation sd,
starting at the geometric mean of its estimated members’
values, so no fleet keeps its own. build_map() warns |
A blank counts as a value in the first row: an unset
Sel_norm_bin (written back as "Off") means “do
not normalize”, which is a different curve from normalizing at a bin.
data_check() warns in all three cases, distinguishing
divergence from resolution.
The reliable way to mirror a fleet is to copy its
fleet_control row and change only the identity and
catchability columns:
Sex structure and relative selectivity
Every selectivity form is sex-specific by default
when a species has two sexes (nsex): each sex gets its own
free copy of every selectivity parameter.
Two independent normalization columns decide whether the sexes keep a relative scale or differ only in shape:
-
Sel_norm_bin, where the reference is taken, as above. -
Sel_norm_scope, whose scale it sets."AcrossSexes"(default) pools one reference over the sexes, so the less-selected sex stays below 1 and relative sex-specific selectivity is retained."WithinSex"divides each sex by its own reference, so both reach 1 and only the shape differs by sex.
Sel_norm_bin |
Sel_norm_scope |
Result |
|---|---|---|
"Off" |
(any) | nothing normalized; the relative scale is free |
"Max" |
"AcrossSexes" |
maximum over bins and sexes: one sex peaks at 1, the other keeps whatever relative level its form gives it |
"Max" |
"WithinSex" |
each sex scaled at its own plateau, wherever that falls |
| a bin | "AcrossSexes" |
anchored at that bin, sexes kept comparable |
| a bin | "WithinSex" |
both sexes forced to 1 at that bin; only the shape differs |
For strongly dimorphic stocks the relative sex selectivity is usually
the quantity of interest, so keep the "AcrossSexes"
default. Where the sexes plateau at different ages and each should be
scaled at its own plateau, use Sel_norm_bin = "Max" with
Sel_norm_scope = "WithinSex" rather than a named bin, which
stops being the plateau once selectivity is time-varying.
Sel_norm_scope has no effect on a one-sex species, or
where Sel_norm_bin is "Off".
Which forms can hold a sex difference in level
"AcrossSexes" normalization preserves a level
ratio and cannot create one, so whether the sexes can reach different
levels at all is a property of the form.
("WithinSex" at a named bin divides each sex by its own
value there, so two sexes whose curves differ in shape end on different
plateaus.)
| Form | Sex difference in level, from the form alone |
|---|---|
Logistic, DescendingLogistic,
LogisticPM
|
none: the curve tends to 1 for either sex, whatever its parameters |
NonParametric, NonParametricPM,
NonParametricIntegrable
|
none: each sex is re-centred so its own mean selectivity-at-age is exactly 1, every year |
Hake |
none: normalizes within sex by its own maximum;
Sel_norm_scope is not read (nor by LogisticPM,
which is not normalized at all) |
DoubleNormal |
old-age plateau only: the right-tail floor is sex-specific, but both sexes peak at exactly 1 |
DoubleLogistic, 2DAR1,
3DAR1
|
free: the height is a free function of that sex’s own parameters |
Every row above describes the form on its own. An apical
selectivity linkage adds a per-sex height multiplier to any estimated
form but 2DAR1/3DAR1, applied after the form’s
own centring and before Sel_norm_bin normalization (so
Sel_norm_scope must be "AcrossSexes", or
Sel_norm_bin "Off"), so a “none” here means
the shape cannot hold the difference, not that the model cannot.
data_check() notes the unread Sel_norm_scope
on a two-sex Hake or LogisticPM fleet left on
the default "AcrossSexes"; LogisticPM reuses
Sel_norm_bin as a penalty bin range.
On a two-sex Logistic fleet an apical
linkage gives five parameters: slope and inflection per sex, plus one
height multiplier on the sex named. Only the joint-sex rows
(Sex = 3) inform that height. Unlike a Stock Synthesis male
offset, usually an offset from the female shape, both shapes
stay free; sharing a shape across the sexes needs a hand-edited
map that points one sex’s cells at the other’s.
The composition data must be joint.
comp_data$Sex = 3 stacks female and male composition into a
single vector that is normalized to sum to 1 as a whole (as Stock
Synthesis does), so the sex ratio is fit and the relative selectivity is
informed. Sex = 1 or 2 put each sex in its own
row, each summing to 1 independently: those hold no
sex-ratio information, and Sel_norm_bin then makes no
difference however it is set. There is no separate sex-ratio likelihood
component.
The sex ratio at recruitment is fixed input, not
estimated, from the sex_ratio sheet at the first modelled
age. Sex-specific natural mortality is
build_M1(M1_model = ) (§7) and sex-specific growth is
build_growth() (§8); the linkage grammar’s per-sex hooks
are linkage_spec(by = ~ sex) and its sex =
filter. The fleet_control Sex column is
inert, kept only so older workbooks still read; sex is
set per observation on comp_data.
4. Catchability (per fleet)
Equations: see vignette 8 §Catchability parameterizations.
Set the Catchability column of
fleet_control:
| Value | String | Description |
|---|---|---|
0 |
"Fixed" |
q supplied directly |
1 |
"Estimated" |
q estimated as a free parameter |
2 |
"Estimated-with-prior" |
Estimated with a lognormal prior on q: mean
Catchability_init (median when
bias_adjust_proc = FALSE), log-scale SD
Catchability_prior_sd
|
3 |
"Analytical" |
The closed-form maximum likelihood q for the fleet’s
Index_distribution (concentrated likelihood). Refused under
TruncatedNormal, which has no closed-form q |
4 |
"PowerEquation" |
Power-function catchability (q · Bα). Not
implemented: data_check() rejects it. |
5 |
"Environmental" |
q linked to an environmental index. Deprecated in
4.9.0: express it as a covariate linkage instead,
build_catchability(linkages = list(q = linkage_spec(~ temp, by = ~ fleet))).
The series is named by Time_varying_q, not
Catchability_index. |
6 |
"AR1" |
Removed in 5.12.0: data_check() errors
on it. Its deviates were never estimated, so q came back constant.
Express the Rogers et al. (2024) form as a q linkage instead, see
below. |
7 |
"AnalyticalArith" |
q solved from the fleet’s own index observations using the AMAK
arithmetic-mean estimator; pair with
Index_distribution = "MVN" for a supplied covariance |
Index likelihood (Index_distribution)
How an index observation is scored, per fleet. The choice also sets how residuals and plot intervals are computed.
| Value | String | Scale | Description |
|---|---|---|---|
0 |
"Lognormal" |
log | Independent lognormal on log(obs). The default.
Log_sd is a log-scale CV. |
1 |
"MVN" |
natural | The AMAK/ebswp DoCovBTS = 1 bare quadratic
form 0.5 · r' Σ⁻¹ r on the residual
obs − q·pred. Drops the normalizing constant, so the
reported value matches ADMB. Needs index_cov. |
2 |
"MVNORM" |
natural | The full multivariate-normal negative log-density. Identical fit to
"MVN" (the extra term is constant), but properly
normalized. Needs index_cov. |
3 |
"Normal" |
natural | Normal on obs − q·pred, with Log_sd read
as an absolute natural-scale sd, not a CV. No lognormal
bias correction. |
4 |
"TruncatedNormal" |
natural | The same normal, left-truncated at zero. An index cannot be
negative, so this is the only natural-scale family whose simulator and
likelihood are the same distribution. Prefer it over
"Normal" unless you need an exact ADMB comparison.
data_check() refuses it with
Catchability = "Analytical". |
Time-varying behavior is set by Time_varying_q (per
fleet):
| Value | String | Behavior |
|---|---|---|
0 |
"Off" |
Time-invariant |
1 |
"IID" |
Independent annual deviations |
2 |
"AR1" |
Removed in 5.16.0: data_check() errors
on it. Set "IID" for the same fit, or see the replacement
below. |
3 |
"Block" |
Time block |
4 |
"RandomWalk" |
Random walk |
Time_varying_q is soft-deprecated as a
whole, as Time_varying_sel is, and
data_check() says so on use; the linkage grammar expresses
the same deviations and time
blocks, with the deviation standard deviation estimated, given a
prior, or held fixed:
build_catchability(linkages = list(
q = linkage_spec(~ ar1(1 | Year), by = ~ fleet)))The removed Catchability = "AR1" (QAR1, Rogers et
al. 2024) is the same formula plus the series the deviations are
observed against, which makes it the state-space form rather
than a free AR(1) on q:
build_catchability(linkages = list(
q = linkage_spec(~ ar1(1 | Year), by = ~ fleet, fleet = <Fleet_code>,
observe = "<that fleet's env_data column>",
obs_sd = <its measurement SD>)))Under Catchability = "Environmental",
Time_varying_q instead names the env_data
series to use: an integer, or a string of them
("1,2,3").
Which fleets get a catchability
Catchability follows the data, not the fleet type. A
fleet is given a q if it holds index_data the model fits, a
fishery with a CPUE series as much as a survey. A fishery’s index is
predicted from that fishery’s own selectivity; an index needing a
different selectivity has to be its own fleet, since
sel_at_age is one block per fleet (the same is true of
Observation_units).
A fleet with no fitted index rows gets no q,
whatever Catchability says, since nothing would inform it;
that includes a composition-only survey. print() marks the
case:
[2] Fishery │ Fishery │ sel: Logistic │ q: Estimated (fixed: no index data)
The exception is sharing. Fleets with the same
Catchability_index share one q parameter, so the
lead fleet (the group’s first non-Off
fleet) decides for all of them whether it is estimated, regardless of
type: a fleet with no index of its own is still estimated if its lead
is, and an "Estimated" fleet is still fixed if its lead is
"Fixed". Give a fleet its own
Catchability_index when it should be estimated
independently. Within a group:
-
"Analytical"/"AnalyticalArith"solve q from each fleet’s own index observations, so a group containing one does not share a catchability, even when every fleet in it holds the same setting. Give those fleets their ownCatchability_index, or use an estimated q for the whole group. -
"Environmental"does share: the whole group follows the lead fleet, including its environmental series where the fleets name different ones inTime_varying_q. -
A
"Fixed"lead estimates and shares nothing: each fleet sits at its ownCatchability_init. -
An estimated q starts at the mean of the group’s
log
Catchability_init, not the lead’s; only the prior centre uses the lead’s.build_map()warns when those inits differ and names the geometric mean: a shared q starting there scales a survey’s whole predicted index by a constant factor, which no residual pattern distinguishes from a real change in abundance. -
Time_varying_q_sd, once estimated (random_q = TRUEwithTime_varying_qof"IID"or"RandomWalk"), is one sd for the group, starting at the geometric mean of its estimated members’ values, andbuild_map()warns when they differ. While fixed, each fleet keeps its own. -
Catchability_prior_sdis read only on the lead, where the prior is scored once.
data_check() warns on the analytical case, on a
Fixed lead that leaves fleets on different inits, and on a
Catchability or Time_varying_q that differs
within a group.
How an index is timed against mortality
The index prediction depends on Fleet_type; there is no
column to set.
A survey index is a snapshot at the month given in
index_data:
A fishery index is CPUE, which integrates over the year alongside the catch. Baranov gives , and effort cancels the (since ):
The catch equation and a fishery’s age composition use the same
,
so a fleet’s index, catch, and comps are consistent. Month
is not read for a fishery’s index rows.
This affects trend, not just scale, so a constant
cannot absorb it. At Month = 6,
is 1.0% below
at
but 8.8% below at
;
at Month = 0 the snapshot factor is
,
against
of 0.906 at
and 0.432 at
.
A seasonal fishery needs no special treatment: its exact window
predictor differs from the year-average by a near-constant factor
takes up (1–3% trend error across
0.05–0.8 for
between 0.1 and 0.5, against 29–33% for a snapshot).
A snapshot-timed index on a fishery’s selectivity
This is the AMAK/ebswp CPUE form, and what an ADMB bridge needs. Give
the index its own Survey fleet and point that fleet’s
Selectivity_index at the fishery, so the index gets the
fishery’s selectivity along with its own Month and its own
q. Build the mirror by copying the fishery’s fleet_control
row; see Sharing a
selectivity between fleets for the columns that have to agree.
5. Composition likelihoods
Set Comp_distribution (or
CAAL_distribution) per fleet:
| Value | String |
|---|---|
-1 |
"MultinomialAFSC" (AFSC convention; the
Comp_distribution default) |
0 |
"Multinomial" (the CAAL_distribution
default) |
1 |
"DirichletMultinomial" (Thorson et al. 2017) |
Diet composition uses an analogous switch on the bioenergetics
control sheet: Diet_distribution = 0 (multinomial) or
1 (Dirichlet-multinomial). Conditional age-at-length (CAAL)
data go through their own data path and are weighted via
CAAL_weights per fleet.
Ageing error, per fleet
age_error holds one matrix per species by default, and
every fleet reads its own species’. A stock whose ageing protocol
changed part way through a series needs more than one (GOA Pacific cod
reads its pre-2007 survey otoliths about a year older than its post-2007
ones), so both age_error and fleet_control
take an optional Ageing_error_index: give the matrices
index values, then point each fleet at the one that aged its samples.
Omit the column, or leave it NA, and the index is the
species. The two eras of a survey are then two fleets sharing a
Selectivity_index and a
Catchability_index.
Each index belongs to one species, since a matrix’s rows are sized by
that species’ age range. data_check() refuses an index that
names no matrix, an index whose rows give more than one
Species, and a fleet pointed at a matrix belonging to
another species (without the column, 2 means “species 2’s
matrix”, not “the second matrix”), and reports coverage per matrix.
6. Recruitment / stock-recruit
(recFun = build_srr())
srr_fun |
String | Description |
|---|---|---|
0 |
"mean" |
Mean recruitment with deviations |
2 |
"BevertonHolt" |
Beverton-Holt |
4 |
"Ricker" |
Ricker |
Priors and environmental relationships go on the curve through
build_srr(); see ?build_srr and
vignette("environmental-linkages-and-priors").
Under multispecies mode (msmMode > 0) spawning
biomass per recruit is undefined, because mortality includes predation.
A curve fitted in the hindcast then estimates its initial recruitment
level instead of deriving it, and the choice of initMode
can move the fitted stock substantially; the curve can also enter as a
recruitment penalty (srr_fun = "mean" with the curve as
srr_pred_fun). A prior on Beverton-Holt steepness is
refused.
7. Natural mortality (M1Fun = build_M1())
M1_model, fixed-effects structure of M1
| Value | String | Description |
|---|---|---|
0 |
"fixed" |
use the input M1_base (no estimation). |
1 |
"sex_age_invariant" |
estimate one M1_{spp}. |
2 |
"sex_specific" |
estimate M1_{spp, sex}. |
3 |
"sex_age_specific" |
estimate M1_{spp, sex, age}. |
Priors and environmental relationships go on M1 through
build_M1(); see ?build_M1 and
vignette("environmental-linkages-and-priors").
M1_re, random-effects structure on M1
| Value | String | Description |
|---|---|---|
0 (default) |
"none" |
No random effects |
1 |
"iid_age" |
IID by age, constant over years |
2 |
"iid_year" |
IID by year, constant over ages |
3 |
"iid_age_year" |
IID across both year and age |
4 |
"ar1_age" |
AR(1) by age, constant over years |
5 |
"ar1_year" |
AR(1) by year, constant over ages |
6 |
"ar1_age_year" |
2D AR(1) over both year and age |
M1_re > 0 requires an M1_model of
0, 1 or 2, or 3 with
a by-year family (2 or 5). Under
M1_model = 0 the input schedule is held fixed and the
deviations carry all of M’s variation, which makes them the most
identifiable of any level. Under M1_model = 3 an
age-varying deviation (1, 3, 4,
6) and the age-specific level enter the likelihood only as
their sum; M1_model = 1 with M1_re = 4 is the
identifiable version of that model. The deprecated env-driven
M1_model 4 and 5 are refused for
every family; linkage_spec(~ temp + (1 | Year)) expresses
the same model.
Variance and correlation parameters are species-specific but
sex-invariant. M1_dev_log_sd is the AR(1)
innovation standard deviation; the marginal is
sigma / sqrt(1 - rho^2), as in WHAM. (The linkage grammar
uses the opposite convention:
linkage_spec(~ ar1(1 | Year), init = ...) takes
sigma as the marginal SD.) M2_use_prior = TRUE
adds a log-normal prior with mean M_prior (the median when
bias_adjust_proc = FALSE) and log-scale SD
M_prior_sd on total M (M1 + M2) in multi-species mode.
Modes 3 and 6 estimate a full age × year
deviation field which, with a single standard deviation and no prior on
M, is strongly confounded with selectivity and recruitment in a
single-species assessment. Read fit$convergence and the
estimability table before trusting one, and consider a prior on M.
8. Growth and weight-at-age
(growthFun = build_growth())
fun (growth_model): fixed-effects
growth
| Value | String | Description |
|---|---|---|
0 (default) |
"empirical" |
Empirical weight-at-age supplied via the weight data
sheet. Forecasts re-use the terminal-year weight schedule. |
1 |
"vonBertalanffy" |
von Bertalanffy length-at-age + length-weight allometry
(alpha_wt_len, beta_wt_len on the data control
sheet) |
2 |
"Richards" |
Sex-specific Richards growth |
Growth variability, plus group, length bins and maturity
| Argument / column | Values | Description |
|---|---|---|
sd_form |
"SD" (default), "CV"
|
Whether sd_L1 / sd_Linf are SDs of
length-at-age (cm) or CVs (SD = CV x length) – SS3
CV_Growth_Pattern 2 or 0 |
sd_plus_group |
"WHAM" (default), "SS3"
|
Plus-group SD pinned to the upper endpoint, or interpolated by
length. SS3 with Growth_Age_for_L2 = 999 is
"WHAM"
|
plus_group_length |
"M1" (default), "none",
"SS3.24", "decay"
|
Plus-group mean length: M1-weighted mean toward L-infinity, or SS3’s
Linf_decay -998 / -999 / plus_group_decay
|
pop_lengths |
lower edges (cm); default the data bins | Population length bins on which the age-length key, weight and maturity are integrated |
L50_mat_len, slope_mat_len (control
sheet) |
cm, per cm; default NA | Logistic maturity-at-length; spawning output integrates maturity x
weight over length. NA keeps the age-based maturity
sheet |
Priors and environmental relationships go on growth through
build_growth(); see ?build_growth and
vignette("environmental-linkages-and-priors").
Time-varying growth is specified through the linkage grammar rather
than a switch of its own:
build_growth(linkages = list(K = linkage_spec(~ rw(1 | Year))))
puts a random walk on the von Bertalanffy K, and
ar1() / (1 | Year) give the autoregressive and
independent alternatives.
9. Harvest control rules (HCR = build_hcr())
HCR |
String | Description | Multi-species? |
|---|---|---|---|
0 |
"NoFishing" |
No fishing, estimate hindcast only | Yes |
1 |
"CMSY" |
Maximize joint catch across species (option to keep depletion ≥
Plimit) |
Yes |
2 |
"ConstantF" |
Constant F set at Ftarget per species |
Yes |
3 |
"ConstantFSSB" |
F that achieves Ftarget% of SB0 at the end
of the projection |
Yes |
4 |
"ConstantFSPR" |
FSPR at Ftarget (NEFSC convention; scale via
Fmult) |
No |
5 |
"NPFMC" |
NPFMC Tier 3 SPR-based HCR (Ftarget,
Flimit, Ptarget, Plimit,
Alpha) |
No |
6 |
"PFMC" |
PFMC Category 1 Ptarget-Plimit ACL with
uncertainty buffer around Flimit (Pstar,
Sigma) |
Yes |
7 |
"SESSF" |
SESSF Tier 1 SPR-based HCR | No |
DynamicHCR = TRUE switches from static to dynamic
SB0 reference points. HCRorder controls the
order in which species F is solved for iterative multi-species HCRs
(e.g. predators before prey). See ?build_hcr.
10. Projection and MSE
| Function | Purpose |
|---|---|
fit_mod(estimateMode = 2, HCR = build_hcr(...)) |
Forward projection under a fixed HCR |
sample_rec() |
Bootstrap historical recruitment deviations (with optional
rec_trend) into the projection; projected recruitment reads
them only under build_srr(proj_mean_rec = FALSE)
|
remove_F() |
Refit a model with F = 0 from styr (default: the year
after endyr); run_mse() uses it for the
no-fishing run behind the collapse metrics |
run_mse() |
Closed-loop MSE: refit EM on the assessment_period
schedule (a period, or the years themselves), sample new data at
sampling_period
|
load_mse() |
Reload per-simulation .rds files written when
dir = is supplied |
check_mse() |
Validate which OM/EM simulations converged |
mse_summary() |
Performance metrics by species, fishery fleet and in total: mean catch, IAV, P(closed), P(F > Flimit), P(SSB < SSBlimit), terminal depletion |
run_mse() parallelizes over simulations, on a FORK
cluster where the platform allows one and PSOCK on Windows. The MSE vignette has the seed handling and the
reproducibility guarantees.
11. Diagnostics and inference
| Function | Purpose |
|---|---|
retrospective() |
Peel terminal years and refit; reports Mohn’s rho for each quantity
/ species at the terminal year and the nyrs_forecast
(default 3) years after it |
jitter() |
Refit from random-perturbed starting values; check optimum stability |
sim_mod() / simulate()
|
Simulate data from a fitted model. Observations always; process
error (recruitment, M, growth, catchability, selectivity) via
process =. simulate() is the
stats generic and draws nsim replicates at
once |
self_test() |
Simulate and refit; check the model recovers what generated the data |
compare_sim() |
Estimation-vs-truth comparison across simulated replicates |
model_average() |
Weighted average of derived quantities across multiple fits, with optional bootstrap uncertainty |
reweight_comps() |
Iterative McAllister-Ianelli (1997) tuning of multinomial
Comp_weights
|
12. Plotting
Each plotter is named after the quantity it shows:
plot_biomass, plot_ssb,
plot_recruitment, plot_depletion,
plot_ssb_depletion, plot_exploitable_biomass,
plot_catch, plot_f,
plot_mortality, plot_m_at_age,
plot_m2_at_age_prop, plot_index,
plot_index_residual, plot_comp,
plot_data, plot_form,
plot_b_eaten, plot_b_eaten_prop,
plot_diet_comp, plot_ration,
plot_selectivity,
plot_selectivity_vs_maturity, plot_maturity,
plot_stock_recruit, plot_timeseries. Most
accept a single fitted model or a list of models with
model_names.
These are built with ggplot2 (colorblind-safe
Okabe-Ito palette for discrete series, viridis for continuous ones) and
return the ggplot object, so they print
when called interactively and take further ggplot2 layers
(e.g. plot_biomass(fit) + ggplot2::ggtitle("My title")).
Pass file = "stem" to also write a PNG with a per-plotter
suffix (plot_recruitment() writes
stem_R_trajectory.png); the per-fleet plotters write one
file each,
e.g. stem_comp_annual_fleet<N>_<age|length>.png
from plot_comp().
Shared arguments. The timeseries plotters
(plot_biomass, plot_ssb,
plot_recruitment, the depletions,
plot_exploitable_biomass, plot_f), the
predation plotters (plot_b_eaten,
plot_b_eaten_prop, plot_m_at_age,
plot_m2_at_age_prop, plot_ration) and
plot_selectivity take one common vocabulary, documented
together in ?"rceattle-plot-args": line_col,
lwd, lty, alpha,
species, spnames, minyr,
maxyr, incl_proj, incl_mean,
add_ci, model_names, file,
width and height. Each means the same thing
wherever it appears, but not every plotter takes every one
(incl_mean is on the predation plotters,
add_ci only where the quantity holds standard errors,
alpha only where the figure has a ribbon or a fan); check
args().
-
line_coltakes colour names, hex codes, or base-graphics palette indices (line_col = 1), andlwdkeeps the base-graphics scale where the default3is a standard-weight line. -
line_colandltysupply values for whichever variable the figure separates by colour or line type, which is not always the model (predators inplot_b_eaten_prop(), sexes inplot_ration()); each function’s help says which. Too few colours are recycled, with a warning. Where colour is a magnitude (the year fan inplot_selectivity())line_colgives the ramp anchors, soline_col = "black"draws the fan in black. -
speciesselects (by index, name, logical mask, or"all", in the order given) andspnameslabels. -
minyrandmaxyrnarrow the data, not just the axis, so a panel with a free y scale rescales to the window. - Base-graphics arguments (
right_adj,top_adj,mod_cex,legend.pos,single.plots,theta) are accepted and ignored by the plotters that had them, and absent from the rest. Set the equivalent on the returned ggplot instead, e.g.plot_biomass(fit) + ggplot2::theme(legend.position = "right").
Display units. Numbers-at-age are in thousands of
fish and weight-at-age in kg, so biomass and SSB come out in mt and
recruitment in thousands of fish. The timeseries plotters rescale the
axis to million mt and millions, and derive
the recruitment age from minage rather than assuming age 1.
Supply inputs on that convention (catch and index in mt, weight-at-age
in kg), or the axis labels will not describe what is plotted; pass
ylab to override the derived label.
Confidence intervals. add_ci = TRUE
draws a 95% interval. Strictly positive series take it on the log scale,
exp(log(x) ± 1.96 · sd_log), using the model’s
log_biomass / log_ssb / log_R
where they exist and the delta-method identity
sd(log x) = sd(x)/x where they do not, so it is
right-skewed and cannot reach zero for a weak year class or a depleted
stock (?plot_timeseries has the derivation).
plot_selectivity() takes it too, but only on a fit run
with fit_control(selectivity_se = TRUE) and only for
estimated, age-based fleets; otherwise it warns and draws none.
Selectivity is identified only up to a scalar, so
Sel_norm_bin fixes the curve’s level rather than measuring
it: the pinned bin has a standard error of 0, the band widens away from
it, and the band’s shape depends on Sel_norm_bin as well as
on the information in the data. Quote that anchor with the interval.
The error comes from whichever sdreport the fit ends on.
Under estimateMode = "Estimate" with an estimating HCR,
fit_mod() re-optimizes the projection with every hindcast
parameter fixed, so the standard error of every selectivity is exactly
0. estimateMode = "Projection" estimates no selectivity at
all, and projection_uncertainty cannot rescue it. Fit the
hindcast alone, or ask for uncertainty in the projection:
# Errors from the hindcast fit, the usual choice for a selectivity figure.
mod <- fit_mod(data_list = data, estimateMode = "Hindcast",
fit_control = fit_control(selectivity_se = TRUE))
plot_selectivity(mod, add_ci = TRUE, minyr = 2015, maxyr = 2015)
# Or keep the HCR projection and reuse the hindcast parameters in it.
mod <- fit_mod(data_list = data, HCR = build_hcr(HCR = 5),
fit_control = fit_control(selectivity_se = TRUE,
projection_uncertainty = TRUE))fit_mod() warns when the combination would report zeros,
and plot_selectivity() declines to draw a band that is 0
wide at every age. Give minyr / maxyr a single
year on a time-varying fleet: every year drawn gets its own band.
Under random_sel = FALSE the annual deviations are
penalized rather than integrated, so the band is a penalized-likelihood
error conditional on Sel_curve_pen1 /
Sel_curve_pen2 and on a fixed
Time_varying_sel_sd: change the smoothing and both the
curve and its band move. The band is also marginal. Selectivity error is
strongly correlated with F and q, so propagating it into a derived
quantity needs the covariance
(fit_control(getReportCovariance = TRUE)), not this
interval alone.
References
- Adams, G.D., Holsman, K.K., Barbeaux, S.J., Dorn, M.W., Ianelli, J.N., Spies, I., Stewart, I.J., Punt, A.E. (2022). An ensemble approach to understand predation mortality for groundfish in the Gulf of Alaska. Fisheries Research, 251, 106303.
- Cheng, M.L.H., Thorson, J.T., Ianelli, J.N., Cunningham, C.J. (2023). Unlocking the triad of age, year, and cohort effects for stock assessment: demonstration of a computationally efficient and reproducible framework using weight-at-age. Fisheries Research, 266, 106755.
- Holsman, K.K., Ianelli, J., Aydin, K., Punt, A.E., Moffitt, E.A. (2016). A comparison of fisheries biological reference points estimated from temperature-specific multi-species and single-species climate-enhanced stock assessment models. Deep Sea Research Part II, 134, 360-378.
- Kinzey, D., Punt, A.E. (2009). Multispecies and single-species models of fish population dynamics: comparing parameter estimates. Natural Resource Modeling, 22, 67-104.
- McAllister, M.K., Ianelli, J.N. (1997). Bayesian stock assessment using catch-age data and the sampling-importance resampling algorithm. Canadian Journal of Fisheries and Aquatic Sciences, 54, 284-300.
- Methot, R.D., Wetzel, C.R. (2013). Stock synthesis: a biological and statistical framework for fish stock assessment and fishery management. Fisheries Research, 142, 86-99.
- Rogers, L.A., Monnahan, C.C., Williams, K., Jones, D.T., Dorn, M.W. (2024). Climate-driven changes in the timing of spawning and the availability of walleye pollock (Gadus chalcogrammus) to assessment surveys in the Gulf of Alaska. ICES Journal of Marine Science, 82(1), fsae005.
- Taylor, I.G., Grandin, C., Hicks, A.C., Taylor, N., Cox, S. (2015). Status of the Pacific hake (whiting) stock in U.S. and Canadian waters in 2015. Joint Technical Committee of the U.S. and Canada Pacific Hake/Whiting Agreement; National Marine Fisheries Service; Fisheries and Oceans Canada.
- Thorson, J.T., Johnson, K.F., Methot, R.D., Taylor, I.G. (2017). Model-based estimates of effective sample size in stock assessment models using the Dirichlet-multinomial distribution. Fisheries Research, 192, 84-93.
- Wassermann, S.N., Adams, G.D., Haltuch, M.A., Kaplan, I.C., Marshall, K.N., Punt, A.E. (2025). Even low levels of cannibalism can bias population estimates for Pacific hake. ICES Journal of Marine Science, 82(1), fsae064.
- Xu, H., Thorson, J.T., Methot, R.D., Taylor, I.G. (2019). A new semi-parametric method for autocorrelated age- and time-varying selectivity in age-structured assessment models. Canadian Journal of Fisheries and Aquatic Sciences, 76, 268-285.