Simulate data from a salmonid IPM
simIPM.Rd
Generate pseudo-data, group-level parameters, and states from a specified salmonIPM integrated population model given values for the hyperparameters. This may be useful, e.g., in simulation-based calibration and model sensitivity checking. It is not suitable for simulating data from a fitted model, because initial states are drawn randomly rather than being passed in.
Arguments
- life_cycle
Character string indicating which life-cycle model to simulate. Currently available options are spawner-to-spawner (
"SS"
, the default), iteroparous spawner-to-spawner ("SSiter"
), or spawner-smolt-spawner ("SMS"
).- 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. Ifpool_pops == TRUE
, these should be the names of the population-specific parameters, not their hyper-means. For example, iflife_cycle %in% c("SS","SSiter")
, the options are"none"
(the default),"alpha"
,"Rmax"
, orc("alpha","Rmax")
. CurrentlyRRS
is only implemented forpool_pops == FALSE
.- N_age
Number of (maiden) adult age classes.
- max_age
Oldest (maiden) adult age class.
- ages
For multi-stage models, a named list giving the fixed ages in years of all subadult life stages. For example, if
life_cycle == "SMS"
,list(M = a)
wherea
is integer smolt age.- pars
Named list of (hyper)parameters to be used for simulations:
mu_alpha
Hyper-mean of log intrinsic productivity.mu_alpha_W
,mu_alpha_H
Hyper-means of log intrinsic productivity for wild- and hatchery-origin spawners, respectively. If they differ, both must be specified andmu_alpha
must not be used (and conversely).beta_alpha
Vector of regression coefficients for log intrinsic productivity. Must be specified ifpar_models
includesalpha ~ ...
; otherwise will be ignored and may be omitted.sigma_alpha
Hyper-SD of log intrinsic productivity.mu_Rmax
Iflife_cycle == "SS"
, hyper-mean of log maximum recruitment.mu_Rmax_W
,mu_Rmax_H
Hyper-means of log maximum recruitment for wild- and hatchery-origin spawners, respectively. If they differ, both must be specified andmu_Rmax
must not be used (and conversely).beta_Rmax
Iflife_cycle == "SS"
, vector of regression coefficients for log maximum recruitment. Must be specified ifpar_models
includesRmax ~ ...
; otherwise will be ignored and may be omitted.sigma_Rmax
Iflife_cycle == "SS"
, hyper-SD of log maximum recruitment.rho_alphaRmax
Iflife_cycle == "SS"
, correlation between population-level log(alpha) and log(Rmax).rho_WH
If eithermu_alpha
ormu_[R|M]max
differ by rearing type, correlation between the respective_W
and_H
population-level parameters.beta_R
Iflife_cycle == "SS"
, vector of regression coefficients for log recruitment. Must be specified ifpar_models
includesR ~ ...
; otherwise will be ignored and may be omitted.rho_R
Iflife_cycle == "SS"
, AR(1) coefficient of brood-year log productivity anomalies.sigma_year_R
Iflife_cycle == "SS"
, hyper-SD of brood-year log productivity anomalies.sigma_R
Iflife_cycle == "SS"
, unique recruitment process error SD.mu_Mmax
Iflife_cycle == "SMS"
, hyper-mean of log maximum smolt recruitment.beta_Mmax
Iflife_cycle == "SMS"
, vector of regression coefficients for log maximum smolt recruitment.mu_Mmax_W
,mu_Mmax_H
Hyper-means of log maximum smolt recruitment for wild- and hatchery-origin spawners, respectively. If they differ, both must be specified andmu_Mmax
must not be used (and conversely).sigma_Mmax
Iflife_cycle == "SMS"
, hyper-SD of log maximum smolt recruitment.rho_alphaMmax
Iflife_cycle == "SMS"
, correlation between log(alpha) and log(Mmax).beta_M
Iflife_cycle == "SMS"
, vector of regression coefficients for log smolt recruitment. Must be specified ifpar_models
includesM ~ ...
; otherwise will be ignored and may be omitted.rho_M
Iflife_cycle == "SMS"
, AR(1) coefficient of spawner-smolt log productivity anomalies.sigma_year_M
Iflife_cycle == "SMS"
, process error SD of spawner-smolt log productivity anomalies.sigma_M
Iflife_cycle == "SMS"
, SD of unique spawner-smolt productivity process errors.mu_MS
Iflife_cycle == "SMS"
, mean SAR.beta_MS
Iflife_cycle == "SMS"
, vector of regression coefficients for logit SAR anomalies. Must be specified ifpar_models
includess_MS ~ ...
; otherwise will be ignored and may be omitted.rho_MS
Iflife_cycle == "SMS"
, AR(1) coefficient for logit SAR anomalies.sigma_year_MS
Iflife_cycle == "SMS"
, process error SD of logit SAR anomalies.sigma_MS
Iflife_cycle == "SMS"
, SD of unique logit SAR process errors.mu_p
Among-population mean simplex of age distributions.sigma_pop_p
Vector of among-population SDs of mean log-ratio age distributions.R_pop_p
Among-population correlation matrix of mean log-ratio age distributions.sigma_pop_p
Vector of SDs of log-ratio cohort age distributions.R_pop_p
Correlation matrix of cohort log-ratio age distributions.sigma_p
Vector of SDs of log-ratio cohort age distributions.R_p
Correlation matrix of cohort log-ratio age distributions.mu_SS
Iflife_cycle == "SSiter"
, mean kelt survival.beta_SS
Iflife_cycle == "SSiter"
, vector of regression coefficients for logit kelt survival. Must be specified ifpar_models
includess_SS ~ ...
; otherwise will be ignored and may be omitted.rho_SS
Iflife_cycle == "SSiter"
, AR(1) coefficient for annual logit kelt survival anomalies.sigma_year_SS
Iflife_cycle == "SSiter"
, process error SD of annual logit kelt survival anomalies.sigma_SS
Iflife_cycle == "SSiter"
, SD of unique logit kelt survival process errors.tau
Iflife_cycle != "SMS"
, spawner observation error SD.tau_M
Iflife_cycle == "SMS"
, smolt observation error SD.tau_S
Iflife_cycle == "SMS"
, pawner observation error SD.S_init
Scalar giving median of initial spawning population size. If bothS_init
andS_init_K
are specified, the latter is ignored.S_init_K
Scalar giving median of initial spawning population size as a fraction of carrying capacity. Note that ifalpha < 1
,K
is undefined and specifyingS_init_K
will result in an error.
- par_models
Optional list of two-sided formulas of the form
theta ~ x1 + ... + xK
, wheretheta
is a (hyper)parameter or state in the model specified bystan_model
that accepts covariates (see Details for available model-parameter combinations) andx1 + ... + xK
are terms involving variables infish_data
. Standard formula syntax such as:
and*
may be used; seestats::formula()
.- center
Logical indicating whether the terms in model matrices constructed from
fish_data
using the formulas inpar_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 predictorscenter = 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 inpar_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_F
Logical or 0/1 vector of length
N_age
indicating whether each adult age is fully (non)selected by the fishery. The default is all selected. Iflife_cycle == "SSiter"
,N_age
refers to the total number of maiden and repeat age classes (counting the repeat plus group as 1).- age_B
Logical or 0/1 vector of length
N_age
indicating whether each adult age is fully (non)selected in broodstock collection. The default is all selected. Iflife_cycle == "SSiter"
,N_age
refers to the total number of maiden and repeat age classes (counting the repeat plus group as 1).- fish_data
Data frame with columns:
pop
Numeric, character or factor population ID.year
Numeric or integer giving the year the fish spawned (i.e., the brood year).A
Spawning habitat size (either stream length or area). Will often be time-invariant within a population, but need not be.p_HOS
True fraction of hatchery-origin spawners.F_rate
Total harvest rate (proportion) of natural-origin fish.B_rate
Adult hatchery broodstock removal rate.n_age_obs
Number of spawners sampled for age composition.n_HW_obs
Number of spawners sampled for hatchery / wild origin....
Additional variables to be used as covariates.
Value
A named list with elements
sim_dat
A data frame containing simulated data in the structure of (seesalmonIPM()
) appropriate for the specifiedlife_cycle
, ready to be passed tosalmonIPM()
.pars_out
A named list of hyperparameters, group-level parameters, and states used in generating the pseudo-data.
See also
salmonIPM()
for fitting models