diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.nojekyll @@ -0,0 +1 @@ + diff --git a/404.html b/404.html new file mode 100644 index 0000000..9dd5d73 --- /dev/null +++ b/404.html @@ -0,0 +1,103 @@ + + +
+ + + + +vignettes/nwfscDiag.Rmd
+ nwfscDiag.Rmd
The package provides the functionality to conduct model diagnostics +for Stock Synthesis (SS3) models. The standard diagnostic included in +this package are standard required analysis for U.S. West Coast +Groundfish stock assessments managed by the Pacific Fisheries Management +Council. The package was designed to perform model diagnostics and +create plots and tables in a standardized format. The standardized +approach will facilitate the use of these outputs in the assessment +template approach.
+The diagnostics created by the package are: - jitter runs to ensure
+model convergence at the Maximum Likelihood Estimate (MLE), -
+retrospective runs to examine model sensitivity to recent data,
+and
+- likelihood profiles across parameters.
This package does not maintain backward compatibility with previous +versions of Stock Synthesis. However, if needed user can download older +package versions that may work with older versions (3.30.+) of Stock +Synthesis.
+nwfscDiag can be installed via github:
+install.packages("remotes")
+remotes::install_github("pfmc-assessments/nwfscDiag")
+The package depends upon a few other packages and they should be +installed upon installation of the package. The dependent packages +are:
+install.packages('dplyr')
+remotes::install_github('r4ss/r4ss')
+A new version of r4ss package was released on July 29, 2022 that
+included some significant changes that are required for the current
+version of nwfscDiag
to run. The current version of the
+nwfscDiag 1.1.2 package is designed to work with the latest release of
+r4ss. Please see release version 1.0.1 to use earlier versions of
+r4ss.
First, you should specify the directory where the base model is +located and where the diagnostics will be run and the name of the base +model folder:
+library(nwfscDiag)
+directory <- "C:/your directory"
+base_model_name <- "base model"
+Another way to do handle directory management is by using a project
+file and the here
package:
directory <- here::here("models")
+base_model_name <- "base model"
+The get_settings_profile()
specifies which parameters to
+run a profile for and the parameter ranges for each profile. The low and
+high values can be specified in 3 ways:
Specify the parameters to profile over along with the parameter range +and step size:
+profile_info <- get_settings_profile(
+ parameters = c("NatM_uniform_Fem_GP_1", "SR_BH_steep", "SR_LN(R0)"),
+ low = c(0.40, 0.25, -2),
+ high = c(0.40, 1.0, 2),
+ step_size = c(0.005, 0.05, 0.25),
+ param_space = c('multiplier', 'real', 'relative')
+ )
+The parameters
function argument specifies the
+parameters to profile over where the string provided should match the
+string label in the SS3 control file. The low
,
+high
, step_size
, and param_space
+inputs should be vectors of equal length to the parameters
+input. The above example will profile over female natural mortality,
+steepness, and
+.
+The female natural mortality parameter profile will range from (base
+parameter - base parameter* x) to (base parameter + base parameter * x)
+in steps of 0.005, the steepness parameter profile will range from 0.25
+to 1.0 in step size of 0.05, and the
+
+parameter profile will range from
+(
+- 0.25) to
+(
++ 0.25) in step size of 0.25.
Next the settings for running the profiles, jitter, and
+retrospectives within r4ss
needs to be specified using
+get_settings()
:
model_settings <- get_settings(
+ settings = list(
+ base_name = base_model_name,
+ run = c("jitter", "profile", "retro"),
+ profile_details = profile_info )
+ )
+where the above example requests jitters, profiles, and retrospective
+models to be run for the model file specified above as the
+base_model_name
with the profile setting set using
+get_settings_profile()
above. Calling
+model_settings
in the R terminal will show all default
+settings.
If profile
is included in the run requested and
+verbose = TRUE
in the model_settings()
the
+values for each parameter profiled across will be printed to the screen.
+Reviewing this information prior to running all diagnostics can be
+useful to ensure the parameter range and step size was set
+correctly.
Run all diagnostics:
+run_diagnostics(mydir = directory, model_settings = model_settings)
+library(nwfscDiag)
+directory <- here::here("models")
+base_model_name <- "base model"
+
+profile_settings <- get_settings_profile(
+ parameters = c("SR_BH_steep"),
+ low = c(0.25),
+ high = c(1.0),
+ step_size = c(0.05),
+ param_space = c('real')
+ )
+
+model_settings <- get_settings(
+ settings = list(
+ base_name = base_model_name,
+ run = "profile",
+ profile_details = profile_settings)
+ )
+
+run_diagnostics(mydir = directory, model_settings = model_settings)
+library(nwfscDiag)
+directory <- here::here("models")
+base_model_name <- "base model"
+
+model_settings <- get_settings(
+ settings = list(
+ base_name = base_model_name,
+ run = "jitter",
+ Njitter = 100,
+ jitter_fraction = 0.10)
+ )
+
+run_diagnostics(mydir = directory, model_settings = model_settings)
+library(nwfscDiag)
+directory <- here::here("models")
+base_model_name <- "base model"
+
+model_settings <- get_settings(
+ settings = list(
+ base_name = base_model_name,
+ run = "retro",
+ retro_yrs = -1:-10)
+ )
+
+run_diagnostics(mydir = directory, model_settings = model_settings)
+There are instances where not all models runs within a parameter
+profile converge. In this case one needs to rerun only select models
+that failed to converge in the profile. The
+rerun_profile_vals()
function allows users to do this.
library(nwfscDiag)
+directory <- here::here("models")
+base_model_name <- "base model"
+rerun_profile_vals(
+ mydir = file.path(model_dir, base_name),
+ model_settings = model_settings,
+ para_name = "SR_LN(R0)",
+ run_num = c(6, 4,3,2),
+ data_file_nm = "base_model_data_file.dat")
+where the run_num
is the number reported in the
+profile_SR_LN(RO))_results.csv file under the run column. Profiles are
+run out from the base model parameter value to lower or higher values to
+improve model convergence and hence, the run number reported in the csv
+is not sequential from the lower to upper bounds.
r4ss
v1.49.3+ supports running models in parallel. This
+can be particularly helpful when running jitters. In order to run
+jitters in parallel, additional specifications are needed outside the
+nwfscDiag
package and some additional R packages
+(parallelly
, future
) need to be installed:
ncores <- parallelly::availableCores(omit = 1)
+future::plan(future::multisession, workers = ncores)
+
+model_settings <- get_settings(settings = list(
+ exe = "ss3",
+ base_name = base_model,
+ run = "jitter",
+ Njitter = 100,
+ jitter_fraction = 0.10))
+
+run_diagnostics(mydir = dir, model_settings = model_settings)
+future::plan(future::sequential)
+This same approach could be done with profiles, but is not +recommended for models with convergence issues.
+The package provides the functionality to conduct model diagnostics for Stock Synthesis (SS3) models. The standard diagnostic included in this package are standard required analysis for U.S. West Coast Groundfish stock assessments managed by the Pacific Fisheries Management Council. The package was designed to perform model diagnostics and create plots and tables in a standardized format. The standardized approach will facilitate the use of these outputs in the assessment template approach sa4ss.
+The diagnostics created by the package are: - jitter runs to ensure model convergence at the MLE, - retrospective runs to examine model sensitivity to recent data, and
+- likelihood profiles across parameters.
This package does not maintain backward compatibility with previous versions of Stock Synthesis. However, if needed user can download older package versions that may work with older versions (3.30.+) of Stock Synthesis.
+nwfscDiag can be installed via github:
+install.packages("remotes")
+remotes::install_github("pfmc-assessments/nwfscDiag")
+The package depends upon a few other packages and they should be installed upon installation of the package. The dependent packages are:
+install.packages('dplyr')
+remotes::install_github('r4ss/r4ss')
+A new version of r4ss package was released on July 29, 2022. This release included some significant changes that included changes to function names and function inputs. The current version of the nwfscDiag 1.1.2 package is designed to work with the latest release of r4ss. Please see release version 1.0.1 to use earlier versions of r4ss.
+Please report any issues with this package by posting a new github issue at https://github.com/pfmc-assessments/nwfscDiag/issues.
+Check the profile range specified
+check_profile_range(mydir, model_settings)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
Nothing is explicitly returned from check_profile_range()
R/get_jitter_quants.R
+ get_jitter_quants.Rd
Tables generated to visualize results
+get_jitter_quants(mydir, model_settings, output)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
List of model output created by run_jitter()
.
Nothing is explicitly returned from get_jitter_quants()
.
R/get_param_values.R
+ get_param_values.Rd
Generate likelihood profiles +To be called from the run_diagnostics function after creating +the model settings using the get_settings function.
+get_param_values(mydir, para = NULL, vec, summary)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A character string specifying the SS3 parameter name that the +profile pertains to. The parameter name should match the name in the +control.ss_new file from SS3.
Vector of parameter values or retrospective runs the summary object contains
List created by the r4ss::SSsummarize()
function
Get model values across retrospective runs
+get_retro_quants(mydir, model_settings, output)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
List of model output created by run_retro()
.
Nothing is explicitly returned from get_retro_quants()
.
+The following objects are saved to the disk.
mohnsrho.csv
with the following columns:
type: the type of Mohn's rho
Woods Hole Mohn's rho (Legault 2009) used by the Northeast Fisheries Science Center (NEFSC), and
Hurtado-Ferro et al. (2015) used by the Alaska Fisheries Science Center (AFSC)
Quantity: the stock assessment quantity of interest
values: the Mohn's rho values
apply(utils::read.csv(file.path("..", paste0(mod_loc, "_retro"), "retrofigures4doc.csv")), 1, function(x) do.call(sa4ss::add_figure, as.list(x)))
mohnsrho.tex
for use with sa4ss::read_child()
+inside of an environment with results = "asis"
+to include a table of Mohn's rho values in a document.
sa4ss::read_child(file.path(paste0(params[["model"]], "_retro"), "mohnsrho.tex"))
Check that all of the settings are in the list
+get_settings(settings = NULL, verbose = FALSE)
A list of the current settings where each object in the list
+must be named. Those names that are not found in the stored list will be
+added. The default value of NULL
leads to a full list being
+returned.
A logical value specifying if the message should be output to +the screen or not.
A list of settings for running model diagnostics.
+get_settings(list("Njitter" = 10))
+#> $Njitter
+#> [1] 10
+#>
+#> $base_name
+#> [1] "model"
+#>
+#> $para_offset
+#> [1] FALSE
+#>
+#> $run
+#> [1] "jitter" "profile" "retro"
+#>
+#> $profile_details
+#> parameters low high step_size param_space
+#> 1 NatM_uniform_Fem_GP_1 0.40 0.4 0.01 multiplier
+#> 2 SR_BH_steep 0.25 1.0 0.05 real
+#> 3 SR_LN(R0) -2.00 2.0 0.25 relative
+#>
+#> $version
+#> [1] "3.30"
+#>
+#> $exe
+#> [1] "ss3"
+#>
+#> $verbose
+#> [1] FALSE
+#>
+#> $extras
+#> [1] "-nohess"
+#>
+#> $show_in_console
+#> [1] TRUE
+#>
+#> $printlikes
+#> [1] FALSE
+#>
+#> $jitter_fraction
+#> [1] 0.05
+#>
+#> $jitter_init_values_src
+#> NULL
+#>
+#> $oldsubdir
+#> [1] ""
+#>
+#> $newsubdir
+#> [1] "retro"
+#>
+#> $retro_yrs
+#> [1] -1 -2 -3 -4 -5
+#>
+#> $overwrite
+#> [1] TRUE
+#>
+#> $show_in_console
+#> [1] FALSE
+#>
+#> $btarg
+#> NULL
+#>
+#> $minbthresh
+#> NULL
+#>
+#> $remove_files
+#> [1] TRUE
+#>
+#> $oldctlfile
+#> [1] "control.ss_new"
+#>
+#> $newctlfile
+#> [1] "control_modified.ss"
+#>
+#> $linenum
+#> NULL
+#>
+#> $string
+#> NULL
+#>
+#> $profilevec
+#> NULL
+#>
+#> $usepar
+#> [1] FALSE
+#>
+#> $globalpar
+#> [1] FALSE
+#>
+#> $parlinenum
+#> NULL
+#>
+#> $parstring
+#> NULL
+#>
+#> $saveoutput
+#> [1] TRUE
+#>
+#> $overwrite
+#> [1] TRUE
+#>
+#> $whichruns
+#> NULL
+#>
+#> $prior_check
+#> [1] FALSE
+#>
+#> $read_like
+#> [1] TRUE
+#>
+#> $init_values_src
+#> [1] 0
+#>
+#> $subplots
+#> [1] 1 3
+#>
+
+
Create a data frame of parameters you want to profile over. The default +inputs for this function represent the typical parameters you would want +to profile over but the data frame can actually accommodate any viable +parameter in your Stock Synthesis model. Note that the defaults are, at a +minimum, the profiles needed in your assessment document if you are +presenting to the Pacific Fisheries Management Council.
+A vector of character strings that specify the SS3 +parameter names that you want to conduct profiles for.
A numeric vector specifying the low or high parameter bounds
+you want to use for the profile of each parameter in parameters
.
A numeric vector specifying the increments between the low
+and high bounds for each parameter in parameters
. These values will be
+passed to seq(from = low, to = high, by = step_size)
.
A vector of character strings that specify the way in
+which you want the parameter bounds to be translated. The available options
+are, "real"
, "mulitplier"
, and "relative"
.
"real"
indicates bounds in the parameter space,
"relative"
indicates how far to go from the base parameter, and
"multiplier"
indicates that low and high bounds are set at x\
+and below the base parameter.
Deprecated: The use_prior_like input is no longer +needed because r4ss now automatically plots the likelihood profile with and +without any parameter prior likelihood contributions regardless of the +setting in the user starter file.
A data frame with five columns,
parameters,
low,
high,
step_size, and
param_space. +Where, there is one row for each parameter that will be profiled. +The default settings provide users with a good template that they can add +to or modify by giving some reasonable inputs for the default parameters +that are requested in the Terms of Reference.
The param_space
argument indicates where the range of of the profile
+parameter should be interpreted as relative to the base model estimate vs.
+across a pre-specified range. An example is for R0 where the default setting
+below indicates that the param_space is relative where the low bound for the
+profile is set = base model log(R0) - 2 and high = base model log(R0) + 2.
+The default range for M is set as a multiplier to explore a range of (M -
+0.40 * M) - (M + 0.40 * M) at a step size of 0.005. This range may be too
+large (or small) with a step size too large (or too small) and should be
+considered if the default settings are appropriate for your specific model.
+The default setting for steepness is in 'real' space which means that the low
+and high is in the same parameter space as the parameter. A user can select
+any of the options for specifying a parameter range for any parameter.
if (FALSE) { # \dontrun{
+
+# Define each parameter in real space
+get_settings_profile(
+ parameters = c("NatM_uniform_Fem_GP_1", "SR_BH_steep", "SR_LN(R0)"),
+ low = c(0.02, 0.25, 8),
+ high = c(0.07, 1.0, 11),
+ step_size = c(0.005, 0.05, 0.25),
+ param_space = c("real", "real", "real")
+)
+
+# Example 2: Run a profile for natural mortality one with the prior likelihood and one without
+get_settings_profile(
+ parameters = c("NatM_uniform_Fem_GP_1", "NatM_uniform_Fem_GP_1"),
+ low = c(0.40, 0.40),
+ high = c(0.40, 0.40),
+ step_size = c(0.005, 0.005),
+ param_space = c("multiplier", "multiplier")
+)
+} # }
+
+
Used by profile_wrapper()
to write summary statistics to the disk.
get_summary(mydir, para, vec, profilemodels, profilesummary)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A character string specifying the SS3 parameter name that the +profile pertains to. The parameter name should match the name in the +control.ss_new file from SS3.
A numeric vector specifying the parameter values that the +profile covers.
An object returned from r4ss::SSgetoutput()
.
An object returned from r4ss::SSsummarize()
.
+ All functions+ + |
+ |
---|---|
+ + | +Check the profile range specified |
+
+ + | +Create output files with jitter quantities |
+
+ + | +Generate likelihood profiles To be called from the run_diagnostics function after creating the model settings using the get_settings function. |
+
+ + | +Get model values across retrospective runs |
+
+ + | +Check that all of the settings are in the list |
+
+ + | +Get default settings for profiles |
+
+ + | +Generate results from likelihood profiles |
+
+ + | +Run r4ss::jitter based on |
+
+ + | +Generated plots to visualize results |
+
+ + | +Generate likelihood profile plots |
+
+ + | +Create plots for retrospective runs |
+
+ + | +Create a |
+
+ + | +Format a vector of real numbers with a pretty number of decimal places |
+
+ + | +Run |
+
+ + | +Rerun some of the models in a likelihood profile |
+
+ + | +Run r4ss::retro based on |
+
+ + | +Round values |
+
+ + | +Wrapper to run each of the 3 standard diagnostic items:
|
+
+ + | +Run r4ss::jitter based on |
+
+ + | +Run |
+
+ + | +Run r4ss::retro based on |
+
Code to run jitters for a model +Output will be saved in an Rdata object called "jitter_output" +Plots and tables generated to visualize results
+jitter_wrapper(mydir, model_settings)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
Nothing is explicitly returned from jitter_wrapper
.
The following functions interact with jitter_wrapper
:
run_diagnostics: calls jitter_wrapper
See magrittr::%>%
for details.
lhs %>% rhs
The result of calling rhs(lhs)
.
Generated plots to visualize results
+plot_jitter(mydir, model_settings, output)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
List of model output created by run_jitter()
.
Nothing is explicitly returned from (plot_jitter[]).
+Create plots to be included in presentations and documents that +summarize a likelihood profile.
+plot_profile(mydir, rep, para, profilesummary)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of model output as returned by r4ss::SS_output()
.
A character string specifying the SS3 parameter name that the
+profile pertains to. The parameter name should match the name in the
+control.ss_new file from SS3.
+The name will be cleaned up for plotting purposes internally within the function.
+For example, SR_BH_steep
becomes "Steepness (h)".
Output from r4ss::SSsummarize()
.
+Ensure that the results are ordered according to the parameter of interest.
+Otherwise, the profile plots will not be smooth and lines will zig-zag back and forth.
profile_wrapper and rerun_profile_vals call plot_profile
.
Create plots for retrospective runs
+plot_retro(mydir, model_settings, output)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
List of model output created by run_retro()
.
Nothing is explicitly returned from plot_retro()
.
+The following objects are saved to the disk.
A set of figures from r4ss::SSplotComparisons
retrofigures4doc.csv
for use with sa4ss::add_figure
to add retro peels of
+spawning stock biomass (SSB) and fraction unfished,
+complete with captions and alternative text.
Create a .png
figure
pngfun(wd, file, w = 7, h = 7, pt = 12)
R/pretty_decimal.R
+ pretty_decimal.Rd
Choose the final formatting for the number of decimals that should be +displayed given a vector of real numbers. All numbers in the returned +vector will be unique.
+pretty_decimal(x)
A vector of strings containing formatted numerical values all with +an equal number of decimal places and at least one decimal place.
+pretty_decimal(c(1.0, pi, 3.14, 0.002, 0.0021, 0.02))
+#> [1] "1.0000" "3.1416" "3.1400" "0.0020" "0.0021" "0.0200"
+
+# Returns at least one decimal place even if not needed
+pretty_decimal(1)
+#> [1] "1.0"
+
+# Will return an error because duplicated entries
+if (FALSE) { # \dontrun{
+pretty_decimal(c(1.1, 1.1))
+} # }
+
+
Setting up the specifications, running the profile using r4ss::profile()
,
+and generating figures and tables can be tedious, error prone, and time
+consuming. Thus, profile_wrapper()
aims to further decrease the work
+needed to generate a profile that is easily included in a assessment report
+for the Pacific Fisheries Management Council. See the See Also section for
+information on a workflow to use this function.
profile_wrapper(mydir, model_settings)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
Nothing is explicitly returned from profile_wrapper()
.
+The following objects are saved to the disk:
*_profile_output.Rdata
*_trajectories_*
from r4ss::SSplotComparisons()
piner_panel_*.png
parameter_panel_*.png
run_diag_warning.txt
a copy of the control file saved to model_settings$newctlfile
backup_oldctlfile.ss
backup_ss.par
The following functions interact with profile_wrapper()
:
get_settings()
: populates a list of settings for model_settings
run_diagnostics()
: calls profile_wrapper()
r4ss::profile()
: the workhorse of profile_wrapper()
that does the
+parameter profiles
R/rerun_profile_vals.R
+ rerun_profile_vals.Rd
To be called after run_diagnostics()
in the instance when a model within a
+profile has bad dynamics and could benefit from attempting the run with
+different starting values. The jitter fraction will be turned on and the
+model will be reran in hopes that a better likelihood can be found. The
+summary diagnostics will be recreated as well.
rerun_profile_vals(mydir, para_name, model_settings, run_num, data_file_nm)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
SS parameter name that the profile was run across. This is
+used to located the correct folder combined with the mydir function input
+(e.g., paste0(mydir, "/", model_settings[["base_name"]], "_profile_", para_name)
).
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
An integer vector specifying the run numbers that you would +like to rerun for convergence. This input needs to match the run number for +the original profile (e.g., Report6.sso) that you would like to rerun.
A character string specifying the name of the SS3 data
+file. This is more than likely "data.ss"
.
if (FALSE) { # \dontrun{
+model_settings <- get_settings()
+temp_profile_dir <- file.path(tempdir(), "profile")
+r4ss::copy_SS_inputs(
+ recursive = TRUE,
+ verbose = FALSE,
+ dir.old = system.file(package = "r4ss", "extdata", "simple_small"),
+ dir.new = file.path(temp_profile_dir, "simple_small"),
+ overwrite = TRUE
+)
+ss3_path <- r4ss::get_ss3_exe(
+ dir = file.path(temp_profile_dir, "simple_small")
+)
+model_settings <- get_settings(
+ settings = list(
+ base_name = "simple_small",
+ exe = gsub("\\.exe", "", basename(ss3_path)),
+ run = c("profile"),
+ profile_details = get_settings_profile(
+ parameters = c("NatM_uniform_Fem_GP_1"),
+ low = c(0.20),
+ high = c(0.25),
+ step_size = c(0.02),
+ param_space = c("multiplier")
+ )
+ )
+)
+run_diagnostics(
+ mydir = temp_profile_dir,
+ model_settings = model_settings
+)
+rerun_profile_vals(
+ mydir = temp_profile_dir,
+ model_settings = model_settings,
+ para_name = "NatM_uniform_Fem_GP_1",
+ run_num = c(1),
+ data_file_nm = "data.ss"
+)
+} # }
+
Create a folder containing retrospective runs for a given base-model folder.
+Runs are created using settings specified in model_settings
and
+is formatted for inclusion in a document.
retro_wrapper(mydir, model_settings)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
Nothing is explicitly returned from retro_wrapper
.
+The following objects are saved to the disk.
mohnsrho.csv
with the following columns:
type: the type of Mohn's rho
Woods Hole Mohn's rho (Legault 2009) used by the Northeast Fisheries Science Center (NEFSC), and
Hurtado-Ferro et al. (2015) used by the Alaska Fisheries Science Center (AFSC)
Quantity: the stock assessment quantity of interest
values: the Mohn's rho values
A set of figures from r4ss::SSplotComparisons
retrofigures4doc.csv
for use with sa4ss::add_figure
to add retro peels of
+spawning stock biomass (SSB) and fraction unfished,
+complete with captions and alternative text.
apply(utils::read.csv(file.path("..", paste0(mod_loc, "_retro"), "retrofigures4doc.csv")), 1, function(x) do.call(sa4ss::add_figure, as.list(x)))
mohnsrho.tex
for use with sa4ss::read_child()
+inside of an environment with results = "asis"
+to include a table of Mohn's rho values in a document.
sa4ss::read_child(file.path(paste0(params$model, "_retro"), "mohnsrho.tex"))
retro_output.Rdata
with a list of R objects.
The following functions interact with retro_wrapper
:
run_diagnostics: calls retro_wrapper
r4ss::retro: the workhorse of retro_wrapper
that does the peels
Round values
+round_any(x, accuracy, f = round)
Jitter
Profiles across requested SS3 parameters
Retrospectives
R/run_diagnostics.R
+ run_diagnostics.Rd
Wrapper to run each of the 3 standard diagnostic items:
Jitter
Profiles across requested SS3 parameters
Retrospectives
run_diagnostics(mydir, model_settings)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
A vector of likelihoods for each jitter iteration.
+Code to run jitters for a model +Output will be saved in an Rdata object called "jitter_output"
+run_jitter(mydir, model_settings)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
A list of quantities across jitters called jitter_output
Setting up the specifications, running the profile using r4ss::profile()
,
+and generating figures and tables can be tedious, error prone, and time
+consuming. Thus, profile_wrapper()
aims to further decrease the work
+needed to generate a profile that is easily included in a assessment report
+for the Pacific Fisheries Management Council. See the See Also section for
+information on a workflow to use this function.
run_profile(mydir, model_settings, para)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
A character string specifying the SS3 parameter name that the +profile pertains to. The parameter name should match the name in the +control.ss_new file from SS3.
Nothing is explicitly returned from profile_wrapper()
.
+The following objects are saved to the disk:
*_profile_output.Rdata
*_trajectories_*
from r4ss::SSplotComparisons()
piner_panel_*.png
parameter_panel_*.png
run_diag_warning.txt
a copy of the control file saved to model_settings$newctlfile
backup_oldctlfile.ss
backup_ss.par
The following functions interact with profile_wrapper()
:
get_settings()
: populates a list of settings for model_settings
run_diagnostics()
: calls profile_wrapper()
which calls this function.
r4ss::profile()
: the workhorse of profile_wrapper()
that does the
+parameter profiles
Create a folder containing retrospective runs for a given base-model folder.
+Runs are created using settings specified in model_settings
and
+is formatted for inclusion in a document.
run_retro(mydir, model_settings)
Directory where model files are located.
+There is no default entry for mydir
.
+An example of user input could be
+mydir = file.path("C:/my_models", "base_model")
.
A list of all model settings. +Typically, created using get_settings but users can create their own list, +as long as it has all of the necessary components for the function at hand.
Nothing is explicitly returned from retro_wrapper
.
+The following objects are saved to the disk.
mohnsrho.csv
with the following columns:
type: the type of Mohn's rho
Woods Hole Mohn's rho (Legault 2009) used by the Northeast Fisheries Science Center (NEFSC), and
Hurtado-Ferro et al. (2015) used by the Alaska Fisheries Science Center (AFSC)
Quantity: the stock assessment quantity of interest
values: the Mohn's rho values
A set of figures from r4ss::SSplotComparisons
retrofigures4doc.csv
for use with sa4ss::add_figure
to add retro peels of
+spawning stock biomass (SSB) and fraction unfished,
+complete with captions and alternative text.
apply(utils::read.csv(file.path("..", paste0(mod_loc, "_retro"), "retrofigures4doc.csv")), 1, function(x) do.call(sa4ss::add_figure, as.list(x)))
mohnsrho.tex
for use with sa4ss::read_child()
+inside of an environment with results = "asis"
+to include a table of Mohn's rho values in a document.
sa4ss::read_child(file.path(paste0(params[["model"]], "_retro"), "mohnsrho.tex"))
retro_output.Rdata
with a list of R objects.
The following functions interact with retro_wrapper
:
run_diagnostics: calls retro_wrapper
r4ss::retro: the workhorse of retro_wrapper
that does the peels