| Title: | Fits the Multispecies Assessment Model (CEATTLE) Using TMB |
|---|---|
| Description: | Implements the CEATTLE model using Template Model Builder ('TMB'; Kristensen et al. 2015), which can be installed following <https://github.com/kaskr/adcomp/wiki/Download>. Structured similar to the original manuscript in terms of modularization. Separate functions estimate retrospective temperature- and size-specific predator rations, prey preference, and weight-at-age. These are then used as inputs to the CEATTLE model to evaluate how predation mortality, recruitment, and survival of three target species change under historical climate conditions and harvest rates. |
| Authors: | Grant Adams [aut, cre] (ORCID: <https://orcid.org/0000-0003-0297-8347>) |
| Maintainer: | Grant Adams <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 4.5.0 |
| Built: | 2026-06-10 02:51:24 UTC |
| Source: | https://github.com/grantdadams/Rceattle |
Returns the model's derived population quantities in long form so that
custom plots and post-processing don't have to walk the deeply nested
quantities list or inherit the dimnames decisions in
rename_output(). Two shapes are flattened into one tidy frame:
species-by-year quantities (e.g. biomass, ssb, R, F_spp) and
species-by-sex-by-age-by-year quantities (e.g. N_at_age,
biomass_at_age, M_at_age). For the species-level shapes, sex
and age are returned as NA. Cells of the 4D arrays that are
padded out to max(nsex) / max(nages) for species with fewer
sexes or ages are dropped.
## S3 method for class 'Rceattle' as.data.frame( x, row.names = NULL, optional = FALSE, which = c("biomass", "ssb", "R", "biomass_depletion", "ssb_depletion", "F_spp"), ci_level = 0.95, ... )## S3 method for class 'Rceattle' as.data.frame( x, row.names = NULL, optional = FALSE, which = c("biomass", "ssb", "R", "biomass_depletion", "ssb_depletion", "F_spp"), ci_level = 0.95, ... )
x |
An object of class |
row.names, optional
|
Ignored; present for the |
which |
Character vector of quantity names to extract, or
|
ci_level |
Confidence level for |
... |
Currently unused. |
Standard errors (se) and confidence intervals (lwr, upr) are
populated from the TMB sdreport for any quantity that was
ADREPORT'd (currently biomass, ssb, R); other quantities and
fits produced with getsd = FALSE get NA for se / lwr / upr.
Set ci_level to widen or narrow the band.
A data.frame with columns year, species, sex, age,
quantity, value, se, lwr, upr. species is the character
species name from data_list$spnames. Rows are sorted in the order
which was given.
A data list containing inputs for a single-species CEATTLE model fit to
Aleutian Islands Atka mackerel data through 2022. See
BS2017SS for format details.
Atka2022Atka2022
A list with the same structure as BS2017SS.
A data list containing inputs for the three-species (walleye pollock,
Pacific cod, arrowtooth flounder) multispecies CEATTLE model for the
Eastern Bering Sea. See BS2017SS for format details.
BS2017MSBS2017MS
A list with the same structure as BS2017SS.
A dataset containing the inputs used for CEATTLE
BS2017SSBS2017SS
Control
Number of species included in CEATTLE
Start year of the hindcast
End year of the hindcast
End year of the forecast
Number of sexes to model in the population (1 = combined/1sex, 2 = models both female/male)
Spawning month of the population to adjust the numbers spawning
Percent of recruitment that is female (ignored if nsex = 1)
Number of ages of each species included in the hindcast
Minimum age for each population (i.e.does recruitment correspond to age 0, 1, 2?)
Number of lengths of each species included in the hindcast
Weight-at-age (weight) index to use for calculation of each species population derived quantities (SSB, Consumption/Ration, Suitability, etc)
Weight-at-age (weight) index to use for calculation of each species spawning biomass
Age transition matrix (e.g. growth trajectory) index to use for derived quantities of the population to convert age to length (also used in length-based predation estimation)
Standard deviation to use for recruitment
Other food in the ecosystem for each species
Estimate or fix numbers-at-age: 0 = estimate dynamics, 1 = use input numbers-at-age in NbyageFixed, 2 = multiply input numbers-at-age (NbyageFixed) by a single scaling coefficient, 3 = multiply input numbers-at-age (NbyageFixed) by age specific scaling coefficient.
Estimate residual (multi-species mode) or total natural mortality (single-species mode). 0 = use fixed natural mortality from M1_base, 1 = estimate sex- and age-invariant M1, 2 = sex-specific (two-sex model), age-invariant M1, 3 = estimate sex- and age-specific M1.
Survey and fishery data specifications
Survey index in weight (kg) or numbers data
Total catch in weight (kg) or numbers data
Survey/fishery age or length composition data. Note if sex is 3, put female composition data then male composition data (similar to SS).
Empirical/fixed selectivity for surveys and fisheries (leave empty if not used)
Age transition matrix (e.g. growth trajectory) used to convert age to length for length comp data. Can have multiple matrices for a species specified by Age_transition_index.
Aging error matrices. Can have only one per species.
Weight-at-age (weight) to use for calculation of derived quantities (SSB, Consumption/Ration, Suitability, Total Catch, Survey Biomass, etc). Can have multiple weight-at-age data-sets for each species, but must be full for all years of the hindcast.
Maturity-at-age for each species
Percent female at age for each species
Residual natural mortality for each species
Parameters for weight-at-length power function for each species. . Used when estimating time-variant length-based gamma suitability (suitMode = 2) or time-variant length-based lognormal suitability (suitMode = 5)
Which bioenergetics equation to use for each species for ft to scale max consumtion: 1 = Exponential (Stewart et al 1983), 2 = Temperature-dependendence for warm-water species (Kitchell et al 1977; sensu Holsman et al 2015), 3 = temperature dependence for cool and cold-water species (Thornton and Lessem 1979)
Which environmental index in env_data to use to drive bioenergetics
This scales the maximum consumption used for ration for each species; Pvalue is in CmaxfTPvalue*ration_data
Number of foraging days per year for each species
Intercept of allometric mass function for calculating maximum consumption: CA * Weight ^ CB
Slope of allometric mass function for calculating maximum consumption: CA * Weight ^ CB
Parameter for temperature scaling function of maximum consumption specified by Ceq
Parameter for temperature scaling function of maximum consumption specified by Ceq
Parameter for temperature scaling function of maximum consumption specified by Ceq
Parameter for temperature scaling function of maximum consumption specified by Ceq
Parameter for temperature scaling function of maximum consumption specified by Ceq
Parameter for temperature scaling function of maximum consumption specified by Ceq
Environmental indices such as bottom temperature data to incorporate into ration equation specificed by Ceq and Cindex. Also used to drive catchability if Catchability = 5. Will use the mean for missing years. Temperature should be in celcius.
Annual relative foraging rate by age or input consumption at age. Multiplied by pvalue and fday to scale maximum consumption to the number of days in a year that foraging occurs.
Stomach proportion by numbers for each predator, prey, predator age, prey age combination. Can also be year specific by including the column, "Year"
Stomach proportion by weight for each predator, prey, predator age, prey age combination. Can also be year specific by including the column, "Year"
fleet_control: controls for survey and fisheries data
Name of survey or fishery
Index of survey/fishery ACROSS species
0 or 'Off' = Do not estimate; 1 = 'Fishery'; 2 = 'Survey'
Species number
index to use if selectivities of different surveys are to be the same
Selectivity to use for the species: 0 = "Fixed"; 1 = "Logistic"; 2 = "NonParametric" sensu Ianelli et al 2018; 3 = "DoubleLogistic"; 4 = "DescendingLogistic"; 5 = "Hake" non-parametric sensu Taylor et al; 6 = "2DAR1"; 7 = "3DAR1" sensu Cheng et al 2024; 8 = "DoubleNormal" (Gaussian ascending and descending limbs blended at a common peak — similar to SS3 pattern 24). Parameters: sel_inf[1] = peak bin/length; sel_inf[2] = logit(right_floor), right-tail floor analogous to SS3 P6/end_logit (logit=-10 → dome-shaped, logit=+10 → logistic ascending-only); log_sel_slp[1] = log(sigma_ascending); log_sel_slp[2] = log(sigma_descending). Supports the same time-varying modes as DoubleLogistic (IID, Block, RandomWalk).
"Age" or "Length".
Number of ages to estimate non-parametric selectivity.
Whether a time-varying selectivity should be estimated for logistic, double logistic selectivity, or descending logistic. 0 = "Off", 1 = "IID" penalized deviates given sel_sd_prior or random effect, 2 = "AR1" (TODO), 3 = "Block" time blocks with no penalty, 4 = "RandomWalk" following Dorn, 5 = "RandomWalkAscending" on ascending portion of double logistic only.
The fixed or initial sd to use for time varying selectivity.
Age/length bin at which selectivity is non-zero
Ages below this will be grouped to this age for composition data. For example, if set to 2, comp data for age 2 will include 1 and 2 year olds.
Ages above this will be grouped to this age for composition data. For example, if set to 9 for a species with 10 ages, comp data for age 9 will include 9 and 10 year olds.
Is the observation in weight (kg) set as 1, if the observation is in numbers caught, set as 2
Weight-at-age (weight) index to use for calculation of derived quantities
Age transition matrix (e.g. growth trajectory) index to use for derived quantities to convert age to length
index to use if catchability coefficients are to be set the same
Estimate catchability? (0 or "Fixed" = fixed at prior; 1 or "Estimated" = Estimate single parameter; 2 or "Estimated-with-prior" = Estimate single parameter with prior; 3 or "Analytical" = Estimate analytical q from Ludwig and Walters 1994; - 4 = Estimate power equation; - 5 or "Environmental" = Linear equation log(q_y) = q_mu + beta * index_y; 6 or "AR1" = annual AR1 catchability deviates are fit to environmental index sensu Rogers et al 2025)
Starting value or fixed value for catchability
Variance of q prior: dnorm (log_q, log_q_prior, q_sd_prior)
Whether a time-varying q should be estimated. 0 = "Off", 1 = "IID" penalized deviate or random effect, 2 = "AR1" (TODO), 3 = "Block" time blocks with no penalty; 4 = "RandomWalk" random walk from mean following Dorn 2018 (dnorm(q_y - q_y-1, 0, sigma). If Catchability = 5 or 6, this determines the environmental index to be used in the equation log(q_y) = q_mu + beta * index_y
The sd to use for the random walk of time varying q if set to 1
Estimate survey variance (0 = use CV from index_data, 1 = yes, 2 = analytically estimate following (Ludwig and Walters 1994)
Starting value to be used if Estimate_sigma_index = 1
Estimate fishery variance (0 = use CV from index_data, 1 = yes, 2 = analytically estimate following (Ludwig and Walters 1994)
Starting value to be used if Estimate_sigma_catch = 1
Composition weights to be used for multinomial likelihood. These are multiplied. After running model, these will update to McAllister & Ianelli 1997 weights using the harmonic mean.
Units used for survey: 1 = kg; 2 = numbers
The proportion of future fishing mortality assigned to this fleet
sex codes: 0=combined; 1=use female only; 2=use male only; 3 = joint female and male
Function to build parameter bounds based on Holsman et al 2015 and Kinzey and Punt 2010
build_bounds(param_list = NULL, data_list)build_bounds(param_list = NULL, data_list)
param_list |
Parameter list object built from |
data_list |
a Rceattle data object |
List of upper and lower bounds
Specify the growth model for Rceattle
build_growth(fun = "empirical", growth_age_L1 = NA, linkages = NULL)build_growth(fun = "empirical", growth_age_L1 = NA, linkages = NULL)
fun |
Growth function. Either a string (GROWTH_FUNS:
|
growth_age_L1 |
Von Bertalanffy / Richards anchor age (the age at
which mean length equals |
linkages |
Optional named list of |
A list of switches defining the growth model.
## Not run: # Sex-specific von Bertalanffy with temperature on K, by species + sex build_growth( fun = "vonBertalanffy", # or fun = 1 linkages = list( K = linkage_spec( formula = ~ temp, by = ~ species + sex, priors = list(temp = normal(0, 1)) ) ) ) ## End(Not run)## Not run: # Sex-specific von Bertalanffy with temperature on K, by species + sex build_growth( fun = "vonBertalanffy", # or fun = 1 linkages = list( K = linkage_spec( formula = ~ temp, by = ~ species + sex, priors = list(temp = normal(0, 1)) ) ) ) ## End(Not run)
Defines the harvest control rule and associated reference points used in the Rceattle model.
build_hcr( HCR = 0, DynamicHCR = FALSE, Ftarget = 0.4, Flimit = 0.35, Ptarget = 0.4, Plimit = 0, Alpha = 0.05, Pstar = 0.45, Sigma = 0.5, Fmult = 1, HCRorder = 1 )build_hcr( HCR = 0, DynamicHCR = FALSE, Ftarget = 0.4, Flimit = 0.35, Ptarget = 0.4, Plimit = 0, Alpha = 0.05, Pstar = 0.45, Sigma = 0.5, Fmult = 1, HCRorder = 1 )
HCR |
Harvest control rule to use. Accepts an integer or equivalent string alias. Default = 0. See Details for the full list of available options. |
DynamicHCR |
TRUE/FALSE. Whether to use static or dynamic reference points (default = FALSE). |
Ftarget |
Target fishing mortality rate (yr^-1) (SPR or depletion based) or input F for projections. For example, if Ftarget is spr F40%, enter 0.40. |
Flimit |
Limit fishing mortality rate (yr^-1) (SPR or depletion based). For example, if Flimit is spr F35%, enter 0.35. |
Ptarget |
Target spawning-stock biomass as a percentage of static or dynamic spawning-stock-biomass at F = 0 (accounts for recruitment). |
Plimit |
Limit spawning-stock biomass as a percentage of static or dynamic spawning-stock-biomass at F = 0 (accounts for recruitment). |
Alpha |
Parameter used in NPFMC Tier 3 HCR. |
Pstar |
Quantile used for uncertainty buffer given |
Sigma |
Standard deviation used for normally distributed uncertainty buffer given |
Fmult |
Multiplier on the target F (default = 1). Used to scale the target fishing mortality following NEFSC convention. |
HCRorder |
For multi-species models, the order in which to project fishing (e.g., predators first, then prey). |
Harvest control rule formulations currently implemented in Rceattle:
hcr = 0 or "NoFishing": No catch. Estimate the hindcast.
hcr = 1 or "CMSY": CMSY. Maximize catch across all species simultaneously. CMSY can be constrained such that depletion does not fall below Plimit.
hcr = 2 or "ConstantF": Constant input F set at Ftarget for each species (vector or single F). SPR (single-species only) based Flimit is specified via Flimit.
hcr = 3 or "ConstantFSSB": F that achieves Ftarget% of SSB0 in the end of the projection.
hcr = 4 or "ConstantFSPR": Constant Fspr set at Ftarget for each species. Can be multiplied by Fmult following NEFSC.
hcr = 5 or "NPFMC": The North Pacific Fishery Management Council (NPFMC) Tier 3 spawner-per-recruit-based harvest control rule:
Stock status:
Stock status:
Stock status: or
hcr = 6 or "PFMC": An HCR based on the The Pacific Fishery Management Council (PFMC) category 1 40-10 annual catch limit (ABC) harvest control rule assuming Fofl is normally distributed with a standard deviation (sigma) = 0.5 and an uncertainty quantile buffer (P*) of 0.45 (PFMC 2020). The model uses Fspr if single-species or F that achieves X% of SSB0 for multi-species. Target biological reference points are calculated based on the normal cumulative distribution function (Phi(quantile,mean,standard deviation)), P*, and sigma as follows:
Stock status:
Stock status:
Stock status:
hcr = 7 or "SESSF": An HCR based on the The Southern and Eastern Scalefish and Shark Fishery (SESSF) spawner-per-recruit-based Tier 1 harvest control rule where F_Limit=F_(20%), B_Limit=SB_20, F_Target (AFMA 2017) calculated as follows:
Stock status:
Stock status:
Stock status:
NOTE: only HCRs 1, 2, 3, and 6 will work in multi-species mode.
A list containing the harvest control rule and associated biological reference points.
Reads a data list and map to update the map argument based on the HCR specified in build_hcr
build_hcr_map( data_list, map, debug = FALSE, all_params_on = FALSE, HCRiter = 1 )build_hcr_map( data_list, map, debug = FALSE, all_params_on = FALSE, HCRiter = 1 )
data_list |
an Rceattle data_list |
map |
a map object created from |
debug |
logical. If TRUE, turns off all parameters for debugging (default = FALSE). |
all_params_on |
logical. If TRUE, leaves all hindcast parameters turned on (default = FALSE). |
HCRiter |
for multi-species models, the order in which to project fishing (e.g. predators first, then prey) |
a list of map arguments for each parameter
Define M1 specifications
build_M1( M1_model = 0, M1_re = 0, updateM1 = FALSE, M1_use_prior = FALSE, M2_use_prior = FALSE, M_prior = 0.4, M_prior_sd = 0.35, M1_indices = NA, linkages = NULL )build_M1( M1_model = 0, M1_re = 0, updateM1 = FALSE, M1_use_prior = FALSE, M2_use_prior = FALSE, M_prior = 0.4, M_prior_sd = 0.35, M1_indices = NA, linkages = NULL )
M1_model |
Vector or scalar specifying the M1 structural fixed- effects model. Either an integer code or the equivalent string alias (both forms are accepted; the integer code is canonical):
|
M1_re |
Vector or scalar specifying the M1 random-effects
model. Either an integer code or the equivalent string alias:
|
updateM1 |
If using initial parameters, use M1 fixed effects
from data ( |
M1_use_prior |
Vector or scalar; if |
M2_use_prior |
Vector or scalar; if |
M_prior |
Mean (natural-scale) of the lognormal prior on M. |
M_prior_sd |
SD (log-scale) of the lognormal prior on M. |
M1_indices |
Soft-deprecated. Vector of column indices into
|
linkages |
Optional named list of |
A list of switches for defining the M1 model.
## Not run: # Sex/age-invariant M with a temperature linkage on M1 build_M1( M1_model = "sex_age_invariant", linkages = list( M1 = linkage_spec( formula = ~ temp, by = ~ species, priors = list(temp = normal(0, 0.5)) ) ) ) ## End(Not run)## Not run: # Sex/age-invariant M with a temperature linkage on M1 build_M1( M1_model = "sex_age_invariant", linkages = list( M1 = linkage_spec( formula = ~ temp, by = ~ species, priors = list(temp = normal(0, 0.5)) ) ) ) ## End(Not run)
Orchestrates the building of the TMB map object by calling specialized helper functions for each parameter block (Recruitment, M1, Predation, Selectivity, Catchability, etc.).
build_map( data_list, params, debug = FALSE, random_rec = FALSE, random_sel = FALSE )build_map( data_list, params, debug = FALSE, random_rec = FALSE, random_sel = FALSE )
data_list |
an Rceattle data_list |
params |
A parameter list created from |
debug |
Logical. If TRUE, sets all map values to NA except the dummy parameter, running the model without parameter estimation. |
random_rec |
Logical. If TRUE, treats recruitment deviations as random effects,
meaning the variance parameter ( |
random_sel |
Logical. If TRUE, treats selectivity deviations as random effects,
meaning the variance parameter ( |
A list containing the factorized TMB map (mapFactor) and the
original map matrix/array list (mapList).
Maps survey catchability base parameters (index_log_q),
time-varying deviations (index_q_dev), and environmental linkages
(index_q_beta, index_q_rho).
build_map_catchability(map_list, data_list, nyrs_hind)build_map_catchability(map_list, data_list, nyrs_hind)
map_list |
The current TMB map list. |
data_list |
The data list containing model settings. |
nyrs_hind |
Number of historical years. |
Updated map_list.
Sets all parameters in the map list to NA, except the
dummy parameter, for use in debug or testing modes.
build_map_debug(map_list, debug)build_map_debug(map_list, debug)
map_list |
The current TMB map list. |
debug |
Logical. If TRUE, debug mode is activated. |
Updated map_list.
Maps fishing mortality parameters (log_F) and related targets.
Also maps data weighting parameters (catch_log_sd, comp_weights, caal_weights).
build_map_f_and_data_weights(map_list, data_list, nyrs_hind)build_map_f_and_data_weights(map_list, data_list, nyrs_hind)
map_list |
The current TMB map list. |
data_list |
The data list containing model settings. |
nyrs_hind |
Number of historical years. |
Updated map_list.
Turns off (sets to NA) most population and fleet parameters for
species where the dynamics are fixed (estDynamics > 0).
build_map_fixed_natage(map_list, data_list)build_map_fixed_natage(map_list, data_list)
map_list |
The current TMB map list. |
data_list |
The data list containing model settings. |
Updated map_list.
Maps the fixed parameters (log_growth_pars) and the random effects
parameters (log_growth_par_devs, growth_dev_log_sd, growth_rho) based on
growth_model and growth_re settings.
build_map_growth(map_list, data_list, nyrs_hind)build_map_growth(map_list, data_list, nyrs_hind)
map_list |
The current TMB map list. |
data_list |
The data list containing model settings. |
nyrs_hind |
Number of historical years. |
Updated map_list.
Maps the fixed parameters (log_M1) and the random effects
parameters (log_M1_dev, M1_dev_log_sd, M1_rho) based on
M1_model and M1_re settings.
build_map_m1(map_list, data_list, nyrs_hind)build_map_m1(map_list, data_list, nyrs_hind)
map_list |
The current TMB map list. |
data_list |
The data list containing model settings. |
nyrs_hind |
Number of historical years. |
Updated map_list.
Maps predation suitability parameters (log_gam_a, log_gam_b,
log_phi) and diet weight parameters based on msmMode and
suitMode.
build_map_predation(map_list, data_list)build_map_predation(map_list, data_list)
map_list |
The current TMB map list. |
data_list |
The data list containing model settings. |
Updated map_list.
Maps the recruitment deviations (rec_dev, init_dev),
stock-recruitment parameters (rec_pars) and Rec dev variances (R_log_sd)
see build_srr() for options,
build_map_recruitment(map_list, data_list, nyrs_hind, nyrs_proj, random_rec)build_map_recruitment(map_list, data_list, nyrs_hind, nyrs_proj, random_rec)
map_list |
The current TMB map list. |
data_list |
The data list containing model settings. |
nyrs_hind |
Number of historical years. |
nyrs_proj |
Total number of years (historical + projected). |
random_rec |
Logical indicating if recruitment deviations are random effects. |
Updated map_list.
Maps base selectivity parameters (log_sel_slp, sel_inf,
sel_coff) and time-varying deviations, based on Selectivity
and Time_varying_sel settings in fleet_control.
Selectivity in fleet_control of the data determines shape of selectivity curve:
0 = "Fixed" empirical selectivity provided in emp_sel in the data
1 = "Logistic"
2 = "NonParametric" selecitivty sensu Ianelli et al 2018
3 = "DoubleLogistic"
4 = "DescendingLogistic"
5 = "Hake" non-parametric selectivity sensu Taylor et al 2014 (Hake)
6 = "2DAR1" across age x year
7 = "3DAR1" across age x cohort x year (Cheng et al 2024)
8 = "DoubleNormal" Gaussian ascending/descending limbs blended at peak (analogous to SS3 pattern 24).
Parameters: sel_inf[1] = peak; sel_inf[2] = logit(right_floor) (right-tail floor, SS3 P6/end_logit);
log_sel_slp[1] = log(sigma_asc); log_sel_slp[2] = log(sigma_desc).
right_floor→0: dome-shaped; right_floor→1: logistic ascending only.
N_sel_bins Number of age/length bins to estimate non-parametric selectivity when Selectivity = 2 or 5. Not used otherwise
Time_varying_sel determines if time-varying selectivity should be estimated for logistic, double logistic selectivity, descending logistic , non-parametric, or hake (Selectivity = 1, 2, 3, 4, or 5).
0 = 'None'
1 = 'IID' penalized deviates given sel_sd_prior
3 = 'Block' time blocks with no penalty
4 = 'RandomWalk' random walk following Dorn
5 = 'RandomWalkAscending' random walk on ascending portion of double logistic only.
random_sel in fit_mod treats random deviates and random walk parameters as random effects, estimating the variance.
build_map_selectivity(map_list, data_list, nyrs_hind, random_sel)build_map_selectivity(map_list, data_list, nyrs_hind, random_sel)
map_list |
The current TMB map list. |
data_list |
The data list containing model settings. |
nyrs_hind |
Number of historical years. |
random_sel |
Logical indicating if selectivity deviations are random effects. |
Updated map_list.
Function to read a TMB cpp file and construct parameter list object for Rceattle
build_params(data_list)build_params(data_list)
data_list |
an Rceattle data_list |
a list of map arguments for each parameter
Stock recruitment relationships currently implemented in Rceattle:
srr_fun = 0 or "mean": No stock recruit relationship. Recruitment is a function of R0 and annual deviates (i.e. steepness = 0.99).
srr_fun = 2 or "BevertonHolt": Beverton-holt stock-recruitment relationship
srr_fun = 4 or "Ricker": Ricker stock-recruitment relationship
When srr_pred_fun > 0 and srr_fun = 0 recruitment in the hindcast is estimated as in srr_fun = 0
, but an additional stock recruitment relationship defined by srr_pred_fun is estimated between srr_hat_styr and srr_hat_endyr and treated as an additional penalty. The stock recruitment relationship defined by srr_pred_fun is then used in the projection.
build_srr( srr_fun = 0, srr_pred_fun = srr_fun, proj_mean_rec = TRUE, srr_mse_switchyr = NULL, srr_hat_styr = NULL, srr_hat_endyr = NULL, srr_est_mode = 1, srr_prior = 4, srr_prior_sd = 1, srr_indices = NA, Bmsy_lim = NA, linkages = NULL )build_srr( srr_fun = 0, srr_pred_fun = srr_fun, proj_mean_rec = TRUE, srr_mse_switchyr = NULL, srr_hat_styr = NULL, srr_hat_endyr = NULL, srr_est_mode = 1, srr_prior = 4, srr_prior_sd = 1, srr_indices = NA, Bmsy_lim = NA, linkages = NULL )
srr_fun |
Stock recruit function to be used for hindcast estimation of Rceattle (see @description below). Default = 0 |
srr_pred_fun |
stock recruit function for projection, reference points, and penalties to be used for Rceattle (see below). When |
proj_mean_rec |
Project the model using: 0 = mean recruitment (average R of hindcast) or 1 = SRR(omega, srr_devs) |
srr_mse_switchyr |
is used for MSEs to deal with AMAK and Jim Ianelli's estimation where a stock recruit function is estimated as an additional penalty (srr_fun = 0 and srr_pred_fun > 0). It tells the model in what year to switch to the stock recruit function. |
srr_hat_styr |
Integer. The first year used for estimating the recruitment function as an additional penalty. It will add additional penalties sensu AMAK and Jim Ianelli's pollock model when |
srr_hat_endyr |
Integer. The last year used for estimating the recruitment function as an additional penalty. It will add an additional penalties sensu AMAK and Jim Ianelli's pollock model when |
srr_est_mode |
Switch to determine estimation mode. 0 = fix alpha to prior mean, 1 = freely estimate R0, alpha, and/or beta (default), 2 = use lognormally distributed prior for alpha (Ricker) or steepness (Beverton), 3 = use beta distributed prior for steepness (Beverton) given mean and sd. |
srr_prior |
mean for normally distributed prior for stock-recruit parameter |
srr_prior_sd |
Prior standard deviation for stock-recruit parameter |
srr_indices |
Soft-deprecated. Use the |
Bmsy_lim |
Upper limit for Ricker based SSB-MSY (e.g 1/Beta). Will add a likelihood penalty if beta is estimated above this limit. Default |
linkages |
Optional named list of |
A list containing the stock recruitment relationship settings
Function to load .RDs files from MSE runs
check_mse(dir = NULL, file = NULL)check_mse(dir = NULL, file = NULL)
dir |
Directory used to save files from |
file |
file name used to save files from |
list of MSE simulations/run
Function to clean data prior to Rceattle runs
clean_data(data_list)clean_data(data_list)
data_list |
Rceattle data list |
Extract estimated parameters from an Rceattle fit
## S3 method for class 'Rceattle' coef(object, ...)## S3 method for class 'Rceattle' coef(object, ...)
object |
An object of class |
... |
Currently unused. |
A named numeric vector of estimated fixed-effect parameters
(the optimizer's par). Returns NULL if the model was not
estimated.
Combine data sets. Will use the env_data data set from data_set1 and diet data will have to be updated.
combine_data(data_list1 = NULL, data_list2 = NULL)combine_data(data_list1 = NULL, data_list2 = NULL)
data_list1 |
Rceattle data_list 1 |
data_list2 |
Rceattle data_list 2 |
Function to evaluate the simulation performance with regard to bias using the median relative error (MRE) and precision using the coefficient of variation.
compare_sim(operating_mod, simulation_mods, object = "quantities")compare_sim(operating_mod, simulation_mods, object = "quantities")
operating_mod |
CEATTLE model object exported from |
simulation_mods |
List of CEATTLE model objects exported from |
object |
character string specifying which part of the model to compare (default = "quantities") |
A data frame summarising simulation performance metrics
Runs the post-fit convergence battery and returns a single structured
object. Each check yields a record with a common schema
(id, tier, severity, message, data);
severity is one of "OK", "NOTE", "WARN",
"FAIL". The object's status is the worst severity present.
convergence_diagnostics(object, ...)convergence_diagnostics(object, ...)
object |
An object of class |
... |
Currently unused. |
fit_mod() runs this automatically and attaches the result as
fit$convergence; call convergence_diagnostics() directly to
re-run it on any fit. Checks cover the optimizer gradient, Hessian
positive-definiteness and conditioning, parameters on bounds, phasing, and
parameter estimability.
An object of class "Rceattle_convergence": a list with
status (overall worst severity) and checks (named list of
records).
A fitted Rceattle model object for the multispecies run of CEATTLE
for the Eastern Bering Sea (walleye pollock, Pacific cod, arrowtooth
flounder).
EBS_ms_runEBS_ms_run
An object of class Rceattle.
A fitted Rceattle model object for the single-species run of CEATTLE
for the Eastern Bering Sea with natural mortality estimated.
EBS_ss_M_runEBS_ss_M_run
An object of class Rceattle.
A fitted Rceattle model object for the single-species run of CEATTLE
for the Eastern Bering Sea (walleye pollock, Pacific cod, arrowtooth
flounder) without estimating natural mortality.
EBS_ss_runEBS_ss_run
An object of class Rceattle.
fit_mod()
fit_mod() carries roughly a dozen optimizer- and reporting-related
arguments (bias.correct, getsd, loopnum, newtonsteps, ...).
That is a lot of surface area when the user mostly cares about
"what model am I fitting" rather than "how is it being fit."
fit_control() collects those knobs into a single object so calls
to fit_mod() can stay focused on the model spec:
fit_control( bias.correct = FALSE, getsd = TRUE, getJointPrecision = TRUE, getReportCovariance = FALSE, use_gradient = TRUE, rel_tol = 1, loopnum = 5, newtonsteps = 0, phase = FALSE, TMBfilename = NULL, verbose = 1, nlminb_control = list(eval.max = 1e+09, iter.max = 1e+09, trace = 0) )fit_control( bias.correct = FALSE, getsd = TRUE, getJointPrecision = TRUE, getReportCovariance = FALSE, use_gradient = TRUE, rel_tol = 1, loopnum = 5, newtonsteps = 0, phase = FALSE, TMBfilename = NULL, verbose = 1, nlminb_control = list(eval.max = 1e+09, iter.max = 1e+09, trace = 0) )
bias.correct |
logical. If |
getsd |
logical. If |
getJointPrecision |
logical. Return the full Hessian of fixed
and random effects. Default |
getReportCovariance |
logical. Return the variance-covariance
of |
use_gradient |
logical. Use the analytic gradient during
phasing. Default |
rel_tol |
Numeric tolerance used to flag discontinuous
likelihood warnings (compares the TMB and |
loopnum |
Integer. Number of times to re-start optimization
( |
newtonsteps |
Integer. Number of extra Newton steps to take
after optimization (alternative to |
phase |
|
TMBfilename |
Optional character. Path (without |
verbose |
|
nlminb_control |
A list of control parameters passed to
|
fit <- fit_mod( data_list = BS2017SS, msmMode = 0, fit_control = fit_control(loopnum = 1, getsd = FALSE) )
Pass the result via the fit_control argument to fit_mod(). When
supplied, the values in the fit_control object override the
corresponding individual arguments to fit_mod(). Individual
arguments are kept for backward compatibility.
A list of class "Rceattle_fit_control".
# Quick-and-dirty fit: skip sdreport, single optimizer pass ctl <- fit_control(getsd = FALSE, loopnum = 1) # Production fit with bias correction and joint precision ctl <- fit_control(bias.correct = TRUE, getJointPrecision = TRUE)# Quick-and-dirty fit: skip sdreport, single optimizer pass ctl <- fit_control(getsd = FALSE, loopnum = 1) # Production fit with bias correction and joint precision ctl <- fit_control(bias.correct = TRUE, getJointPrecision = TRUE)
This function estimates population parameters of CEATTLE using maximum likelihood in TMB.
fit_mod( data_list = NULL, inits = NULL, map = NULL, bounds = NULL, file = NULL, estimateMode = 0, projection_uncertainty = FALSE, random_rec = FALSE, random_q = FALSE, random_sel = FALSE, HCR = build_hcr(), niter = 3, recFun = build_srr(), M1Fun = build_M1(), growthFun = build_growth(), msmMode = 0, avgnMode = 0, initMode = "NonEquilibrium", suitMode = 0, suit_styr = NULL, suit_endyr = NULL, fit_control = NULL, ... )fit_mod( data_list = NULL, inits = NULL, map = NULL, bounds = NULL, file = NULL, estimateMode = 0, projection_uncertainty = FALSE, random_rec = FALSE, random_q = FALSE, random_sel = FALSE, HCR = build_hcr(), niter = 3, recFun = build_srr(), M1Fun = build_M1(), growthFun = build_growth(), msmMode = 0, avgnMode = 0, initMode = "NonEquilibrium", suitMode = 0, suit_styr = NULL, suit_endyr = NULL, fit_control = NULL, ... )
data_list |
A data list read in via |
inits |
(Optional) A named list of initial parameter values, as returned by
|
map |
(Optional) A map object from |
bounds |
(Optional) A bounds object from |
file |
(Optional) Filename where files will be saved. If NULL, no file is saved. |
estimateMode |
0 = Fit the hindcast model and projection with HCR specified via |
projection_uncertainty |
logical. If TRUE, accounts for hindcast parameter uncertainty in projections when using an HCR. Default is FALSE for speed. |
random_rec |
logical. If TRUE, treats recruitment deviations as random effects using the laplace approximation.The default is FALSE. |
random_q |
logical. If TRUE, treats annual catchability deviations as random effects using the laplace approximation.The default is FALSE. |
random_sel |
logical. If TRUE, treats annual selectivity deviations as random effects using the laplace approximation.The default is FALSE. |
HCR |
HCR list object from |
niter |
Number of iterations for multispecies model |
recFun |
The stock recruit-relationship parameterization from |
M1Fun |
M1 parameterizations and priors. Use |
growthFun |
The weight-at-age parameterization from |
msmMode |
The predation mortality functions to used. Defaults to no predation mortality used. |
avgnMode |
The average abundance-at-age approximation to be used for predation mortality equations. 0 (default) is the |
initMode |
how the population is initialized. 0 = initial age-structure estimated as free parameters; 1 = equilibrium age-structure estimated out from R0 + mortality (M1); 2 = non-equilibrium age-structure estimated out from R0, mortality (M1), and initial population deviates; 3 = non-equilibrium age-structure estimated out from initial fishing mortality (Finit), R0, mortality (M1), and initial population deviates; 4 = non-equilibrium age-structure version 2 where initial fishing mortality (Finit) scales R0. |
suitMode |
Switch for suitability derivation for each predator (single value or vector). 0 = empirical based on diet data (Holsman et al. 2015), 1 = length-based gamma suitability, 2 = weight-based gamma suitability, 3 = length-based lognormal suitability, 4 = weight-based lognormal suitability, 5 = length-based normal suitability, 6 = weight-based normal suitability. |
suit_styr |
Integer. The first year used to calculate mean suitability. Defaults to $styr$ in $data_list$. Used when diet data were sampled from a subset of years. |
suit_endyr |
Integer. The last year used to calculate mean suitability. Defaults to $endyr$ in $data_list$. Used when diet data were sampled from a subset of years. |
fit_control |
A list returned by |
... |
Deprecated optimizer / sdreport / phasing arguments
(e.g. |
CEATTLE is an age-structured population dynamics model that can be fit with or without predation mortality. The default is to exclude predation mortality by setting msmMode to 0. Predation mortality can be included by setting msmMode with the following options:
0. Single species mode
1. Holsman et al. 2015 predation based on multi-species virtual population analysis (MSVPA) based predation formation.
2. MSVPA Holling Type III
Values 3 through 9 (Kinzey & Punt 2009 functional responses –
Holling Type I/II/III, predator interference, predator preemption,
Hassell-Varley, Ecosim) are blocked at runtime by data_check()
because the implementations have not been validated against the
current parameter set. See src/TMB/predation.hpp.
A list of class "Rceattle" including:
data_list: List of data inputs
initial_params: List of starting parameters
bounds: Parameter bounds used for estimation
map: List of map used in TMB
obj: TMB model object
opt: Optimized model object from nlminb
sdrep: Object of class sdreport exported by TMB including the standard errors of estimated parameters
estimated_params: List of estimated parameters
quantities: Derived quantities from CEATTLE
run_time: Model run time
data(BS2017SS) ss_run <- fit_mod( data_list = BS2017SS, estimateMode = 0, msmMode = 0, fit_control = fit_control(phase = FALSE, verbose = 0) )data(BS2017SS) ss_run <- fit_mod( data_list = BS2017SS, estimateMode = 0, msmMode = 0, fit_control = fit_control(phase = FALSE, verbose = 0) )
A data list containing inputs for a multispecies CEATTLE model fit to
three groundfish species on Georges Bank. See BS2017SS for
format details.
GeorgesBank3sppGeorgesBank3spp
A list with the same structure as BS2017SS.
This function calculates a probability transition matrix that defines the probability of a fish of a given age belonging to specific length bins. It supports Von Bertalanffy and Richards growth models and includes a Stock Synthesis (SS) style plus-group correction.
get_growth_matrix_r( fracyr, nsex_sp, nages_sp, nlengths_sp, nyrs, lengths_sp, minage_sp, maxage_sp, growth_params_sp, growth_log_sd_sp, growth_model_sp )get_growth_matrix_r( fracyr, nsex_sp, nages_sp, nlengths_sp, nyrs, lengths_sp, minage_sp, maxage_sp, growth_params_sp, growth_log_sd_sp, growth_model_sp )
fracyr |
Numeric. Fraction of the year (0 = Jan 1st). |
nsex_sp |
Integer. Number of sexes for the species. |
nages_sp |
Integer. Number of age classes. |
nlengths_sp |
Integer. Number of length bins. |
nyrs |
Integer. Number of years in the simulation. |
lengths_sp |
Vector. Boundaries of the length bins. |
minage_sp |
Numeric. The reference age (L1) for growth estimation. |
maxage_sp |
Numeric. The age at which growth enters the asymptotic phase. |
growth_params_sp |
Array. Dimensions (sex, yr, 4). Params: K, L1, Linf, Richards m. |
growth_log_sd_sp |
Array. Dimensions (sex, 2). Log-SD of length: 1st param is SD at minage, 2nd param is SD at maxage. |
growth_model_sp |
Integer. 1 = Von Bertalanffy, 2 = Richards. |
A 4D array of probabilities with dimensions (sex, age, length, year).
Converts a growth matrix (length-at-age probabilities) into mean weight-at-age using a length-weight relationship (W = a * L^b).
get_weight_at_age_r( nsex_sp, nages_sp, nlengths_sp, nyrs, lengths_sp, length_at_age, growth_matrix, lw_params )get_weight_at_age_r( nsex_sp, nages_sp, nlengths_sp, nyrs, lengths_sp, length_at_age, growth_matrix, lw_params )
nsex_sp |
Integer. Number of sexes. |
nages_sp |
Integer. Number of age classes. |
nlengths_sp |
Integer. Number of length bins. |
nyrs |
Integer. Number of years. |
lengths_sp |
Vector. Boundaries of the length bins. |
length_at_age |
Array. Mean length at age from get_growth_matrix_r. |
growth_matrix |
Array. 4D array (sex, age, length, year) from get_growth_matrix_r. |
lw_params |
Array. Dimensions (sex, yr, 2). Params: 1st is alpha (a), 2nd is beta (b). |
The function calculates midpoints for length bins to avoid bias. For the first bin, it assumes the width is equal to the second bin's width. The final weight-at-age is the expected value across all length bins for that age.
A 3D array of mean weights with dimensions (sex, age, year).
A data list containing inputs for a single-species CEATTLE model fit to
Gulf of Alaska groundfish data through 2018. See BS2017SS
for format details.
GOA2018SSGOA2018SS
A list with the same structure as BS2017SS.
A data list containing inputs for a single-species CEATTLE model fit to
Gulf of Alaska arrowtooth flounder data. See BS2017SS
for format details.
GOAatfGOAatf
A list with the same structure as BS2017SS.
A data list containing inputs for a single-species CEATTLE model fit to
Gulf of Alaska arrowtooth flounder data through 2023. See
BS2017SS for format details.
GOAatf2023GOAatf2023
A list with the same structure as BS2017SS.
A data list containing inputs for a single-species CEATTLE model fit to
Gulf of Alaska Pacific cod data. See BS2017SS for format
details.
GOAcodGOAcod
A list with the same structure as BS2017SS.
A data list containing inputs for a single-species CEATTLE model fit to
Gulf of Alaska walleye pollock data. See BS2017SS for
format details.
GOApollockGOApollock
A list with the same structure as BS2017SS.
A list containing biomass, spawning stock biomass, and recruitment reference values from the 2018 Gulf of Alaska Stock Assessment and Fishery Evaluation (SAFE) report.
GOAsafe2018GOAsafe2018
A list with components:
Total biomass time series
Spawning stock biomass time series
Recruitment time series
Run's the Rceattle model at initial values that are +- N(0, sd) from the initial parameters.
jitter( Rceattle = NULL, njitter = 50, sd = 0.2, phase = FALSE, seed = 123, cores = NULL )jitter( Rceattle = NULL, njitter = 50, sd = 0.2, phase = FALSE, seed = 123, cores = NULL )
Rceattle |
an Rceattle model fit using |
njitter |
the number of jitters to run |
sd |
standard deviation for jitter (default = 0.2) |
phase |
as in |
seed |
random number seed. Each jitter |
cores |
Number of cores to use for parallel jitters. Default
|
a list of Rceattle models
data(BS2017SS) ss_run <- fit_mod(data_list = BS2017SS, inits = NULL, file = NULL, estimateMode = 0, random_rec = FALSE, msmMode = 0, avgnMode = 0, phase = FALSE, verbose = 0) jitters <- jitter(ss_run, njitter = 10)data(BS2017SS) ss_run <- fit_mod(data_list = BS2017SS, inits = NULL, file = NULL, estimateMode = 0, random_rec = FALSE, msmMode = 0, avgnMode = 0, phase = FALSE, verbose = 0) jitters <- jitter(ss_run, njitter = 10)
Capture a linkage specification
linkage_spec( formula, param = NULL, data = NULL, by = ~species, species = NULL, sex = NULL, link = "log", init = NULL, bounds = NULL, priors = NULL, re_group = NA_character_, est_phase = 1L )linkage_spec( formula, param = NULL, data = NULL, by = ~species, species = NULL, sex = NULL, link = "log", init = NULL, bounds = NULL, priors = NULL, re_group = NA_character_, est_phase = 1L )
formula |
one-sided R formula whose RHS describes the linear
predictor for |
param |
target parameter name on the natural scale
(e.g. |
data |
(Optional) data frame for formula validation. Currently
validation happens at materialization time inside |
by |
one-sided formula naming stratifying factors that should
each get their own coefficients. Allowed names are |
species |
optional integer vector of 1-based species ids that
this spec applies to. |
sex |
optional vector of sex ids that this spec applies to.
May be supplied as integers ( |
link |
link function relating the linear predictor to the
natural-scale target parameter. One of |
init |
optional named numeric vector of initial values keyed by
the design-matrix column name (e.g.
|
bounds |
optional named list of |
priors |
optional named list whose entries are
Rceattle_priors objects, keyed by design-matrix column name.
Inside this argument the unprefixed shorthand |
re_group |
optional character: name of a random-effect grouping
for these coefficients. |
est_phase |
optional integer estimation phase. Default |
An Rceattle_linkage_spec object.
Function to load .RDs files from MSE runs
load_mse(dir = NULL, file = NULL, exclude = NULL, include_em = TRUE)load_mse(dir = NULL, file = NULL, exclude = NULL, include_em = TRUE)
dir |
Directory used to save files from |
file |
file name used to save files from |
exclude |
index of MSE simulations not to load |
include_em |
whether the EMs should be loaded or not (default = TRUE) |
list of MSE simulations/run
Returns the joint negative-objective from nlminb, sign-flipped, as
a "logLik" object. df is the number of estimated fixed-effect
parameters. The nobs attribute is intentionally omitted: counting
"observations" in a stock assessment likelihood (with composition
cells, indices, catches, and priors) is not well-defined, so
stats::AIC() works (uses df) while stats::BIC() does not.
## S3 method for class 'Rceattle' logLik(object, ...)## S3 method for class 'Rceattle' logLik(object, ...)
object |
An object of class |
... |
Currently unused. |
An object of class "logLik", or NULL if the model was
not estimated.
Model average of derived quantities
model_average(Rceattle, weights = NULL, uncertainty = FALSE, nboot = 10000)model_average(Rceattle, weights = NULL, uncertainty = FALSE, nboot = 10000)
Rceattle |
list of Rceattle model objects |
weights |
vector of weights to be used for weighting models |
uncertainty |
TRUE/FALSE Sample uncertainty across derived quantities using weighted bootstrap from the asymptotic distribution of MLEs |
nboot |
Number of bootstraps taken from asymptotic distribution of MLEs. Default = 10000 |
an Rceattle object with derived quantities weighted by the specified weights. The length of the derived quantities spans the years which overlap across all models.
Management strategy evaluation performance metric summary
mse_summary(mse, om_only = FALSE)mse_summary(mse, om_only = FALSE)
mse |
|
om_only |
only include performance metrics from OMs |
Alist of two data.frames with MSE summary statistics of performance metrics including: data.frame 1
Average annual catch across projection years and simulations per fleet and across fleets
Average interannual variation in catch (IAV) across projection years (n) per fleet and across fleets
% of years in which the fishery is closed across simulations (s)
Average relative mean squared error in estimate of spawning biomass in the terminal year across simulations
% of years in which the population is perceived as undergoing overfishing as determined from F_Limit across simulations via build_hcr in the EM
% of years in which the population is perceived to be overfished as determined from B_Limit across simulations via build_hcr in the EM
% of years in which the population is undergoing overfishing as determined from the “true” F_Limit across simulations via build_hcr in the OM
% of years in which the population is overfished as determined from the “true” B_Limit across simulations via build_hcr in the OM
Average ratio of spawning biomass over B_target in the terminal year across simulations in the OM 10-14. Terminal biomass, SSB, SSB depletion (relative to equilibrium), SSB depletion (relative to dynamic SB0)
A data list containing inputs for a single-species CEATTLE model fit to
Gulf of Alaska northern rockfish data through 2022. See
BS2017SS for format details.
NorthernRockfish2022NorthernRockfish2022
A list with the same structure as BS2017SS.
Function that plots the biomass consumed trends as estimated from Rceattle. Returns and saves a figure with the biomass eaten trajectory.
plot_b_eaten( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, width = 7, height = 6.5, minyr = NULL, incl_proj = FALSE, mod_cex = 1, alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE )plot_b_eaten( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, width = 7, height = 6.5, minyr = NULL, incl_proj = FALSE, mod_cex = 1, alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
Which species to plot e.g. c(1,4). Default = NULL plots them all |
spnames |
Species names for legend |
add_ci |
TRUE/FALSE, includes 95 percent confidence interval |
lwd |
Line width as specified by user |
save |
Save figure to file? |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
width |
Figure width in inches |
height |
Figure height in inches |
minyr |
first year to plot |
incl_proj |
TRUE/FALSE include projections years |
mod_cex |
Cex of text for model name legend |
alpha |
Shading for confidence intervals |
mod_avg |
TRUE/FALSE |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
Function that plots the biomass consumed trends as estimated from Rceattle. Returns and saves a figure with the biomass eaten trajectory.
plot_b_eaten_prop( Rceattle, file = NULL, model_names = NULL, line_col = NULL, spnames = NULL, species = NULL, lwd = 3, right_adj = 0, top_adj = 0.15, minyr = NULL, mohns = NULL, width = 7, height = 6.5, incl_proj = FALSE, incl_mean = FALSE, add_ci = FALSE, mod_cex = 1 )plot_b_eaten_prop( Rceattle, file = NULL, model_names = NULL, line_col = NULL, spnames = NULL, species = NULL, lwd = 3, right_adj = 0, top_adj = 0.15, minyr = NULL, mohns = NULL, width = 7, height = 6.5, incl_proj = FALSE, incl_mean = FALSE, add_ci = FALSE, mod_cex = 1 )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
spnames |
Species names for legend |
species |
Which species to plot e.g. c(1,4). Default = NULL plots them all |
lwd |
Line width as specified by user |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
top_adj |
Adjustment for top margin |
minyr |
first year to plot |
mohns |
data.frame of mohn's rows extracted from |
width |
Figure width in inches |
height |
Figure height in inches |
incl_proj |
TRUE/FALSE include projections years |
incl_mean |
TRUE/FALSE include horizontal long term mean |
add_ci |
TRUE/FALSE, includes 95 percent confidence interval |
mod_cex |
Cex of text for model name legend |
Plots the mean minage+ biomass (million mt) and 95\
plot_biomass( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )plot_biomass( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
What species to include 1:nspp |
spnames |
Species names for legend |
add_ci |
If the confidence interval is to be added |
lwd |
Line width as specified by user |
save |
Save derived quantity? |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
legend.pos |
Position of the legend as used by |
width |
Figure width in inches |
height |
Figure height in inches |
minyr |
First year to plot |
maxyr |
max year to plot |
incl_proj |
TRUE/FALSE, include projection years |
mod_cex |
Cex of text for model name legend |
lty |
line type |
alpha |
shading for confidence intervals |
mod_avg |
TRUE/FALSE |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
reference |
Reference model |
Returns and saves a figure with the biomass trajectory.
Plot of fitted landings data on natural-scale (r4ss-style)
plot_catch( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, right_adj = 0, top_adj = 1.2, incl_proj = FALSE, single.plots = FALSE, width = NULL, height = NULL, alpha = 0.4, lwd = 2, ymax = NULL, maxyr = NULL, mse = FALSE, error = TRUE, fleets = NULL )plot_catch( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, right_adj = 0, top_adj = 1.2, incl_proj = FALSE, single.plots = FALSE, width = NULL, height = NULL, alpha = 0.4, lwd = 2, ymax = NULL, maxyr = NULL, mse = FALSE, error = TRUE, fleets = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
Species names for legend |
right_adj |
How much right side of the x-axis for fitting the legend. As percentage. |
top_adj |
How much top side of the y-axis for fitting the legend. As percentage (default = 1.2). |
incl_proj |
TRUE/FALSE include projections years |
single.plots |
if TRUE plot invidual fits else make multiplot |
width |
plot width |
height |
plot hight |
alpha |
Transparency of lines for MSE plots |
lwd |
Line width |
ymax |
Fleet specific upper ylim |
maxyr |
Max year to plot |
mse |
Is if an MSE object from |
error |
Include observed data with error bars? |
fleets |
Which fishing fleets to include (defaults to all = NULL) |
Function the plots the comp data as estimated from Rceattle
plot_comp( Rceattle, file = NULL, model_names = NULL, species = NULL, cex = 3, lwd = 3, right_adj = 0 )plot_comp( Rceattle, file = NULL, model_names = NULL, species = NULL, cex = 3, lwd = 3, right_adj = 0 )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
species |
Species names for legend |
cex |
Line width as specified by user |
lwd |
Line width for observed data lines |
right_adj |
How many units of the x-axis to add to the right side of the figure for fitting the legend. |
Returns and saves a figure
Plots a timeline of presence/absence (and optionally relative quantity) of
the data sources contributing to an Rceattle model's likelihood, by year and
fleet. Modelled after Stock Synthesis's r4ss::SSplotData().
plot_data( Rceattle, file = NULL, subplots = 1:2, datatypes = "all", fleets = "all", species = "all", ghost = FALSE, fleetcol = "default", width = 7, height = 5, res = 200, ptsize = 10, margins = c(5.1, 2.1, 2.1, 10.1), cex = 2, lwd = 12, maxsize = 1, alphasize = 1, mainTitle = FALSE, cex.main = 1 )plot_data( Rceattle, file = NULL, subplots = 1:2, datatypes = "all", fleets = "all", species = "all", ghost = FALSE, fleetcol = "default", width = 7, height = 5, res = 200, ptsize = 10, margins = c(5.1, 2.1, 2.1, 10.1), cex = 2, lwd = 12, maxsize = 1, alphasize = 1, mainTitle = FALSE, cex.main = 1 )
Rceattle |
Either a single Rceattle model object exported from
|
file |
Path/prefix used to save the figure. If |
subplots |
Integer vector controlling which subplots are produced:
|
datatypes |
Either |
fleets |
Either |
species |
Either |
ghost |
Logical. If |
fleetcol |
Either |
width, height
|
Figure dimensions in inches. |
res |
Resolution (dpi) for the saved PNG. |
ptsize |
Pointsize passed to |
margins |
|
cex |
Character expansion for points showing isolated years. |
lwd |
Line width for runs of consecutive years (subplot 1). |
maxsize |
Max bubble radius (in plot units) for subplot 2. |
alphasize |
Bubble fill transparency (0–1). |
mainTitle |
Logical; if |
cex.main |
Title character expansion. |
Years with Year > 0 contribute to the likelihood; rows with Year < 0
(kept for fitting comparison only) are shown when ghost = TRUE. Diet data
uses Year == 0 for the fixed reference stomach composition; those entries
are plotted at the model endyr and labelled per predator species.
Invisibly, a list with typetable — the long data frame underlying
the plot (year, fleet, data type, relative size).
Plots the mean biomass depletion and 95\
plot_depletion( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )plot_depletion( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
What species to include 1:nspp |
spnames |
Species names for legend |
add_ci |
If the confidence interval is to be added |
lwd |
Line width as specified by user |
save |
Save derived quantity? |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
legend.pos |
Position of the legend as used by |
width |
Figure width in inches |
height |
Figure height in inches |
minyr |
First year to plot |
maxyr |
max year to plot |
incl_proj |
TRUE/FALSE, include projection years |
mod_cex |
Cex of text for model name legend |
lty |
line type |
alpha |
shading for confidence intervals |
mod_avg |
TRUE/FALSE |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
reference |
Reference model |
Returns and saves a figure with the biomass depletion trajectory.
Plots the mean SSB depletion and 95\ Depletion reference lines for Ptarget and Plimit are drawn in blue and red respectively.
plot_depletionSSB( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )plot_depletionSSB( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
What species to include 1:nspp |
spnames |
Species names for legend |
add_ci |
If the confidence interval is to be added |
lwd |
Line width as specified by user |
save |
Save derived quantity? |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
legend.pos |
Position of the legend as used by |
width |
Figure width in inches |
height |
Figure height in inches |
minyr |
First year to plot |
maxyr |
max year to plot |
incl_proj |
TRUE/FALSE, include projection years |
mod_cex |
Cex of text for model name legend |
lty |
line type |
alpha |
shading for confidence intervals |
mod_avg |
TRUE/FALSE |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
reference |
Reference model |
Returns and saves a figure with the SSB depletion trajectory.
If year == 0, diet data are averaged from suit_styr to suit_endyr If prey_age >= 0 diet data are diet proportion of prey-at-age in predator-at-age If prey_age < 0 diet data are diet proportion of prey-spp in predator-at-age (sum across prey ages) If prey_age < 0 and pred_age < 0, diet data are mean diet proportion of prey-spp in predator-spp (sum across prey ages and take mean across predator ages) If prey_age < 0 and pred_age < -500, diet data are weighted mean diet proportion of prey-spp in predator-spp (sum across prey ages and take weighted mean across predator ages)
plot_diet_comp(Rceattle, file = NULL, species = NULL)plot_diet_comp(Rceattle, file = NULL, species = NULL)
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
species |
Species names for legend |
Returns and saves a figure
Plots the mean exploitable biomass (million mt) and 95\
plot_exploitable_biomass( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )plot_exploitable_biomass( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
What species to include 1:nspp |
spnames |
Species names for legend |
add_ci |
If the confidence interval is to be added |
lwd |
Line width as specified by user |
save |
Save derived quantity? |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
legend.pos |
Position of the legend as used by |
width |
Figure width in inches |
height |
Figure height in inches |
minyr |
First year to plot |
maxyr |
max year to plot |
incl_proj |
TRUE/FALSE, include projection years |
mod_cex |
Cex of text for model name legend |
lty |
line type |
alpha |
shading for confidence intervals |
mod_avg |
TRUE/FALSE |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
reference |
Reference model |
Returns and saves a figure with the exploitable biomass trajectory.
Function that plots the F time series per species from Rceattle
plot_f( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, right_adj = 0, width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE )plot_f( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, right_adj = 0, width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
Which species to plot e.g. c(1,4). Default = NULL plots them all |
spnames |
Species names for legend |
add_ci |
NOT WORKING If the confidence interval is to be added |
lwd |
Line width as specified by user |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
width |
plot width |
height |
plot height |
minyr |
First year to plot |
maxyr |
max year to plot |
incl_proj |
TRUE/FALSE, include projection years |
mod_cex |
Cex of text for model name legend |
alpha |
shading for confidence intervals |
mod_avg |
is the list a model average? (DEPRECATED) |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
Returns and saves a figure with the population trajectory.
Function to plot the functional form estimated or specified by Rceattle
plot_form(params = NULL, pred = 1, pred_age = 1, prey = 1, msmMode = 3)plot_form(params = NULL, pred = 1, pred_age = 1, prey = 1, msmMode = 3)
params |
Parameter list object from |
pred |
Predator index |
pred_age |
Predator age |
prey |
Prey index |
msmMode |
Multispecies mode integer specifying functional form |
Plot of fitted CPUE indices on natural-scale (r4ss-style)
plot_index( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, right_adj = 0, top_adj = 0.05, incl_proj = FALSE, single.plots = FALSE, width = NULL, height = NULL, error = TRUE )plot_index( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, right_adj = 0, top_adj = 0.05, incl_proj = FALSE, single.plots = FALSE, width = NULL, height = NULL, error = TRUE )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
Species names for legend |
right_adj |
How much right side of the x-axis for fitting the legend. As percentage. |
top_adj |
How much top side of the y-axis for fitting the legend. As percentage. |
incl_proj |
TRUE/FALSE include projections years |
single.plots |
if TRUE plot invidual fits else make multiplot |
width |
plot width |
height |
plot hight |
error |
include observed data and error bars? |
Plot of residuals CPUE indices on log-scale (r4ss-style)
plot_indexresidual( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, right_adj = 0, top_adj = 0.05, incl_proj = FALSE, single.plots = FALSE, width = NULL, height = NULL )plot_indexresidual( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, right_adj = 0, top_adj = 0.05, incl_proj = FALSE, single.plots = FALSE, width = NULL, height = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
Species names for legend |
right_adj |
How much right side of the x-axis for fitting the legend. As percentage. |
top_adj |
How much top side of the y-axis for fitting the legend. As percentage. |
incl_proj |
TRUE/FALSE include projections years |
single.plots |
if TRUE plot invidual fits else make multiplot |
width |
plot width |
height |
plot hight |
Plot of fitted CPUE indices on log-scale (r4ss-style)
plot_logindex( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, right_adj = 0, top_adj = 0.05, incl_proj = FALSE, single.plots = FALSE, width = NULL, height = NULL )plot_logindex( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, right_adj = 0, top_adj = 0.05, incl_proj = FALSE, single.plots = FALSE, width = NULL, height = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
Species names for legend |
right_adj |
How much right side of the x-axis for fitting the legend. As percentage. |
top_adj |
How much top side of the y-axis for fitting the legend. As percentage. |
incl_proj |
TRUE/FALSE include projections years |
single.plots |
if TRUE plot invidual fits else make multiplot |
width |
plot width |
height |
plot hight |
Function that plots the natural mortality at age (M1 + M2) as estimated from Rceattle. Returns and saves a figure with the M-at-age trajectory.
plot_m_at_age( Rceattle, file = NULL, age = 1, model_names = NULL, line_col = NULL, spnames = NULL, species = NULL, lwd = 3, lty = 1, right_adj = 0, minyr = NULL, width = 7, height = 6.5, incl_proj = FALSE, incl_mean = FALSE, add_ci = FALSE )plot_m_at_age( Rceattle, file = NULL, age = 1, model_names = NULL, line_col = NULL, spnames = NULL, species = NULL, lwd = 3, lty = 1, right_adj = 0, minyr = NULL, width = 7, height = 6.5, incl_proj = FALSE, incl_mean = FALSE, add_ci = FALSE )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
age |
Age to plot M at age |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
spnames |
Species names for legend |
species |
Which species to plot e.g. c(1,4). Default = NULL plots them all |
lwd |
Line width as specified by user |
lty |
Line type |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
minyr |
first year to plot |
width |
Figure width in inches |
height |
Figure height in inches |
incl_proj |
TRUE/FALSE include projections years |
incl_mean |
TRUE/FALSE include time series mean as horizontal line |
add_ci |
TRUE/FALSE, includes 95 percent confidence interval |
Function that plots the predation mortality at age (M2) by predator as estimated from Rceattle. Returns and saves a figure with the M-at-age trajectory.
plot_m2_at_age_prop( Rceattle, file = NULL, age = 1, model_names = NULL, line_col = NULL, spnames = NULL, species = NULL, lwd = 3, right_adj = 0, top_adj = 0.15, minyr = NULL, width = 7, height = 6.5, incl_proj = FALSE, incl_mean = FALSE, add_ci = FALSE )plot_m2_at_age_prop( Rceattle, file = NULL, age = 1, model_names = NULL, line_col = NULL, spnames = NULL, species = NULL, lwd = 3, right_adj = 0, top_adj = 0.15, minyr = NULL, width = 7, height = 6.5, incl_proj = FALSE, incl_mean = FALSE, add_ci = FALSE )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
age |
Age to plot M at age |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
spnames |
Species names for legend |
species |
Which species to plot e.g. c(1,4). Default = NULL plots them all |
lwd |
Line width as specified by user |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
top_adj |
Adjustment for top margin |
minyr |
first year to plot |
width |
Figure width in inches |
height |
Figure height in inches |
incl_proj |
TRUE/FALSE include projections years |
incl_mean |
TRUE/FALSE include time series mean as horizontal line |
add_ci |
TRUE/FALSE, includes 95 percent confidence interval |
Function that plots the maturity of each species
plot_maturity( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, width = 4, height = 5.5, lwd = 3 )plot_maturity( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, width = 4, height = 5.5, lwd = 3 )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
Species names for legend |
width |
Figure width in inches |
height |
Figure height in inches |
lwd |
Line width as specified by user |
Function that plots the M1 and M2 as estimated from Rceattle
plot_mortality( Rceattle, file = NULL, incl_proj = FALSE, zlim = NULL, type = 0, width = 8, height = 5.5, title = NULL, log = FALSE, minyr = NULL, theta = 155, species = NULL, maxage = NULL, title_cex = 10, M2 = TRUE )plot_mortality( Rceattle, file = NULL, incl_proj = FALSE, zlim = NULL, type = 0, width = 8, height = 5.5, title = NULL, log = FALSE, minyr = NULL, theta = 155, species = NULL, maxage = NULL, title_cex = 10, M2 = TRUE )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
incl_proj |
Include the projection years (TRUE/FALSE) |
zlim |
zlim for M1 + M2 plots. Character - use max range across species in model. NULL - use species specific ranges. Vector of two. |
type |
0 = Tiles, 1 = contour, 2 = facet lines, 3 = persp |
width |
Plot width when saved "inches" |
height |
Plot height when saved "inches" |
title |
Additional title to add. Will also add species names if not NULL |
log |
TRUE/FALSE use log M1 + M2 |
minyr |
First year to plot |
theta |
theta for persp plot |
species |
Species to plot. Plots all if null. |
maxage |
Plot up to this age. Plots all ages if NULL |
title_cex |
Font size for title |
M2 |
TRUE/FALSE Use M2 only (True) or total M (False) |
Function that plots the ration across ages (minage:nages) as estimated from Rceattle. Returns and saves a figure with the ration trajectory. Ration is multiplied by biomass-at-age/sex to get population level estimates
plot_ration( Rceattle, file = NULL, minage = 1, model_names = NULL, line_col = NULL, spnames = NULL, species = NULL, lwd = 3, lty = 1, right_adj = 0, minyr = NULL, width = 7, height = 6.5, incl_proj = FALSE, incl_mean = FALSE, add_ci = FALSE )plot_ration( Rceattle, file = NULL, minage = 1, model_names = NULL, line_col = NULL, spnames = NULL, species = NULL, lwd = 3, lty = 1, right_adj = 0, minyr = NULL, width = 7, height = 6.5, incl_proj = FALSE, incl_mean = FALSE, add_ci = FALSE )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
minage |
minage to plot ration (i.e. age "minage"+) |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
spnames |
Species names for legend |
species |
Which species to plot e.g. c(1,4). Default = NULL plots them all |
lwd |
Line width as specified by user |
lty |
Line type |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
minyr |
first year to plot |
width |
Figure width in inches |
height |
Figure height in inches |
incl_proj |
TRUE/FALSE include projections years |
incl_mean |
TRUE/FALSE include time series mean as horizontal line |
add_ci |
TRUE/FALSE, includes 95 percent confidence interval |
Plots the mean minage recruitment (millions) and 95\
plot_recruitment( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )plot_recruitment( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
What species to include 1:nspp |
spnames |
Species names for legend |
add_ci |
If the confidence interval is to be added |
lwd |
Line width as specified by user |
save |
Save derived quantity? |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
legend.pos |
Position of the legend as used by |
width |
Figure width in inches |
height |
Figure height in inches |
minyr |
First year to plot |
maxyr |
max year to plot |
incl_proj |
TRUE/FALSE, include projection years |
mod_cex |
Cex of text for model name legend |
lty |
line type |
alpha |
shading for confidence intervals |
mod_avg |
TRUE/FALSE |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
reference |
Reference model |
Returns and saves a figure with the recruitment trajectory.
Function that plots the fishery and survey selectivity as estimated from Rceattle
plot_selectivity( Rceattle, file = NULL, model_names = NULL, line_col = NULL, width = 7, height = 6.5, species = c("Walleye pollock", "Pacific cod", "Arrowtooth flounder"), lwd = 3 )plot_selectivity( Rceattle, file = NULL, model_names = NULL, line_col = NULL, width = 7, height = 6.5, species = c("Walleye pollock", "Pacific cod", "Arrowtooth flounder"), lwd = 3 )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
width |
Figure width in inches |
height |
Figure height in inches |
species |
Species names for legend |
lwd |
Line width as specified by user |
Function the plots the fishery selectivity and input maturity. Useful for debugging SPR based reference points.
plot_selectivity_vs_maturity( Rceattle, file = NULL, model_names = NULL, line_col = NULL, width = 7, height = 6.5, species = c("Walleye pollock", "Pacific cod", "Arrowtooth flounder"), lwd = 3 )plot_selectivity_vs_maturity( Rceattle, file = NULL, model_names = NULL, line_col = NULL, width = 7, height = 6.5, species = c("Walleye pollock", "Pacific cod", "Arrowtooth flounder"), lwd = 3 )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
width |
Figure width in inches |
height |
Figure height in inches |
species |
Species names for legend |
lwd |
Line width as specified by user |
Plots the mean SSB (million mt) and 95\
plot_ssb( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )plot_ssb( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
What species to include 1:nspp |
spnames |
Species names for legend |
add_ci |
If the confidence interval is to be added |
lwd |
Line width as specified by user |
save |
Save derived quantity? |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
legend.pos |
Position of the legend as used by |
width |
Figure width in inches |
height |
Figure height in inches |
minyr |
First year to plot |
maxyr |
max year to plot |
incl_proj |
TRUE/FALSE, include projection years |
mod_cex |
Cex of text for model name legend |
lty |
line type |
alpha |
shading for confidence intervals |
mod_avg |
TRUE/FALSE |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
reference |
Reference model |
Returns and saves a figure with the SSB trajectory.
Deprecated alias for plot_ssb_depletion. Please use
plot_ssb_depletion() instead.
plot_ssb_depletion( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )plot_ssb_depletion( Rceattle, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, right_adj = 0, legend.pos = "topright", width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mod_avg = rep(FALSE, length(Rceattle)), mse = FALSE, OM = TRUE, reference = NULL )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
What species to include 1:nspp |
spnames |
Species names for legend |
add_ci |
If the confidence interval is to be added |
lwd |
Line width as specified by user |
save |
Save derived quantity? |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
legend.pos |
Position of the legend as used by |
width |
Figure width in inches |
height |
Figure height in inches |
minyr |
First year to plot |
maxyr |
max year to plot |
incl_proj |
TRUE/FALSE, include projection years |
mod_cex |
Cex of text for model name legend |
lty |
line type |
alpha |
shading for confidence intervals |
mod_avg |
TRUE/FALSE |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
reference |
Reference model |
Function the plots the stock recruit function as estimated from Rceattle
plot_stock_recruit( Rceattle, file = NULL, model_names = NULL, line_col = NULL, width = 7, height = 6.5, species = NULL, spnames = NULL, lwd = 3, lty = 1, incl_proj = FALSE, plot_env = FALSE, mod_cex = 1 )plot_stock_recruit( Rceattle, file = NULL, model_names = NULL, line_col = NULL, width = 7, height = 6.5, species = NULL, spnames = NULL, lwd = 3, lty = 1, incl_proj = FALSE, plot_env = FALSE, mod_cex = 1 )
Rceattle |
Single or list of Rceattle model objects exported from |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
width |
Figure width in inches |
height |
Figure height in inches |
species |
Which species to plot e.g. c(1,4). Default = NULL plots them all |
spnames |
Species names for legend |
lwd |
Line width as specified by user |
lty |
Line type |
incl_proj |
TRUE/FALSE, include projection years for environmental relationship |
plot_env |
TRUE/FALSE, plot environmental covariate relationship |
mod_cex |
Cex of text for model name legend |
Function that plots the time-series (SSB/B/R/Depletion) 95% CI trends as estimated from Rceattle
plot_timeseries( Rceattle, output = "biomass", ylab = NULL, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, legend.pos = "topright", right_adj = 0, width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mse = FALSE, OM = TRUE, reference = NULL, mod_avg = rep(FALSE, length(Rceattle)) )plot_timeseries( Rceattle, output = "biomass", ylab = NULL, file = NULL, model_names = NULL, line_col = NULL, species = NULL, spnames = NULL, add_ci = FALSE, lwd = 3, save = FALSE, legend.pos = "topright", right_adj = 0, width = 7, height = 6.5, minyr = NULL, maxyr = NULL, incl_proj = FALSE, mod_cex = 1, lty = rep(1, length(Rceattle)), alpha = 0.4, mse = FALSE, OM = TRUE, reference = NULL, mod_avg = rep(FALSE, length(Rceattle)) )
Rceattle |
Single or list of Rceattle model objects exported from |
output |
derived quantity of interest: recruitment, biomass, ssb, depletion, or ssb_depletion. Uses same name as ".cpp" file. |
ylab |
Y-axis label |
file |
name of a file to identified the files exported by the function. |
model_names |
Names of models to be used in legend |
line_col |
Colors of models to be used for line color |
species |
What species to include 1:nspp |
spnames |
Species names for legend |
add_ci |
If the confidence interval is to be added |
lwd |
Line width as specified by user |
save |
Save derived quantity? |
legend.pos |
Position of the legend as used by |
right_adj |
Multiplier for to add to the right side of the figure for fitting the legend. |
width |
Figure width in inches |
height |
Figure height in inches |
minyr |
First year to plot |
maxyr |
max year to plot |
incl_proj |
TRUE/FALSE, include projection years |
mod_cex |
Cex of text for model name legend |
lty |
line type |
alpha |
shading for confidence intervals |
mse |
|
OM |
if mse == TRUE, use the OM (TRUE) or EM (FALSE) for plotting? |
reference |
Reference model |
mod_avg |
TRUE/FALSE |
Returns and saves a figure with the population trajectory.
Thin S3 dispatcher around the package's existing plot_*() functions
so that plot(fit) works the way users expect. Pick the panel with
what; everything in ... is forwarded to the underlying function.
## S3 method for class 'Rceattle' plot(x, what = "biomass", ...)## S3 method for class 'Rceattle' plot(x, what = "biomass", ...)
x |
An object of class |
what |
Character. One of |
... |
Passed to the underlying plotting function. |
Invisibly returns NULL. Called for the side effect of
producing a plot.
Provides a compact summary so that auto-printing inside R Markdown / knitr / RStudio does not recurse into the (very deep) data and TMB objects stored on the fit. Only structural metadata, convergence status, headline derived quantities, and the package / TMB-DLL versions used to produce the fit are printed.
## S3 method for class 'Rceattle' print(x, ...)## S3 method for class 'Rceattle' print(x, ...)
x |
An object of class |
... |
Currently unused. |
For operational use, the package version line is meant to make it
obvious which version of Rceattle produced an archived fit so that
results can be reproduced even if master has moved on. Tag a
release (devtools::install_github("grantdadams/[email protected]"))
and the same version string will reappear here on a fresh run.
The input x, invisibly.
Standard Beta(shape1, shape2) on (0, 1), matching stats::dbeta().
For priors on stock-recruit steepness on the standard (0.2, 1)
interval, transform inside the model and use prior_beta() on the
rescaled quantity.
prior_beta(shape1, shape2)prior_beta(shape1, shape2)
shape1, shape2
|
positive shape parameters. |
An Rceattle_prior of family "beta".
Shape-rate parameterization, matching stats::dgamma().
prior_gamma(shape, rate)prior_gamma(shape, rate)
shape |
positive shape parameter. |
rate |
positive rate parameter. |
An Rceattle_prior of family "gamma".
Parameterized on the log scale (mean and sd of the log of the
coefficient), matching stats::dlnorm().
prior_lognormal(meanlog, sdlog)prior_lognormal(meanlog, sdlog)
meanlog |
prior mean of the log of the coefficient. |
sdlog |
prior standard deviation of the log (must be positive). |
An Rceattle_prior of family "lognormal".
Normal prior on a linkage coefficient
prior_normal(mean, sd)prior_normal(mean, sd)
mean |
prior mean. |
sd |
prior standard deviation (must be positive). |
An Rceattle_prior of family "normal".
Re-fits an Rceattle model while holding selected cells of a
parameter fixed at user-specified values. Supports profiling a single
cell (e.g. R_log_sd[species = 1]) and arbitrary N-dimensional
cross-profiles over multiple cells – e.g. log_M1[1, 1, 1] and
log_M1[1, 2, 1] jointly, to profile residual M for males against
females. For each grid point the targeted cells are fixed in the TMB
map and the remaining parameters are re-estimated; the result is a
grid of Rceattle models for downstream NLL surfaces.
## S3 method for class 'Rceattle' profile( fitted = NULL, param = NULL, slots = NULL, values = NULL, transform = "log", cores = NULL, ... )## S3 method for class 'Rceattle' profile( fitted = NULL, param = NULL, slots = NULL, values = NULL, transform = "log", cores = NULL, ... )
fitted |
an Rceattle model fit using |
param |
Name of the parameter to profile. Two ways to specify it:
|
slots |
A list whose entries are integer index vectors, one entry
per cell to fix. Each entry's length must equal the number of
dimensions of the resolved parameter – 1 for vectors
( |
values |
A list of numeric vectors, one per entry of |
transform |
How to map user values onto the internal parameter scale
before substituting them into |
cores |
Number of cores to use for parallel fits. Default
|
... |
Unused; present for consistency with the |
A list with elements:
list of fitted Rceattle models, one per grid
row; entries for non-converged fits are NULL so positions
stay aligned with grid.
data frame of grid values on the user scale (before
transform); one column per profiled cell, named
slot_1, slot_2, ...
numeric vector of joint negative log-likelihoods
(opt$objective); NA where the fit did not
converge.
the profiled parameter name (echoed).
the slots list (echoed for downstream plotting).
data(BS2017SS) ss_run <- fit_mod(data_list = BS2017SS, inits = NULL, file = NULL, estimateMode = 0, random_rec = FALSE, msmMode = 0, avgnMode = 0, phase = FALSE, verbose = 0) # 1-D profile of sigmaR for species 1 (alias form -- natural scale) p1 <- profile(ss_run, param = "sigmaR", slots = list(1), values = list(seq(0.1, 1.5, by = 0.1))) # Equivalent raw form (log scale -- user does the transform) p1_raw <- profile(ss_run, param = "R_log_sd", slots = list(1), values = list(log(seq(0.1, 1.5, by = 0.1))), transform = "identity") # 2-D cross-profile of M1 across species 1 and 2 (sex 1, age 1). # BS2017SS is single-sex; with a multi-sex model the same form # (e.g. c(1, 1, 1), c(1, 2, 1)) would cross-profile males vs females. p2 <- profile(ss_run, param = "M1", slots = list(c(1, 1, 1), c(2, 1, 1)), values = list(seq(0.1, 0.4, length.out = 3), seq(0.1, 0.4, length.out = 3))) # 1-D profile of SRR alpha for species 1 (alias drops the rec_pars column) p3 <- profile(ss_run, param = "alpha", slots = list(1), values = list(seq(2, 80, length.out = 20)))data(BS2017SS) ss_run <- fit_mod(data_list = BS2017SS, inits = NULL, file = NULL, estimateMode = 0, random_rec = FALSE, msmMode = 0, avgnMode = 0, phase = FALSE, verbose = 0) # 1-D profile of sigmaR for species 1 (alias form -- natural scale) p1 <- profile(ss_run, param = "sigmaR", slots = list(1), values = list(seq(0.1, 1.5, by = 0.1))) # Equivalent raw form (log scale -- user does the transform) p1_raw <- profile(ss_run, param = "R_log_sd", slots = list(1), values = list(log(seq(0.1, 1.5, by = 0.1))), transform = "identity") # 2-D cross-profile of M1 across species 1 and 2 (sex 1, age 1). # BS2017SS is single-sex; with a multi-sex model the same form # (e.g. c(1, 1, 1), c(1, 2, 1)) would cross-profile males vs females. p2 <- profile(ss_run, param = "M1", slots = list(c(1, 1, 1), c(2, 1, 1)), values = list(seq(0.1, 0.4, length.out = 3), seq(0.1, 0.4, length.out = 3))) # 1-D profile of SRR alpha for species 1 (alias drops the rec_pars column) p3 <- profile(ss_run, param = "alpha", slots = list(1), values = list(seq(2, 80, length.out = 20)))
Read a CEATTLE excel data file
read_data(file = "Rceattle_data.xlsx")read_data(file = "Rceattle_data.xlsx")
file |
Filname to be used. Must end with '.xlsx' |
library(Rceattle) data(BS2017SS) out_file <- file.path(tempdir(), "BS2017SS.xlsx") write_data(data_list = BS2017SS, file = out_file) data_list <- read_data(file = out_file) file.remove(out_file)library(Rceattle) data(BS2017SS) out_file <- file.path(tempdir(), "BS2017SS.xlsx") write_data(data_list = BS2017SS, file = out_file) data_list <- read_data(file = out_file) file.remove(out_file)
Function to rearrange a data_list object to be read into TMB
rearrange_dat() is a deprecated alias for rearrange_data()
kept for backwards compatibility; please use rearrange_data().
rearrange_data(data_list) rearrange_dat(data_list)rearrange_data(data_list) rearrange_dat(data_list)
data_list |
an Rceattle data_list |
Function to update hindcast and set F to 0. Useful for determining dynamic reference points for multi-species models under climate-change.
remove_F(Rceattle)remove_F(Rceattle)
Rceattle |
A fitted Rceattle model object |
Function to rename derived quantities from Rceattle
rename_output(data_list = NULL, quantities = NULL)rename_output(data_list = NULL, quantities = NULL)
data_list |
an Rceattle data_list |
quantities |
list of "report" objects from Rceattle. |
Returns a long-format data frame of residuals across one or more of
the four fitted data sources: "index" (survey indices),
"catch" (fishery catches), "comp" (age- or length-composition
proportions), and "caal" (conditional age-at-length proportions).
## S3 method for class 'Rceattle' residuals(object, type = "index", scale = "log", ...)## S3 method for class 'Rceattle' residuals(object, type = "index", scale = "log", ...)
object |
An object of class |
type |
One or more of |
scale |
|
... |
Currently unused. |
For "index" and "catch", the Residual column is on the log
scale by default (matching the lognormal observation likelihood) and
can be switched to the natural scale via scale = "natural". For
"comp" and "caal", residuals are Pearson residuals on the
fitted proportions:
where N is the input sample size. Composition rows are returned in long form: one row per (observation, age/length bin).
Composition rows carry the Age0_Length1 flag from comp_data
(0 for age comps, 1 for length comps) so age and length comps
can be filtered apart. CAAL rows carry both the conditioning
Length and the age Bin.
A data.frame with columns Source, Fleet_code,
Fleet_name, Species, Sex, Year, Length, Bin,
Age0_Length1, Sample_size, Observed, Fitted, Residual.
Sex, Length, Bin, Age0_Length1, and Sample_size are
NA where they do not apply (e.g. for index/catch rows).
Calculate Mohn's rho and run retrospective peels for an Rceattle model. The function also evaluates retrospective forecast skill. To evaluate both retrospective bias and forecast skill, the function uses the map functionality of TMB to peel the model:
Filters data, filters fixed inputs, and maps out time-varying parameters for the peeled years. All time-varying parameters for the peeled years are set to the terminal year of the model for that peel.
Fits the peeled model.
Turns off all hindcast parameters, turns on F for the peeled years, and fits to the peeled catch series to update the "forecast" dynamics given projection assumptions and observed catch from the peeled years.
retrospective( Rceattle = NULL, peels = 5, rescale = FALSE, nyrs_forecast = 3, cores = NULL )retrospective( Rceattle = NULL, peels = 5, rescale = FALSE, nyrs_forecast = 3, cores = NULL )
Rceattle |
an Rceattle model fit using |
peels |
the number of retrospective peels to use in the calculation of rho and for model estimation |
rescale |
TRUE/FALSE whether to subset and rescale environmental predictors for the range of peel years. |
nyrs_forecast |
Number of forecast years to calculate Mohn's Rho in addition to terminal year |
cores |
Number of cores to use for parallel peels. Default
|
a list of 1. list of Rceattle models and 2. vector of Mohn's rho for each species
data(BS2017SS) ss_run <- fit_mod(data_list = BS2017SS, inits = NULL, file = NULL, estimateMode = 0, random_rec = FALSE, msmMode = 0, avgnMode = 0, phase = FALSE, verbose = 0) retro <- retrospective(ss_run, peels = 10)data(BS2017SS) ss_run <- fit_mod(data_list = BS2017SS, inits = NULL, file = NULL, estimateMode = 0, random_rec = FALSE, msmMode = 0, avgnMode = 0, phase = FALSE, verbose = 0) retro <- retrospective(ss_run, peels = 10)
A subset of rich.colors by Arni Magnusson from the gplots package, with the addition of alpha transparency (which is now available in the gplots version as well)
rich.colors.short(n, alpha = 1)rich.colors.short(n, alpha = 1)
n |
Number of colors to generate. |
alpha |
Alpha transparency value for all colors in vector. Value is passed to rgb function. |
Arni Magnusson, Ian Taylor
Runs a forward projecting MSE. Main assumptions are the projected selectivity/catchability, foraging days, and weight-at-age are the same as the terminal year of the hindcast in the operating model. Assumes survey sd is same as average across historic time series, while comp data sample size is same as last year. No implementation error and no observation error for catch!
run_mse( om, em, nsim = 10, start_sim = 1, assessment_period = 1, sampling_period = 1, simulate_data = TRUE, regenerate_past = FALSE, sample_rec = TRUE, rec_trend = 0, fut_sample = 1, cap = NULL, catch_mult = NULL, seed = 666, regenerate_seed = seed, loopnum = 1, file = NULL, dir = NULL, timeout = 999, endyr = NA, cores = NULL )run_mse( om, em, nsim = 10, start_sim = 1, assessment_period = 1, sampling_period = 1, simulate_data = TRUE, regenerate_past = FALSE, sample_rec = TRUE, rec_trend = 0, fut_sample = 1, cap = NULL, catch_mult = NULL, seed = 666, regenerate_seed = seed, loopnum = 1, file = NULL, dir = NULL, timeout = 999, endyr = NA, cores = NULL )
om |
CEATTLE model object exported from |
em |
CEATTLE model object exported from |
nsim |
Number of simulations to run (default 10) |
start_sim |
First simulation number to start at. Useful if the code stops at specific seed/sim (default = 1). |
assessment_period |
Period of years that each assessment is taken |
sampling_period |
Period of years data sampling is conducted. Single value or vector the same length as the number of fleets. |
simulate_data |
Include simulated random error proportional to that estimated/provided for the data from the OM. |
regenerate_past |
Refits the EM to historical/conditioning data prior to the MSE, where the data are generated from the OM with |
sample_rec |
Include resampled recruitment deviates from the"hindcast" in the projection of the OM. Resampled deviates are used rather than sampling from N(0, sigmaR) because initial deviates bias R0 low. If false, uses mean of recruitment deviates. |
rec_trend |
Linear increase or decrease in mean recruitment from |
fut_sample |
future sampling effort relative to last year. |
cap |
A cap on the catch in the projection. Can be a single number applied to all species (proportional to recommended catch) or vector of length |
catch_mult |
A multiplier for the catch in the projection. Can be a single number or vector of length nspp. Default = NULL |
seed |
seed for the simulation |
regenerate_seed |
seed for regenerating data |
loopnum |
number of times to re-start optimization (where |
file |
(Optional) Filename where each OM simulation with EMs will be saved. If NULL, no files are saved. |
dir |
(Optional) Directory where each OM simulation is saved |
timeout |
length of time (minutes) estimation will run before stopping a sim (default 999 minutes) |
endyr |
Terminal year of the MSE projection. Default = NA uses |
cores |
Number of cores to use for parallel simulations. Default
|
A list of operating models (differ by simulated recruitment determined by nsim) and estimation models fit to each operating model (differ by terminal year).
Sample historical recruitment deviates and place in the projection
sample_rec(Rceattle, sample_rec = TRUE, update_model = TRUE, rec_trend = 0)sample_rec(Rceattle, sample_rec = TRUE, update_model = TRUE, rec_trend = 0)
Rceattle |
CEATTLE model object exported from |
sample_rec |
Include resampled recruitment deviates from the"hindcast" in the projection of the OM. Resampled deviates are used rather than sampling from N(0, sigmaR) because initial deviates bias R0 low. If false, uses mean of recruitment deviates. |
update_model |
Update model dynamics. Default = TRUE |
rec_trend |
Linear increase or decrease in mean recruitment from |
Rceattle model
Simulates data from an Rceattle model and refits the model to the simulated data. TODO add process variation (i.e. random devs) to simulation.
self_test( Rceattle = NULL, nsim = 50, simulate = TRUE, seed = 123, cores = NULL )self_test( Rceattle = NULL, nsim = 50, simulate = TRUE, seed = 123, cores = NULL )
Rceattle |
an Rceattle model fit using |
nsim |
number of simulations |
simulate |
passed to |
seed |
random number seed. Each simulation |
cores |
Number of cores to use for parallel simulations. Default
|
a list of Rceattle models
data(BS2017SS) ss_run <- fit_mod(data_list = BS2017SS, inits = NULL, file = NULL, estimateMode = 0, random_rec = FALSE, msmMode = 0, avgnMode = 0, phase = FALSE, verbose = 0) sims <- self_test(ss_run, nsim = 10)data(BS2017SS) ss_run <- fit_mod(data_list = BS2017SS, inits = NULL, file = NULL, estimateMode = 0, random_rec = FALSE, msmMode = 0, avgnMode = 0, phase = FALSE, verbose = 0) sims <- self_test(ss_run, nsim = 10)
Function to set phasing order
set_phases()set_phases()
list of parameter names with associated phase
Simulates data used in Rceattle from the expected values estimated from an existing Rceattle model. The variances and uncertainty are consistent with those used in the operating model. The function simulates: survey biomass (log-normal), catch-at-age/length composition (multinomial or dirichlet-multinomial), conditional-age-at-length (CAAL; multinomial or dirichlet-multinomial), and total catch (log-normal).
sim_mod(Rceattle, simulate = FALSE)sim_mod(Rceattle, simulate = FALSE)
Rceattle |
A CEATTLE model object exported from |
simulate |
Logical. If |
A data_list object containing the simulated or expected data
values, formatted for use in Rceattle.
Compact summary method for Rceattle fits
## S3 method for class 'Rceattle' summary(object, ...)## S3 method for class 'Rceattle' summary(object, ...)
object |
An object of class |
... |
Currently unused. |
Function to check for missing switches for map and parameter functions
switch_check(data_list)switch_check(data_list)
data_list |
Rceattle data list |
#https://www.dataanalytics.org.uk/make-transparent-colors-in-r/
t_col(color, percent = 50, name = NULL)t_col(color, percent = 50, name = NULL)
color |
color name |
percent |
% transparency |
name |
an optional name for the color |
TMBAIC calculates AIC for a given model fit
TMBAIC(opt, p = 2, n = Inf)TMBAIC(opt, p = 2, n = Inf)
opt |
the output from |
p |
the penalty on additional fixed effects (default=2, for AIC) |
n |
the sample size, for use in AICc calculation (default=Inf, for which AICc=AIC) |
AIC, where a parsimonious model has a AIC relative to other candidate models
This function runs TMB with ADMB-like phasing of parameter estimation. Function with normal inputs, passed via "...", plus two additional arguments, "phase" Optimizer by default is nlminb phase is a tagged list where missing elements are populated with a vector of 1s, and non-missing elements are integers, and where the optimizer loops through values of phase while progressively changing map to turn on parameters
TMBphase( data, parameters, map, random, phases, model_name, silent, use_gradient = TRUE, control = list(eval.max = 1e+09, iter.max = 1e+09, trace = 0) )TMBphase( data, parameters, map, random, phases, model_name, silent, use_gradient = TRUE, control = list(eval.max = 1e+09, iter.max = 1e+09, trace = 0) )
data |
A list to be passed to TMB |
parameters |
A list of parameters of the model |
map |
a list of map object from the model |
random |
A character vector of names of parameters that are random effects |
phases |
A list of the phases for the parameters of the model (same structure as your parameter list) |
model_name |
A string describing the model name. Must be the name of your .cpp file |
silent |
logical. If TRUE, suppresses output from TMB (default = TRUE). |
use_gradient |
logical. If TRUE, uses gradient in optimization (default = TRUE). |
control |
A list of control parameters. For details see |
A list of parameter estimates and their standard errors
Gavin Fay https://github.com/kaskr/TMB_contrib_R/blob/master/TMBphase/R/TMBphase.R
Returns the fixed-effect covariance matrix produced by
TMB::sdreport(). Random-effect covariance is not returned here —
use object$sdrep for the full report.
## S3 method for class 'Rceattle' vcov(object, ...)## S3 method for class 'Rceattle' vcov(object, ...)
object |
An object of class |
... |
Currently unused. |
A numeric matrix, or NULL if sdreport was not run
(i.e. the fit was produced with getsd = FALSE).
A data list containing inputs for a CEATTLE model that uses growth
estimated from the Woods Hole Assessment Model (WHAM). See
BS2017SS for format details.
whamGrowthDatawhamGrowthData
A list with the same structure as BS2017SS.
Write data file
write_data(data_list, file = "Rceattle_data.xlsx")write_data(data_list, file = "Rceattle_data.xlsx")
data_list |
Rceattle data_list object |
file |
Filname to be used. Must end with '.xlsx' |
library(Rceattle) data(BS2017SS) out_file <- file.path(tempdir(), "BS2017SS.xlsx") write_data(data_list = BS2017SS, file = out_file) file.remove(out_file)library(Rceattle) data(BS2017SS) out_file <- file.path(tempdir(), "BS2017SS.xlsx") write_data(data_list = BS2017SS, file = out_file) file.remove(out_file)