Simulate data from a salmonid IPM
simIPM.RdGenerate 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_funthat 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"). CurrentlyRRSis 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)whereais integer smolt age.- pars
Named list of (hyper)parameters to be used for simulations:
mu_alphaHyper-mean of log intrinsic productivity.mu_alpha_W,mu_alpha_HHyper-means of log intrinsic productivity for wild- and hatchery-origin spawners, respectively. If they differ, both must be specified andmu_alphamust not be used (and conversely).beta_alphaVector of regression coefficients for log intrinsic productivity. Must be specified ifpar_modelsincludesalpha ~ ...; otherwise will be ignored and may be omitted.sigma_alphaHyper-SD of log intrinsic productivity.mu_RmaxIflife_cycle == "SS", hyper-mean of log maximum recruitment.mu_Rmax_W,mu_Rmax_HHyper-means of log maximum recruitment for wild- and hatchery-origin spawners, respectively. If they differ, both must be specified andmu_Rmaxmust not be used (and conversely).beta_RmaxIflife_cycle == "SS", vector of regression coefficients for log maximum recruitment. Must be specified ifpar_modelsincludesRmax ~ ...; otherwise will be ignored and may be omitted.sigma_RmaxIflife_cycle == "SS", hyper-SD of log maximum recruitment.rho_alphaRmaxIflife_cycle == "SS", correlation between population-level log(alpha) and log(Rmax).rho_WHIf eithermu_alphaormu_[R|M]maxdiffer by rearing type, correlation between the respective_Wand_Hpopulation-level parameters.beta_RIflife_cycle == "SS", vector of regression coefficients for log recruitment. Must be specified ifpar_modelsincludesR ~ ...; otherwise will be ignored and may be omitted.rho_RIflife_cycle == "SS", AR(1) coefficient of brood-year log productivity anomalies.sigma_year_RIflife_cycle == "SS", hyper-SD of brood-year log productivity anomalies.sigma_RIflife_cycle == "SS", unique recruitment process error SD.mu_MmaxIflife_cycle == "SMS", hyper-mean of log maximum smolt recruitment.beta_MmaxIflife_cycle == "SMS", vector of regression coefficients for log maximum smolt recruitment.mu_Mmax_W,mu_Mmax_HHyper-means of log maximum smolt recruitment for wild- and hatchery-origin spawners, respectively. If they differ, both must be specified andmu_Mmaxmust not be used (and conversely).sigma_MmaxIflife_cycle == "SMS", hyper-SD of log maximum smolt recruitment.rho_alphaMmaxIflife_cycle == "SMS", correlation between log(alpha) and log(Mmax).beta_MIflife_cycle == "SMS", vector of regression coefficients for log smolt recruitment. Must be specified ifpar_modelsincludesM ~ ...; otherwise will be ignored and may be omitted.rho_MIflife_cycle == "SMS", AR(1) coefficient of spawner-smolt log productivity anomalies.sigma_year_MIflife_cycle == "SMS", process error SD of spawner-smolt log productivity anomalies.sigma_MIflife_cycle == "SMS", SD of unique spawner-smolt productivity process errors.mu_MSIflife_cycle == "SMS", mean SAR.beta_MSIflife_cycle == "SMS", vector of regression coefficients for logit SAR anomalies. Must be specified ifpar_modelsincludess_MS ~ ...; otherwise will be ignored and may be omitted.rho_MSIflife_cycle == "SMS", AR(1) coefficient for logit SAR anomalies.sigma_year_MSIflife_cycle == "SMS", process error SD of logit SAR anomalies.sigma_MSIflife_cycle == "SMS", SD of unique logit SAR process errors.mu_pAmong-population mean simplex of age distributions.sigma_pop_pVector of among-population SDs of mean log-ratio age distributions.R_pop_pAmong-population correlation matrix of mean log-ratio age distributions.sigma_pop_pVector of SDs of log-ratio cohort age distributions.R_pop_pCorrelation matrix of cohort log-ratio age distributions.sigma_pVector of SDs of log-ratio cohort age distributions.R_pCorrelation matrix of cohort log-ratio age distributions.mu_SSIflife_cycle == "SSiter", mean kelt survival.beta_SSIflife_cycle == "SSiter", vector of regression coefficients for logit kelt survival. Must be specified ifpar_modelsincludess_SS ~ ...; otherwise will be ignored and may be omitted.rho_SSIflife_cycle == "SSiter", AR(1) coefficient for annual logit kelt survival anomalies.sigma_year_SSIflife_cycle == "SSiter", process error SD of annual logit kelt survival anomalies.sigma_SSIflife_cycle == "SSiter", SD of unique logit kelt survival process errors.tauIflife_cycle != "SMS", spawner observation error SD.tau_MIflife_cycle == "SMS", smolt observation error SD.tau_SIflife_cycle == "SMS", pawner observation error SD.S_initScalar giving median of initial spawning population size. If bothS_initandS_init_Kare specified, the latter is ignored.S_init_KScalar giving median of initial spawning population size as a fraction of carrying capacity. Note that ifalpha < 1,Kis undefined and specifyingS_init_Kwill result in an error.
- par_models
Optional list of two-sided formulas of the form
theta ~ x1 + ... + xK, wherethetais a (hyper)parameter or state in the model specified bystan_modelthat accepts covariates (see Details for available model-parameter combinations) andx1 + ... + xKare 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_datausing the formulas inpar_modelsshould 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 = FALSEmay 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_datausing the formulas inpar_modelsshould 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_ageindicating whether each adult age is fully (non)selected by the fishery. The default is all selected. Iflife_cycle == "SSiter",N_agerefers 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_ageindicating whether each adult age is fully (non)selected in broodstock collection. The default is all selected. Iflife_cycle == "SSiter",N_agerefers to the total number of maiden and repeat age classes (counting the repeat plus group as 1).- fish_data
Data frame with columns:
popNumeric, character or factor population ID.yearNumeric or integer giving the year the fish spawned (i.e., the brood year).ASpawning habitat size (either stream length or area). Will often be time-invariant within a population, but need not be.p_HOSTrue fraction of hatchery-origin spawners.F_rateTotal harvest rate (proportion) of natural-origin fish.B_rateAdult hatchery broodstock removal rate.n_age_obsNumber of spawners sampled for age composition.n_HW_obsNumber of spawners sampled for hatchery / wild origin....Additional variables to be used as covariates.
Value
A named list with elements
sim_datA data frame containing simulated data in the structure of (seesalmonIPM()) appropriate for the specifiedlife_cycle, ready to be passed tosalmonIPM().pars_outA named list of hyperparameters, group-level parameters, and states used in generating the pseudo-data.
See also
salmonIPM() for fitting models