Modifying and running stock synthesis models: part 2
Michelle Sculley
January 2025
Next we will cover editing and running stock assessments using a script based workflow developed for the BILLWG.
This code is available for the BILLWG in the SS_Intl_Auto repository. It is still in development - but can be run for NP Swordfish and WCNPO striped marlin.
This was developed specifically to run BILLWG assessments to better distribute the workload during assessment meetings.
Editing raw text files can lead to mistakes - its better to write a clean file each run.
Forgetting to change a parameter line
Missing a value in a parameter line
It can be time consuming to run diagnostics by hand
We are set up to run large numbers of models on super computers
We can run models on codespaces (no need to install software!)
Keeps workflows consistent between WG members for ease of collaboration
Keeps science transparent - easy to replicate your results
Write SS files
Run SS models
Run diagnostics
Print summary reports (with Quarto)
Print r4ss plots
Run projections (in development)
Some external data files are needed to run this code:
These are stored in the /Data folder in the repository
Catch (csv)
CPUE (csv)
Length Composition (csv)
CTL_Inputs (xlsx)
CTL_Parameters (xlsx)
Any other csv files for other input data - such as age comp or generalize size comp (in development)
This file contains all the long and short line parameters used in the control file.
Each species is its own sheet
We will be editing the sheet for our species “EXM”
Each line is a parameter
category tells R which parameter group it belongs to
OPTION tells R which option to use if more than one set of parameters in a particular type is used (i.e. alternative growth parameters)
The subsequent colmns are the parameters lines from the SS control file
To run alternative models add a new set of parameters for your parameter of choice - do NOT change the “Base” option parameters
Which parameters we use in the SS model is determined by the PARAM_option inputs in the Build_All_SS function
This file contains all the additional information needed to populate the control file
Each sheet is a model run
You will need to add a new sheet if you need to change any of the parameters in this sheet
ASPM - no additional inputs needed
Runs test (CPUE and Size Data) – No additional inputs
Stock status quantities – no additional inputs
Jitter
Njitter = number of jitter models to run
jitterFraction = how much to change initial parameters for each run
Retrospectives/Hindcasting
Likelihood Profiles
profile_name = name of parameter you want to profile on
profile.vec = vector with two values:
[1] number of models you want run (excluding MLE)
[2] increment value between parameters (i.e. c(4,0.1) for a model where SR_LN(R0) = 8 would run - profile models at 7.8, 7.9, 8.0, 8.1, and 8.2)
You should only modify the file Run_SS_Model.R
Set the base directory you are working in
Provide a vector of your fleet names
Modify model.info to the options you want to use while running the model
Source 01_Build_All_SS.r
Run Build_All_SS with appropriate inputs
You are able to run jitters, retrospectives, and profiles in parallel with this code.
BUT, The built in functions do this in r4ss are not set up to run in parallel.
If you choose to set run_parallel = TRUE the code will use bespoke functions based upon their r4ss equivalents, written to run in parallel, which are contained within this repository:
parallel_jitter.R
parallel_profile.R
parallel_retro.R
parallel_SS_parlines.R (supporting function)
If you set run_parallel = FALSE the r4ss functions will be used by default
Using the Run_SS_Model.R script, run a sensitivity analysis on the base model for species “EXM”
Options for runs:
GROWTH – increase Lamax by 10%
GROWTH – decrease Lamax by 10%
MORT – increase by 10%
MORT – decrease by 10%
MAT – increase L50 by 10%
MAT – decrease L50 by 10%
SEL – change F1 to option 24 – logistic
SR – increase sigmaR to 0.9
SR – decrease sigmaR to 0.3
Steepness – change to 0.8
ISC Open Science Worflows Workshop 2025