Penalized smooths for fishing mortality, catchability and observation SD
Source:R/smooths.R
smooth_formulas.RdUse s() or t2() in F_settings$mu_form, index_settings$q_form,
catch_settings$sd_form or index_settings$sd_form. for_fleet() scopes
F mean formulas and for_survey() scopes catchability formulas. Use a
categorical by column for separate observation-SD smooths by group.
mgcv builds the basis, and the assessment jointly estimates each
relationship and its smoothness.
Details
Supported terms are univariate s(x, k, bs, by) with thin-plate
("tp") or cubic-regression ("cr") bases, and t2(age, year, k, bs, by)
using these marginal bases. Predictors and categorical by groups must be
bare input-column names. Other mgcv options, numeric by, te(), ti(),
multidimensional s(), linked penalties, fixed smoothness, random-effect
bases and custom constraints are not supported. Choose a modest k supported
by distinct predictor values; it limits basis size, not the fitted EDF.
Unpenalized basis directions are fixed coefficients. Each penalized block
has coefficients \(u_j\sim N(0,\tau_j^2 I)\) with its complete normalized
Gaussian density. Smoothing SDs are estimated through RTMB and coefficients
are integrated by Laplace approximation. Tensor terms can have several
independent penalties; factor-by smooths have separate penalties per level.
In mean formulas, contributions enter the log F or selected q-link
predictor before any multiplicative selectivity curve. In sd_form,
contributions enter the log of the observation SD. A positive effect
increases residual spread. Catch and index SD smooths each have their
own coefficients and penalties. The cor_struct setting controls
correlation among observation errors. Ordinary terms provide intercepts, and
sd_supplied continues to supply an offset on the log-SD scale.
F smooths support process = "off", "iid" or "ar1". Smooth means with
residual variation are experimental: both may describe the same pattern.
Inspect check_tam(), uncertainty, and recovery simulations. Intrinsic
RW/correlated-RW F residuals are not supported with smooth means.
Bases use historical covariates and are rebuilt in every fold. Temporal
smooth contributions hold the terminal training year in projections.
The rw()/ar1() q effects follow their own process definitions. Warm starts
are retained only for compatible bases. Simulation draws each penalized
coefficient once per realization and applies the same function throughout
its grid. Conditional draws retain fitted coefficients. See
tidy_tam() for the fitted contributions and uncertainty.
The conversion follows mgcv's smoothCon()/smooth2random(type = 2) and
the approach in sdmTMB. Prediction transforms are adapted from Simon Wood's
mgcv smooth2random example, also used by sdmTMB's s2rPred().
Validation pins mgcv 1.9.4 and sdmTMB revision
34740199c51fbebe86a6de7671f33f590db166bf.
References
Wood, S. N. (2017). Generalized Additive Models: An Introduction
with R, second edition. Chapman and Hall/CRC.
https://stat.ethz.ch/R-manual/R-devel/library/mgcv/html/smooth2random.html
sdmTMB contributors, R/smoothers.R (GPL-3):
https://github.com/sdmTMB/sdmTMB/blob/34740199c51fbebe86a6de7671f33f590db166bf/R/smoothers.R
Examples
~ fleet + s(age, k = 5, by = fleet)
#> ~fleet + s(age, k = 5, by = fleet)
#> <environment: 0x62974c1ef520>
~ fleet + t2(age, year, k = c(4, 5), bs = c("cr", "tp"), by = fleet)
#> ~fleet + t2(age, year, k = c(4, 5), bs = c("cr", "tp"), by = fleet)
#> <environment: 0x62974c1ef520>
~ 0 + for_fleet("Trawl", ~ factor(year) + logistic(age)) +
for_fleet("Gillnet", ~ factor(year) + s(age, k = 5))
#> ~0 + for_fleet("Trawl", ~factor(year) + logistic(age)) + for_fleet("Gillnet",
#> ~factor(year) + s(age, k = 5))
#> <environment: 0x62974c1ef520>
~ 0 + for_survey("RV", ~ s(age, k = 5)) +
for_survey("Sentinel", ~ logistic(age))
#> ~0 + for_survey("RV", ~s(age, k = 5)) + for_survey("Sentinel",
#> ~logistic(age))
#> <environment: 0x62974c1ef520>
catch_settings <- list(sd_form = ~ s(age, k = 5))
index_settings <- list(sd_form = ~ survey + s(age, k = 5, by = survey))