| Title: | Facilitates Model Running for EBS Pollock |
|---|---|
| Description: | Facilitates model running for EBS Pollock. |
| Authors: | Jim Ianelli [aut, cre] |
| Maintainer: | Jim Ianelli <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.1.0000 |
| Built: | 2026-05-19 07:42:52 UTC |
| Source: | https://github.com/afsc-assessments/ebswp |
Extracts data for either biomass or some other metric based on the given models in the list M.
The function formats the data into a consistent structure for further processing.
.get_ats_df(M, biomass = TRUE).get_ats_df(M, biomass = TRUE)
M |
A list of model outputs. Each item should contain at least
the elements |
biomass |
A logical flag. If |
A dataframe with columns: year, Model, obs, pre, lb, and ub.
This function iterates through a list of models and extracts year and associated measurements.
.get_avo_df(M).get_avo_df(M)
M |
A list of models where each model has the needed attributes. |
A data frame with columns for year, model, observed values, predicted values, lower bounds, and upper bounds.
This function iterates through a list of models and extracts year and associated measurements.
.get_bts_df(M, biomass = TRUE).get_bts_df(M, biomass = TRUE)
M |
A list of models where each model has the needed attributes. |
biomass |
Logical indicating if biomass data should be used. If FALSE, other measurements are used. |
A data frame with columns for year, model, observed values, predicted values, lower bounds, and upper bounds.
Extract copE data
.get_cope_df(M).get_cope_df(M)
M |
list object created by read_admb function |
dataframe of spawning biomass
Extract CPUE data
.get_cpue_df(M).get_cpue_df(M)
M |
list object created by read_admb function |
dataframe of observed and predicted CPUE
This function extracts likelihood values from a list of models and formats them into a structured data frame.
.get_like_df(M).get_like_df(M)
M |
A list of models where each model contains likelihood components. |
A data frame containing the likelihood components, model name, natural mortality value (M), and negative log likelihood (NLL) for each model in the list.
# Assuming 'model_list' is a list of models with the appropriate structure # likelihood_df <- .get_like_df(model_list)# Assuming 'model_list' is a list of models with the appropriate structure # likelihood_df <- .get_like_df(model_list)
Extract mean age from pollock model run
.get_mnage_df(M).get_mnage_df(M)
M |
list object created by read_admb function |
dataframe of spawning biomass
Extract Numbers at age 3
.get_Nage_3_df(M).get_Nage_3_df(M)
M |
list object created by read_admb function |
dataframe of age3+ biomass
Extract Recruits (R) from pollock run
.get_R_rel_df(M, rel = TRUE).get_R_rel_df(M, rel = TRUE)
M |
list object created by read_admb function |
rel |
logical flag for relative recruitment |
dataframe of spawning biomass
Extracts predicted recruitment and approximate asymptotic error-bars
.get_recruitment_df(M).get_recruitment_df(M)
M |
list object(s) created by read_admb function |
dataframe of recruitment
SJD Martell, DN Webber
Extract spawning exploitation rate
.get_ser_df(M).get_ser_df(M)
M |
list object created by read_admb function |
dataframe of spawning biomass
Extract stock recruitment results
.get_srr_df(M).get_srr_df(M)
M |
list object created by read_admb function |
dataframe of expected and observed SRR
Spawning biomass may be defined as all males or some combination of males and females
.get_ssb_df(M).get_ssb_df(M)
M |
list object created by read_admb function |
dataframe of spawning biomass
Spawning biomass may be defined as all males or some combination of males and females
.get_ssb_rel_df(M).get_ssb_rel_df(M)
M |
list object created by read_admb function |
dataframe of spawning biomass
run pollock model
.run_mod(moddir = mod_dir).run_mod(moddir = mod_dir)
moddir |
directory where pollock model should be run |
run pollock model on windows
.run_mod_windows(moddir = mod_dir).run_mod_windows(moddir = mod_dir)
moddir |
directory where pollock model should be run |
run projection model DOESN"T WORK...dunno why
.run_proj(moddir = mod_dir).run_proj(moddir = mod_dir)
moddir |
directory where pollock model should be run |
run projection model for windows
.run_proj_windows(moddir = mod_dir).run_proj_windows(moddir = mod_dir)
moddir |
directory where pollock model should be run |
A function that returns a list containing various parameters, settings, and data inputs required for model configuration. This includes start years, recruitment ages, maturity proportions, weights, catch data, survey data, and more.
get_input_data()get_input_data()
A list with the following components:
Start year for the model (e.g., 1964).
Start year for the bottom trawl survey (e.g., 1982).
Start year for the acoustic trawl survey (e.g., 1994).
End year for the model (e.g., 2024).
Age at recruitment (e.g., 1).
Number of ages in the model (e.g., 15).
Proportion mature at age (vector of length nages).
End-weight index (vector of length nages).
Fishery weight-at-age matrix (rows = years, columns = ages).
Spawning stock biomass weight-at-age matrix (rows = years, columns = ages).
Observed catch data (vector of length n_fsh).
Observed effort data (vector of length n_fsh).
Number of CPUE data points.
Years for CPUE data (vector of length n_cpue).
Observed CPUE data (vector of length n_cpue).
Standard deviation for CPUE data (vector of length n_cpue).
Number of acoustic survey data points.
Years for acoustic survey data (vector of length n_avo).
Observed acoustic survey data (vector of length n_avo).
Standard deviation for acoustic survey data (vector of length n_avo).
Weight-at-age matrix for acoustic survey (rows = years, columns = ages).
Number of gears.
Minimum index for each gear (vector of length ngears).
Number of fishery years.
Number of bottom trawl survey years.
Number of acoustic trawl survey years.
Years for fishery data (vector of length n_fsh).
Years for bottom trawl survey data (vector of length n_bts).
Years for acoustic trawl survey data (vector of length n_ats).
Sample size for fishery data (vector of length n_fsh).
Sample size for bottom trawl survey data (vector of length n_bts).
Sample size for acoustic trawl survey data (vector of length n_ats).
Error for fishery data (vector of length n_fsh).
Error for bottom trawl survey data (vector of length n_bts).
Error for acoustic trawl survey data (vector of length n_ats).
Observed age composition for fishery data (matrix of size n_fsh x nages).
Observed bottom trawl survey biomass (vector of length n_bts).
Standard deviation for bottom trawl survey biomass (vector of length n_bts).
Weight-at-age matrix for bottom trawl survey (rows = years, columns = ages).
Observed bottom trawl survey numbers-at-age (matrix of size n_bts x nages).
Observed age composition for bottom trawl survey (matrix of size n_bts x nages).
Standard deviation for acoustic trawl survey numbers-at-age (vector of length n_ats).
Observed age composition for acoustic trawl survey (matrix of size n_ats x nages).
Observed acoustic trawl survey biomass (vector of length n_ats).
Standard deviation for acoustic trawl survey biomass (vector of length n_ats).
Weight-at-age matrix for acoustic trawl survey (rows = years, columns = ages).
Bottom temperature data (vector of length n_fsh).
Number of ageing error matrices.
Ageing error matrix (matrix of size nages x nages).
Number of length bins.
Observed length composition for fishery data (vector of length nlbins).
Age-length transition matrix (matrix of size nages x nlbins).
Test value (e.g., 1234567).
## Not run: input_data <- get_input_data() ## End(Not run)## Not run: input_data <- get_input_data() ## End(Not run)
This function fetches model results based on specified model names and directories.
get_results( mod_names. = mod_names, rundir = "runs", moddir = mod_dir, run_on_mac = TRUE )get_results( mod_names. = mod_names, rundir = "runs", moddir = mod_dir, run_on_mac = TRUE )
mod_names. |
A character vector of model names. Default is 'mod_names'. |
rundir |
The main sub directory path for the models. Default is 'runs' |
moddir |
The main directory path for the models. Default is 'mod_dir' |
run_on_mac |
Logical. Whether to use macOS-specific run behavior. |
A list containing model results.
Extracts results relevant to Tier 3 analyses.
get_tier3_res(proj_file)get_tier3_res(proj_file)
proj_file |
A file path to the projection file. |
A list or vector of results relevant to Tier 3 analyses.
## Not run: proj_file_path <- "path/to/proj.csv" tier3_results <- get_tier3_res(proj_file_path) ## End(Not run)## Not run: proj_file_path <- "path/to/proj.csv" tier3_results <- get_tier3_res(proj_file_path) ## End(Not run)
This function processes the output of a certain model (possibly related to fisheries) to extract, compute, and format various metrics.
get_vars(M, proj_file = NULL, ord = dec_tab_ord)get_vars(M, proj_file = NULL, ord = dec_tab_ord)
M |
A list or data structure that holds the model output/results. Expected to have several
named elements, including |
proj_file |
(Optional) A file path to a projection file for Tier 3 results. Default is NULL. |
ord |
The order and extent of reporting for the decision table aspect Default is dec_tab_ord. |
A list B that contains various extracted and computed metrics.
## Not run: model_result <- list(...) # Example model result here metrics <- get_vars(model_result) ## End(Not run)## Not run: model_result <- list(...) # Example model result here metrics <- get_vars(model_result) ## End(Not run)
A named list containing parameters and settings that control the behavior of a model. This list includes options for stock recruitment, selectivity, natural mortality, and more.
model_settingsmodel_settings
A list with the following components:
stan's covariance matrix option.
Stock Recruitment Type (1 = Ricker, 2 = Beverton-Holt, 3 = Constant, 4 = Old Ricker).
Do combined surveys (0 = No, 1 = Yes).
Use ageing error matrix (0 = No, 1 = Yes).
Use Age1 ATS Index (0 = No, 1 = Yes).
Age1 ATS Index Sigma (log-normal distribution).
Use end-year length data (0 = No, 1 = Yes).
Use population weights for spawning (otherwise fishery weights) (0 = No, 1 = Yes).
Natural mortality prior.
CV of natural mortality prior.
Natural mortality at age (vector for ages 1 to 15).
Prior for all q values.
Sigma for all q values (ignored if greater than 1).
Prior for BTS q values.
Sigma for BTS q values (ignored if greater than 1).
Prior for sigma R (based on 1978 onwards).
CV of sigma R prior.
Phase for estimating sigma R.
Prior for steepness.
CV of steepness prior.
Phase for estimating steepness.
Use prior as SPRF35 = Fmsy (0 = No, 1 = Yes).
Sigma for SPRF35 = Fmsy.
Use last ATS age composition (0 = No, >0 = Yes).
Number of years to average recent selectivity.
Use BTS Biomass (0 = Numbers, 1 = Biomass).
Use ATS Biomass (0 = Numbers, 1 = Biomass).
Stock-Recruitment Prior Beta distribution alpha.
Stock-Recruitment Prior Beta distribution beta.
Number of future years.
Next year's catch.
Number of scenarios.
Fixed catch in future scenario 2.
Fixed catch in future scenario 3.
Phase to calculate F40%.
Phase to start robustness.
Phase for ATS robustness.
Likelihood for ATS (0 = standard, 1 = log-normal for each age).
Phase for fishery logistic selectivity.
Phase for BTS logistic selectivity.
Phase for fishery selectivity deviations.
Phase for BTS selectivity deviations.
Phase for BTS Age1 deviations.
Phase for ATS survey selectivity coefficients.
Phase for ATS survey selectivity deviations.
Phase for natural mortality estimation.
Phase for BTS q estimation.
Phase for standard BTS area q estimation.
Phase for ATS q estimation.
Phase for bottom temperature effect on q.
Phase for regular recruitment deviations.
Phase for larval recruitment deviations.
Phase to estimate stock-recruitment parameters (negative means constant recruitment).
Phase of future weight uncertainty.
Fishery: Number of oldest age groups to have the same selectivity.
BTS: Number of oldest age groups to have the same selectivity.
ATS: Number of oldest age groups to have the same selectivity.
A numeric vector of control flags, where each element corresponds to a specific setting:
Catch Biomass.
Survey Emphasis.
Recruitment Deviations.
Fishing mortality deviations (F_devs).
Lambda on ATS survey.
AVO (Acoustic Visual Observation) data.
Age Composition.
Age Composition Fishery.
Age Composition Survey Fishery.
Selectivity Trend (Fishery).
Selectivity Curvature (Fishery).
CPUE Data.
Fishery Selectivity Dome-shapedness.
Bottom Trawl Survey Dome-shapedness.
Non-Increasing Selectivity Penalty for Hydraulic Survey.
Number of years selectivity fishery stays the same.
Number of years selectivity stays the same in the survey.
Reserved.
Selectivity Deviation Surveys Curvature (Surveys).
BTS Time Variability.
BTS Smoothness (if nonparametric).
ATS Second-Difference.
Lambda on larval recruitment deviations.
Recruits from 1978 onwards only.
Ignore 1978 year class in estimation.
Reserved.
Third differencing in space (negative means no smoothing, positive = lambda).
Retrospective year.
Omit recent years from stock-recruitment estimation.
SRR Prior only (0 = use prior and data, otherwise weight on prior).
Selectivity block shift.
Phase for cohort effect.
Phase for year effect.
Switch for temperature-dependent recruitment (0 = No, 1 = Yes).
Phase for temperature-dependent recruitment.
Switch for predator mortality (0 = No, 1 = Yes).
Phase for predator mortality.
Switch for multispecies functional response (0 = No, 1 = Yes).
model_settings <- list( DoCovBTS = 1, SrType = 1, Do_Combined = 0, use_age_err = 1, use_age1_ATS = 1, age1_sigma_ATS = 1, use_endyr_len = 0, use_popwts_ssb = 0, natmortprior = 0.3, cvnatmortprior = 0.1, natmort_in = c(0.9, 0.45, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3), q_all_prior = 0, q_all_sigma = 2, q_bts_prior = 0, q_bts_sigma = 2, sigrprior = 1, cvsigrprior = 0.2, phase_sigr = -6, steepnessprior = 0.6, cvsteepnessprior = 0.12, phase_steepness = 5, use_spr_msy_pen = 0, sigma_spr_msy = 0.20, use_last_ATS_ac = 1, nyrs_sel_avg = 2, do_bts_bio = 1, do_ATS_bio = 1, srprior_a = 14.93209877, srprior_b = 14.93209877, nyrs_future = 5, next_yrs_catch = 1350, nscen = 8, fixed_catch_fut2 = 1400, fixed_catch_fut3 = 1200, phase_F40 = 6, robust_phase = 1350, ATS_robust_phase = 1350, ATS_like_type = 0, phase_logist_fsh = -1, phase_logist_bts = 2, phase_seldevs_fsh = 4, phase_seldevs_bts = 5, phase_age1devs_bts = 3, phase_selcoffs_ATS = 3, phase_selcoffs_ATS_dev = -5, phase_natmort = -6, phase_q_bts = 3, phase_q_std_area = -4, phase_q_ATS = 4, phase_bt = -6, phase_rec_devs = 3, phase_larv = -3, phase_sr = 5, wt_fut_phase = 6, last_age_sel_group_fsh = 4, last_age_sel_group_bts = 8, last_age_sel_group_ATS = 8, ctrl_flag = c(200, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12.5, 1, 1, 1, 1, 1, 1, 3.125, 5, 0.1, 5, 1, 1, 2, 1, 0, 2, 1), sel_dev_shift = 0, phase_coheff = 1, phase_yreff = 1, switch_temp_recruitment = 0, phase_temp_recruitment = 6, switch_pred_mort = 0, phase_pred_mort = 1, switch_multispecies_functional_response = 1 )model_settings <- list( DoCovBTS = 1, SrType = 1, Do_Combined = 0, use_age_err = 1, use_age1_ATS = 1, age1_sigma_ATS = 1, use_endyr_len = 0, use_popwts_ssb = 0, natmortprior = 0.3, cvnatmortprior = 0.1, natmort_in = c(0.9, 0.45, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3), q_all_prior = 0, q_all_sigma = 2, q_bts_prior = 0, q_bts_sigma = 2, sigrprior = 1, cvsigrprior = 0.2, phase_sigr = -6, steepnessprior = 0.6, cvsteepnessprior = 0.12, phase_steepness = 5, use_spr_msy_pen = 0, sigma_spr_msy = 0.20, use_last_ATS_ac = 1, nyrs_sel_avg = 2, do_bts_bio = 1, do_ATS_bio = 1, srprior_a = 14.93209877, srprior_b = 14.93209877, nyrs_future = 5, next_yrs_catch = 1350, nscen = 8, fixed_catch_fut2 = 1400, fixed_catch_fut3 = 1200, phase_F40 = 6, robust_phase = 1350, ATS_robust_phase = 1350, ATS_like_type = 0, phase_logist_fsh = -1, phase_logist_bts = 2, phase_seldevs_fsh = 4, phase_seldevs_bts = 5, phase_age1devs_bts = 3, phase_selcoffs_ATS = 3, phase_selcoffs_ATS_dev = -5, phase_natmort = -6, phase_q_bts = 3, phase_q_std_area = -4, phase_q_ATS = 4, phase_bt = -6, phase_rec_devs = 3, phase_larv = -3, phase_sr = 5, wt_fut_phase = 6, last_age_sel_group_fsh = 4, last_age_sel_group_bts = 8, last_age_sel_group_ATS = 8, ctrl_flag = c(200, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12.5, 1, 1, 1, 1, 1, 1, 3.125, 5, 0.1, 5, 1, 1, 2, 1, 0, 2, 1), sel_dev_shift = 0, phase_coheff = 1, phase_yreff = 1, switch_temp_recruitment = 0, phase_temp_recruitment = 6, switch_pred_mort = 0, phase_pred_mort = 1, switch_multispecies_functional_response = 1 )
Age Composition Data Plotter t(t() This function generates a series of plots visualizing the age composition data from fisheries assessment. It compares observed and predicted data across different years.
plot_agefit( x, case_label = "2021 assessment", gear = "bts", type = "survey", styr = NULL, ageplus = NULL )plot_agefit( x, case_label = "2021 assessment", gear = "bts", type = "survey", styr = NULL, ageplus = NULL )
x |
Model object or data needed to build age composition plots. |
case_label |
Label for the specific case or dataset being visualized. Default is "2021 assessment". |
gear |
Gear identifier (e.g., "bts"). |
type |
Data type to plot (e.g., "survey"). |
styr |
Start year for plotting (optional). |
ageplus |
Plus group age (optional). |
The function plots observed fishery age composition data using a bar plot, overlaying predicted data with points. It organizes the plots in a multi-panel figure, with each panel representing a year. Age classes are represented on the x-axis.
A multi-panel plot where each panel visualizes age composition data for a specific year.
The function uses the rainbow color palette, and the colors loop around for
each cohort. The function expects certain naming conventions in the input dataset dat.
# Example usage (ensure you have an appropriate dataset 'mod1'): # AgeFits(dat=mod1, main="Fishery Age Composition", case_label="Sample Assessment")# Example usage (ensure you have an appropriate dataset 'mod1'): # AgeFits(dat=mod1, main="Fishery Age Composition", case_label="Sample Assessment")
This function visualizes the acoustic trawl survey data, either biomass or another metric, depending on the choice. It provides options for customization of the resulting plot.
plot_ats( M, xlab = "Year", ylab = "Acoustic trawl survey biomass", xlim = NULL, ylim = NULL, alpha = 0.1, biomass = TRUE, color = "red", error_bars = TRUE )plot_ats( M, xlab = "Year", ylab = "Acoustic trawl survey biomass", xlim = NULL, ylim = NULL, alpha = 0.1, biomass = TRUE, color = "red", error_bars = TRUE )
M |
List of model outputs. A list object like the one accepted
by |
xlab |
Label for the x-axis. Default is "Year". |
ylab |
Label for the y-axis. Default is "Acoustic trawl survey biomass". |
xlim |
Optional range for the x-axis. |
ylim |
Optional range for the y-axis. |
alpha |
Opacity for the ribbon, if used. Default is 0.1. |
biomass |
Logical flag. If |
color |
Color for the data points. Default is "red". |
error_bars |
Logical flag to draw error bars. Default is |
A ggplot2 plot object visualizing the acoustic trawl survey data.
This function takes a list of models and plots the observed, predicted and confidence intervals for the bottom trawl survey data.
plot_avo( M, xlab = "Year", ylab = "Acoustic return (Sa from AVO) ", ylim = NULL, error_bars = TRUE )plot_avo( M, xlab = "Year", ylab = "Acoustic return (Sa from AVO) ", ylim = NULL, error_bars = TRUE )
M |
A list of models where each model has the needed attributes. |
xlab |
Label for the x-axis. |
ylab |
Label for the y-axis. |
ylim |
Limits for the y-axis. |
xlim |
Limits for the x-axis. |
color |
Color for the points. |
biomass |
Logical indicating if biomass data should be used. If FALSE, other measurements are used. |
error_bars |
Logical flag to draw error bars. Default is |
A ggplot object with the plotted data.
This function takes a list of models and plots the observed, predicted and confidence intervals for the bottom trawl survey data.
plot_bts( M, xlab = "Year", ylab = "Bottom trawl survey biomass", xlim = NULL, ylim = NULL, color = "purple", biomass = TRUE, error_bars = TRUE )plot_bts( M, xlab = "Year", ylab = "Bottom trawl survey biomass", xlim = NULL, ylim = NULL, color = "purple", biomass = TRUE, error_bars = TRUE )
M |
A list of models where each model has the needed attributes. |
xlab |
Label for the x-axis. |
ylab |
Label for the y-axis. |
xlim |
Limits for the x-axis. |
ylim |
Limits for the y-axis. |
color |
Color for the points. |
biomass |
Logical indicating if biomass data should be used. If FALSE, other measurements are used. |
error_bars |
Logical flag to draw error bars. Default is |
A ggplot object with the plotted data.
Plot copepod something
plot_cope( M, xlab = "Year", ylab = "Copepod index ", ylim = NULL, color = "red" )plot_cope( M, xlab = "Year", ylab = "Copepod index ", ylim = NULL, color = "red" )
M |
List object(s) created by read_admb function |
xlab |
the x-label of the figure |
ylab |
the y-label of the figure |
ylim |
is the upper limit of the figure |
color |
Color for the points. |
Plot of model estimates of spawning stock biomass
Plot predicted CPUE
plot_cpue( M, xlab = "Year", ylab = "Early trawl fishery CPUE", ylim = NULL, color = "red" )plot_cpue( M, xlab = "Year", ylab = "Early trawl fishery CPUE", ylim = NULL, color = "red" )
M |
List object(s) created by read_admb function |
xlab |
the x-label of the figure |
ylab |
the y-label of the figure |
ylim |
is the upper limit of the figure |
color |
Color for the points. |
Plot of model estimates of observed and predicted CPUE
This function plots the negative log likelihood values for different
components against a specified predictor (e.g., natural mortality).
The function uses ggplot2 for visualization.
plot_likes( M, xlab = "Natural Mortality", ylab = "relative -ln Likelihood", ylim = NULL, xlim = NULL, alpha = 0.1, legend = TRUE )plot_likes( M, xlab = "Natural Mortality", ylab = "relative -ln Likelihood", ylim = NULL, xlim = NULL, alpha = 0.1, legend = TRUE )
M |
A list of models from which likelihood values will be extracted. |
xlab |
Label for the x-axis. Default is "Natural Mortality". |
ylab |
Label for the y-axis. Default is "relative -ln Likelihood". |
ylim |
Limits for the y-axis. Default is NULL. |
xlim |
Limits for the x-axis. Default is NULL. |
alpha |
Alpha transparency level for the plotted lines. Default is 0.1. |
legend |
Logical indicating whether to display a legend. Default is TRUE. |
A ggplot object displaying the negative log likelihood values.
# Assuming 'model_list' is a list of models with the appropriate structure # plot_likes(model_list)# Assuming 'model_list' is a list of models with the appropriate structure # plot_likes(model_list)
Plot predicted mean age by gear type
plot_mnage(M, xlab = "Year", ylab = "Mean age", xlim = NULL, ylim = NULL)plot_mnage(M, xlab = "Year", ylab = "Mean age", xlim = NULL, ylim = NULL)
M |
List object(s) created by read_admb function |
xlab |
the x-label of the figure |
ylab |
the y-label of the figure |
xlim |
is the year range to plot of the figure |
ylim |
is the upper limit of the figure |
Plot of model estimates of mean age against observed (and implied confidence bounds)
Plot predicted Numbers at age 3
plot_Nage_3( M, xlab = "Year", ylab = "Numbers at age 3", ylim = NULL, xlim = c(1990, 2020), breaks = seq(1990, 2022, 2), alpha = 0.8, legend = TRUE, order = NULL )plot_Nage_3( M, xlab = "Year", ylab = "Numbers at age 3", ylim = NULL, xlim = c(1990, 2020), breaks = seq(1990, 2022, 2), alpha = 0.8, legend = TRUE, order = NULL )
M |
List object(s) created by read_admb function |
xlab |
the x-label of the figure |
ylab |
the y-label of the figure |
ylim |
is the upper limit of the figure |
xlim |
limits for the x-axis |
breaks |
tick marks for the x-axis |
alpha |
the opacity of the ribbon |
legend |
logical flag to draw a legend |
order |
optional ordering of model series |
Plot of model estimates of age3+ stock biomass
Plot predicted recruitment
plot_R_rel( M, xlab = "Year", ylab = "Relative age-1 recruits", ylim = NULL, xlim = NULL, alpha = 0.1, legend = TRUE, rel = TRUE )plot_R_rel( M, xlab = "Year", ylab = "Relative age-1 recruits", ylim = NULL, xlim = NULL, alpha = 0.1, legend = TRUE, rel = TRUE )
M |
List object(s) created by read_admb function |
xlab |
the x-label of the figure |
ylab |
the y-label of the figure |
ylim |
is the upper limit of the figure |
xlim |
limits for the x-axis |
alpha |
the opacity of the ribbon |
legend |
logical flag to draw a legend |
rel |
logical flag for relative recruitment |
Plot of model estimates of spawning stock biomass
Plot predicted recruitment and approximate asymptotic error-bars
plot_recruitment( M, xlab = "Year", ylab = "Recruitment (millions)", xlim = c(1990.5, 2023.5), fatten = 0.8, fill = "yellow", alpha = 0.9 )plot_recruitment( M, xlab = "Year", ylab = "Recruitment (millions)", xlim = c(1990.5, 2023.5), fatten = 0.8, fill = "yellow", alpha = 0.9 )
M |
list object created by read_admb function |
xlab |
the x-axis label for the plot |
ylab |
the y-axis label for the plot |
xlim |
limits for the x-axis |
fatten |
line width multiplier |
fill |
fill color for the ribbon |
alpha |
opacity for the ribbon |
Plot of predicted recruitment
SJD Martell, DN Webber
Plot selectivity
plot_sel( Year = M$Yr, sel = M$sel_fsh, styr = 1977, fage = NULL, lage = NULL, alpha = 0.2, scale = 3.8, fill = "purple" )plot_sel( Year = M$Yr, sel = M$sel_fsh, styr = 1977, fage = NULL, lage = NULL, alpha = 0.2, scale = 3.8, fill = "purple" )
Year |
Vector of years. |
sel |
Selectivity matrix or vector. |
styr |
Start year. |
fage |
First age to plot (optional). |
lage |
Last age to plot (optional). |
alpha |
the opacity of the ribbon |
scale |
Scaling factor for plotting. |
fill |
Fill color. |
Plot of model estimates of spawning stock biomass
Plot predicted spawning stock biomass (SER)
plot_ser( M, xlab = "Year", ylab = "Spawning Exploitation rate", ylim = NULL, xlim = NULL, breaks = seq(1960, 2017, 5), alpha = 0.1, legend = TRUE )plot_ser( M, xlab = "Year", ylab = "Spawning Exploitation rate", ylim = NULL, xlim = NULL, breaks = seq(1960, 2017, 5), alpha = 0.1, legend = TRUE )
M |
List object(s) created by read_admb function |
xlab |
the x-label of the figure |
ylab |
the y-label of the figure |
ylim |
is the upper limit of the figure |
xlim |
limits for the x-axis |
breaks |
tick marks for the x-axis |
alpha |
the opacity of the ribbon |
legend |
logical flag to draw a legend |
Plot of model estimates of spawning stock biomass
This function plots the stock-recruitment relationship (SRR) using ggplot2. It can handle multiple models and provides flexibility in display options.
plot_srr( M, ylab = "Recruits (age 1, millions)", xlab = "Female spawning biomass (kt)", ylim = NULL, xlim = NULL, alpha = 0.05, ebar = "FALSE", leglabs = NULL, coverlap = FALSE, sizein = 3, sizeout = 2, yrsin = 1977:2019 )plot_srr( M, ylab = "Recruits (age 1, millions)", xlab = "Female spawning biomass (kt)", ylim = NULL, xlim = NULL, alpha = 0.05, ebar = "FALSE", leglabs = NULL, coverlap = FALSE, sizein = 3, sizeout = 2, yrsin = 1977:2019 )
M |
A list or data structure containing model results. |
ylab |
Label for the y-axis. Default is "Recruits (age 1, millions)". |
xlab |
Label for the x-axis. Default is "Female spawning biomass (kt)". |
ylim |
Limits for the y-axis. Default is |
xlim |
Limits for the x-axis. Default is |
alpha |
Alpha for the ribbons indicating uncertainty. Default is 0.05. |
ebar |
Logical, if |
leglabs |
Custom labels for the legend. Default is |
coverlap |
Logical, if |
sizein |
Font size for the in-sample text labels. Default is 3. |
sizeout |
Font size for the out-of-sample text labels. Default is 2. |
yrsin |
Years to be considered for in-sample. Default is 1977:2019. |
A ggplot object containing the SRR plot.
# Assuming 'model_list' contains the relevant model results: # plot_srr(M = model_list, ylim = c(0, 1e6), xlim = c(0, 2000))# Assuming 'model_list' contains the relevant model results: # plot_srr(M = model_list, ylim = c(0, 1e6), xlim = c(0, 2000))
Spawning biomass may be defined as all males or some combination of males and females
plot_ssb( M, xlab = "Year", ylab = "Female spawning biomass (kt)", ylim = NULL, xlim = NULL, breaks = seq(1990, 2022, 2), alpha = 0.1, legend = TRUE, order = NULL )plot_ssb( M, xlab = "Year", ylab = "Female spawning biomass (kt)", ylim = NULL, xlim = NULL, breaks = seq(1990, 2022, 2), alpha = 0.1, legend = TRUE, order = NULL )
M |
List object(s) created by read_admb function |
xlab |
the x-label of the figure |
ylab |
the y-label of the figure |
ylim |
is the upper limit of the figure |
xlim |
limits for the x-axis |
breaks |
tick marks for the x-axis |
alpha |
the opacity of the ribbon |
legend |
logical flag to draw a legend |
order |
optional ordering of model series |
Plot of model estimates of spawning stock biomass
Spawning biomass may be defined as all males or some combination of males and females
plot_ssb_rel( M, xlab = "Year", ylab = "Relative female spawning biomass", ylim = NULL, xlim = NULL, legend = TRUE, breaks = seq(1990, 2022, 5), alpha = 0.1 )plot_ssb_rel( M, xlab = "Year", ylab = "Relative female spawning biomass", ylim = NULL, xlim = NULL, legend = TRUE, breaks = seq(1990, 2022, 5), alpha = 0.1 )
M |
List object(s) created by read_admb function |
xlab |
the x-label of the figure |
ylab |
the y-label of the figure |
ylim |
is the upper limit of the figure |
xlim |
limits for the x-axis |
legend |
logical flag to draw a legend |
breaks |
tick marks for the x-axis |
alpha |
the opacity of the ribbon |
Plot of model estimates of spawning stock biomass
This function generates and prints summary tables for a specified model configuration. It calculates mean values for various metrics across different scenarios and displays formatted tables for Catch, Spawning Stock Biomass (SSB), Fishing Mortality (F), and Allowable Biological Catch (ABC).
print_Tier3_tbl(mod_number, run = FALSE)print_Tier3_tbl(mod_number, run = FALSE)
mod_number |
Integer. Specifies the model configuration number. |
run |
Logical. If |
The function reads projection results from a CSV file, groups data by alternative and year, calculates mean values for specific metrics, and formats these into tables for each metric. The tables are printed with captions based on the model configuration name.
Prints formatted tables for Catch, SSB, F, and ABC. Does not return a value.
# Example usage print_Tier3_tbl(mod_number = 1, run = TRUE)# Example usage print_Tier3_tbl(mod_number = 1, run = TRUE)
Read ADMB output files .rep, .par, and .cor and return an R object of type 'list'
read_admb(repfile)read_admb(repfile)
repfile |
ADMB output files to be read (no extension needed) |
object of type 'list' with ADMB outputs as list elements
Read ADMB .ctl file and return an R object of type 'list'. DOES NOT WORK
read_ctl(fn)read_ctl(fn)
fn |
name of ADMB .ctl file to be read |
object of type 'list' with ADMB outputs therein
D'Arcy N. Webber
Reads an ADMB data file and returns a list of outputs in R.
read_dat(fn)read_dat(fn)
fn |
Character. The name of the ADMB data file. |
A list containing various ADMB outputs from the data file.
Read ADMB .par, .std, and .cor file and return an R object of type 'list' of estimates and correlations
read_fit(repfile)read_fit(repfile)
repfile |
name of ADMB output file to be read (no extension needed) |
object of type 'list' with ADMB outputs therein
Steve Martell, Anders Nielsen, Athol Whitten, D'Arcy N. Webber
Read ADMB .psv file and return an R object of type 'list'
read_psv(fn, nsamples = 10000)read_psv(fn, nsamples = 10000)
fn |
name of ADMB .psv file to be read (no extension needed) |
nsamples |
number of posterior samples to read |
object of type 'list' with ADMB outputs therein
Steve Martell
Read ADMB .rep file and return an R object of type 'list'
read_rep(fn)read_rep(fn)
fn |
name of ADMB output file to be read (no extension needed) |
object of type "list" with ADMB outputs therein
Steve Martell, D'Arcy N. Webber
This function rescales a covariance matrix using either the Cholesky decomposition method or a simple diagonal adjustment.
rescale_cov(Sigma, Scale_factor, DoChol = FALSE)rescale_cov(Sigma, Scale_factor, DoChol = FALSE)
Sigma |
A covariance matrix that needs to be rescaled. |
Scale_factor |
A numeric value or vector used for scaling. |
DoChol |
Logical indicating if the Cholesky decomposition method should be used.
If |
A rescaled covariance matrix.
This function uses parallel processing to run multiple ADMB models and gather their outputs. After running the models, it also fetches certain variables from a 'proj/spm_detail.csv' file associated with each model.
run_model( moddir = mod_dir, rundir = "runs", modnames = mod_names, Output = TRUE, run_on_mac = TRUE )run_model( moddir = mod_dir, rundir = "runs", modnames = mod_names, Output = TRUE, run_on_mac = TRUE )
moddir |
Character vector. The directory paths for the models, default is |
rundir |
Character string. The base run directory path for the models, default is |
modnames |
Character vector. The names of the models, default is |
Output |
Logical. A flag indicating if any output should be displayed (e.g., messages,
progress, etc.), default is |
run_on_mac |
Logical. Whether to use macOS-specific run behavior. |
A list containing the outputs of the ADMB models and the fetched variables.
This function uses parallel processing to run multiple ADMB models and gather their outputs. After running the models, it also fetches certain variables from a 'proj/spm_detail.csv' file associated with each model.
run_proj( moddir = mod_dir, rundir = "runs", modnames = mod_names, run_on_mac = TRUE )run_proj( moddir = mod_dir, rundir = "runs", modnames = mod_names, run_on_mac = TRUE )
moddir |
Character vector. The directory paths for the models, default is |
rundir |
Character string. The base run directory path for the models, default is |
modnames |
Character vector. The names of the models, default is |
run_on_mac |
Logical. Whether to use macOS-specific run behavior. |
This function takes a list of model outputs and compiles a dataframe with a broader set of fit metrics.
tab_fit(M, mod_scen = NULL)tab_fit(M, mod_scen = NULL)
M |
List containing model outputs. |
mod_scen |
Optional vector of integers indicating which models in M to use. Default is all models. |
Returns a dataframe with extended fit metrics.
This function takes a list of model outputs and compiles a dataframe with a broader set of fit metrics.
tab_ref(M, mod_scen = NULL)tab_ref(M, mod_scen = NULL)
M |
List containing model outputs. |
mod_scen |
Optional vector of integers indicating which models in M to use. Default is all models. |
Returns a dataframe with extended fit metrics.
Helper function to convert the first character of a string to uppercase.
upperCaseFirst(s)upperCaseFirst(s)
s |
The input string. |
Returns the input string with the first character capitalized.
This function takes a list of data elements (matrices, vectors, or other values) and writes them to a specified text file. Each data element in the list is preceded by a comment line indicating its name.
write_dat(output_file = "runs/dat/newfile.dat", indata = in_data)write_dat(output_file = "runs/dat/newfile.dat", indata = in_data)
output_file |
A character string specifying the name of the output text file. Default is "output.txt". |
indata |
A list containing the data elements to be written to the file.
Each element can be a matrix, a vector, or any other value. Default is |
This function doesn't return a value; it writes to the specified output file.
# Assuming 'data_list' is a list of data elements # write_dat(output_file = "sample_output.txt", indata = data_list)# Assuming 'data_list' is a list of data elements # write_dat(output_file = "sample_output.txt", indata = data_list)