Skip to contents

Use s() or t2() in F_settings$mu_form or index_settings$q_form, including inside for_fleet() and for_survey(). The basis is built by mgcv; the assessment jointly estimates the relationship and its smoothness. No separate GAM is fitted to catch or survey observations.

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. These penalties describe mean relationships, not F residual innovations. Contributions enter the log F or selected q-link predictor, before any multiplicative selectivity curve. Ordinary terms provide intercepts.

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 are constructed from historical covariates only and rebuilt in every fold. New temporal smooth contributions hold the terminal training year in projections; existing rw()/ar1() q-effect forecasts retain their 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.

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: 0x5edf856b4110>
~ 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: 0x5edf856b4110>
~ 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: 0x5edf856b4110>
~ 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: 0x5edf856b4110>