Skip to contents

Models fitted with salmonIPM-package are objects of S3 class salmonIPMfit. Elements generally mirror the named arguments passed to the constructor function by salmonIPM() and are mostly self-explanatory, except prior.info is a named list whose elements are lists returned by priors functions for all hyperparameters in the model, whether modifiable (user-specified or default) or hard-coded.

Usage

salmonIPMfit(
  stanfit,
  call,
  stan_model,
  model,
  life_cycle,
  ages,
  pool_pops,
  SR_fun,
  RRS,
  par_models,
  center,
  scale,
  age_S_obs,
  age_S_eff,
  conditionGRonMS,
  prior.info,
  stan_data,
  dims,
  pops,
  elapsed_time,
  salmonIPM_version
)

Arguments

stanfit

An object of class stanfit.

call

An object of class call containing the call to salmonIPM().

stan_model

Character string specifying the salmonIPM model to be fit. A more concise alternative to specifying model, life_cycle, and pool_pops and will override those arguments.

model

Either "IPM" or "RR", indicating whether to fit an IPM or run-reconstruction regression model.

life_cycle

Character string indicating which life-cycle model to fit. One of the following options (must be "SS" if model == "RR"):

  • "SS" Spawner-to-spawner (the default)

  • "SSiter" Spawner-to-spawner with iteroparity (an alias for "SS" with stan_data("IPM_SS_[x]p", fish_data = fish_data)$iter set to 1)

  • "SMS" Spawner-smolt-spawner with a fixed smolt age

  • "SMaS" Spawner-smolt-spawner with multiple smolt age classes (currently only available for pool_pops == FALSE)

  • "LCRchum" Customized spawner-smolt-spawner model for Lower Columbia River chum (pool_pops == TRUE)

ages

For multi-stage models, a named list giving the ages in years of all fixed-age subadult life stages. This is not needed for IPM_SMaS_np because in that case smolt age structure is provided in fish_data.

pool_pops

Logical defaulting to TRUE if multiple populations are present in fish_data and FALSE otherwise, indicating whether to model multiple populations hierarchically rather than as independent "fixed effects". It is possible to fit a model to multiple populations simultaneously even though they share no parameters; indeed this is more efficient than fitting them one at a time because calculations are vectorized and warmup is shared.

SR_fun

One of "exp" (density-independent discrete exponential), "BH" (Beverton-Holt, the default), or "Ricker", indicating which spawner-recruit function to fit. Synonyms "DI", "B-H", "bh", "b-h" and "ricker" are accepted.

RRS

A character string or vector of strings naming parameters of the function specified by SR_fun that differ between wild- and hatchery-origin spawners, such that the relative reproductive success of hatchery spawners is not equal to 1. If pool_pops == TRUE, these should be the names of the population-specific parameters, not their hyper-means. For example, if life_cycle %in% c("SS","SSiter"), the options are "none" (the default), "alpha", "Rmax", or c("alpha","Rmax"). Currently RRS is only implemented for pool_pops == FALSE.

par_models

Optional list of two-sided formulas of the form theta ~ x1 + ... + xK, where theta is a (hyper)parameter or state in the model specified by stan_model that accepts covariates (see Details for available model-parameter combinations) and x1 + ... + xK are terms involving variables in fish_data. Standard formula syntax such as : and * may be used; see stats::formula().

center

Logical indicating whether the terms in model matrices constructed from fish_data using the formulas in par_models should be centered. It is usually recommended to use the default (TRUE) so the baseline parameter estimate applies when predictors are at their sample means, but in some cases such as factor predictors center = FALSE may be appropriate. If combining categorical and numeric predictors, the latter can be centered and scaled prior to modeling.

scale

Logical indicating whether the model matrices constructed from fish_data using the formulas in par_models should be scaled to have column SDs of 1. Unit-scaling predictors is less critical than centering, but is advisable if variables have scales far from 1.

age_S_obs

If stan_model == "IPM_SS_pp", a logical or 0/1 integer vector indicating, for each adult age, whether the observed total spawner data includes that age. The default is to treat S_obs as including spawners of all ages. This option may be useful if certain age classes are not counted. If life_cycle == "SSiter", N_age refers to the total number of maiden and repeat age classes (counting the repeat plus group as 1).

age_S_eff

If stan_model == "IPM_SS_pp", a logical or 0/1 vector indicating, for each adult age, whether spawners of that age contribute to reproduction. This can be used, e.g., to exclude jacks from the effective breeding population. The default is to include spawners of all ages. If life_cycle == "SSiter", N_age refers to the total number of maiden and repeat age classes (counting the repeat plus group as 1).

conditionGRonMS

If life_cycle == "SMaS", logical indicating whether the Gilbert-Rich age frequencies n_GRage_obs in fish_data are conditioned on ocean age. If FALSE (the default) the counts are assumed to be sampled randomly from the population. If TRUE, it is assumed that the number of spawners of each ocean age (e.g., jacks vs 1-ocean) is arbitrary, but smolt (FW) age is randomly sampled within each ocean age; i.e., in a smolt age x ocean age contingency table, the cell frequencies are conditioned on the column totals.

prior.info

A named list of priors on pars. Each element is itself a named list representing the prior in the format returned by the functions in priors with an additional attribute "type".

stan_data

Optional named list of input data passed to rstan::sampling() for fitting an IPM, as returned by stan_data(). Stored if salmonIPM() is called with save_data = TRUE, otherwise NULL.

dims

A named list of data dimensions, including the number of cases (i.e. rows in fish_data) N, the number of populations N_pop, the number of years N_year, and any other model-specific elements.

pops

Character vector giving the unique elements of fish_data$pop.

elapsed_time

Wall time (s) to fit the model, as returned by get_elapsed_time().

salmonIPM_version

The version of salmonIPM used to fit the model.

Value

A salmonIPMfit object with elements described above.

See also