Learn R Programming

ss3sim (version 0.9.0)

change_tv: Methods to include time-varying parameters in an SS3 operating model

Description

change_tv takes SS3 .ctl, .par, and .dat files and implements time-varying parameters using environmental variables. change_tv is specifically set up to work with an operating model .ctl file.

Usage

change_tv(change_tv_list, ctl_file_in = "control.ss_new",
  ctl_file_out = "om.ctl", dat_file_in = "ss3.dat",
  dat_file_out = "ss3.dat", par_file_in = "ss3.par",
  par_file_out = "ss3.par", str_file_in = "starter.ss",
  str_file_out = "starter.ss", rpt_file_in = "Report.sso")

Value

  • The function creates modified versions of the .par, .starter, .ctl, and .dat files.

Which arguments to specifiy in case files

All function argument descriptions that start with an asterisk (*) will be passed through the case files to run_ss3sim. If one of these arguments is not specified in a case file, then a value of NULL will be passed, which may or may not be an appropriate value. Other arguments will be ignored if specified.

Specifying the <code>change_tv_list</code>

Parameters will change to vary with time according to the vectors of deviations passed to change_tv_list. Vectors of deviations, also referred to as environmental data, must have a length equal to endyr-startyr+1, where endyr and startyr are specified the .dat file. Specify years without deviations as zero.

Parameter names must be unique and match the full parameter name in the .ctl file. Names for stock recruit parameters must contain "devs", "R0", or "steep", and only one stock recruit parameter can be time-varying per model.

This feature will include an *additive* functional linkage between environmental data and the parameter where the link parameter is fixed at a value of one and the par value is specified in the .par file: $par'[y] = par + link * env[y]$.

For catchability ($q$) the *additive* functional linkage is implemented on the log scale: $ln(q'[y]) = ln(q) + link * env[y]$

Passing arguments to <code>change_tv</code> through <code><a href="/link/run_ss3sim?package=ss3sim&version=0.9.0" rd-options="" data-mini-rdoc="ss3sim::run_ss3sim">run_ss3sim</a></code>

(1) create a case file with an arbitrary letter not used elsewhere (anything but D, E, F, or R) and (2) include the line function_type; change_tv in your case file. For example, you might want to use M for natural mortality, S for selectivity, or G for growth.

Details

Although there are three ways to implement time-varying parameters within SS3, ss3sim and change_tv only use the environmental variable option. Within SS3, time-varying parameters work on an annual time-step. Thus, for models with multiple seasons, the time-varying parameters will remain constant for the entire year.

The ctl_file_in argument needs to be a .ss_new file because the documentation in .ss_new files are automated and standardized. This function takes advantage of the standard documentation the .ss_new files to determine which lines to manipulate and where to add code in the .ctl, .par, and .dat files, code that is necessary to implement time-varying parameters.

ss3sim uses annual recruitment deviations and may not work with a model that ties recruitment deviations to environmental covariates. If you need to compare the environment to annual recruitment deviations, the preferred option is to transform the environmental variable into an age 0 pre-recruit survey. See page 55 of the SS3 version 3.24f manual for more information.

See Also

Other change functions: change_data, change_em_binning, change_e, change_f, change_maturity, change_retro

Examples

Run this code
# Create a temporary folder for the output and set the working directory:
temp_path <- file.path(tempdir(), "ss3sim-tv-example")
dir.create(temp_path, showWarnings = FALSE)
wd <- getwd()
setwd(temp_path)

# Find the SS3 "Simple" model in the package data:
d <- system.file("extdata", package = "ss3sim")
simple <- paste0(d, "/Simple")
dir.create("Simple")
file.copy(simple, ".", recursive = TRUE)
setwd("Simple")

# Run SS3 to create control.ss_new and Report.sso:
system("ss3_24o_safe starter.ss -noest")

change_tv(change_tv_list = list("NatM_p_1_Fem_GP_1" = c(rep(0, 20),
      rep(.1, 11)), "SR_BH_steep"=rnorm(31, 0, 0.05)), ctl_file_in =
  "control.ss_new", ctl_file_out = "example.ctl", dat_file_in =
  "simple.dat", dat_file_out = "example.dat")

# Clean up:
setwd("../")
unlink("Simple")
setwd(wd)

Run the code above in your browser using DataLab