fit_stockseasonr | R Documentation |
Fit model
fit_stockseasonr(
abund_formula = NULL,
comp_formula = NULL,
abund_dat = NULL,
comp_dat = NULL,
abund_offset = NULL,
abund_knots = NULL,
comp_knots = NULL,
pred_dat = NULL,
model = c("negbin", "dirichlet", "integrated"),
random_walk = FALSE,
fit = TRUE,
silent = TRUE,
nlminb_loops = 1L,
newton_loops = 0L
)
abund_formula |
Model formula for abundance component of model (fit with negative binomial distribution (nbinom2)). Random intercepts (IID or RW) are possible using lme4 syntax, e.g., + (1 | g) where g is a column of class factor representing groups. Penalized splines are possible via mgcv with s() (te not currently supported). |
comp_formula |
Model formula for composition component of model (fit with dirichlet distribution). Random intercepts (IID or RW) are possible using lme4 syntax, e.g., + (1 | g) where g is a column of class factor representing groups. Splines are possible via mgcv with s(), but unlike abundance component these are unpenalized so knots must be specified with k=. |
abund_dat |
Dataframe containing abundance response (e.g. catch) and covariates. |
comp_dat |
Dataframe containing composition response in long format (i.e column of class factor) and covariates. |
abund_offset |
A numeric vector representing the model offset. Usually a log transformed variable. Not included in any prediction. |
abund_knots |
Optional named list containing knot values to be used for basis
construction of smoothing terms in abundance component of model. See
|
comp_knots |
As above, but for composition component of model. |
pred_dat |
Optional dataframe used to generate predictions. Note that in integrated model this applies to both abundance and composition components. |
model |
String specifying whether abundance (negbin), composition (dirichlet), or integrated model is fit. |
random_walk |
Logical specifying whether random intercepts are IID or random walk. |
fit |
Logical specifying whether model should be fit in TMB. If FALSE list of model inputs is returned. |
silent |
Silent or include optimization details? Helpful to set to FALSE for models that take a while to fit. |
nlminb_loops |
How many times to run |
newton_loops |
Alternative Newton optimizer for |
List including model inputs as well as output from TMB::sdreport()
(if fit = TRUE).
dum_pred <- expand.grid(month_n = seq(1, 12, by = 0.1),
region = unique(comp_ex$region))
# composition model with hierarchical random walk
m1 <- fit_stockseasonr(comp_formula = agg ~ 1 + region +
s(month_n, bs = "tp", k = 4, m = 2) +
(1 | year),
comp_dat = comp_ex,
pred_dat = dum_pred,
model = "dirichlet",
random_walk = TRUE,
fit = TRUE,
newton_loops = 1)
# group-specific integrated model with hierarchical random walk
m2 <- fit_stockseasonr(abund_formula = catch ~ 1 +
s(month_n, bs = "tp", k = 3, m = 2) +
region +
(1 | year),
abund_dat = catch_ex,
abund_offset = "offset",
comp_formula = agg ~ 1 + region +
s(month_n, bs = "tp", k = 4, m = 2) +
(1 | year),
comp_dat = comp_ex,
pred_dat = dum_pred,
model = "integrated",
random_walk = TRUE,
fit = TRUE,
silent = FALSE,
newton_loops = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.