Learn R Programming

ss3sim (version 0.9.0)

change_e: Methods to alter which parameters are estimated in a SS3 .ctl file.

Description

Takes SS3 .ctl and forecast.ss files, along with a list structure which houses the data file as read in by SS_readdat and changes which parameters are estimated, how natural mortality is estimated, and if forecasts are performed. The function can be called by itself or within run_ss3sim to alter an estimation model .ctl file. If used with run_ss3sim the case file should be named E. A suggested (default) case letter is E for estimation.

Usage

change_e(ctl_file_in = "em.ctl", ctl_file_out = "em.ctl", dat_list = NULL,
  for_file_in = "forecasts.ss", natM_type = "1Parm",
  natM_n_breakpoints = NULL, natM_lorenzen = NULL, natM_val = c(NA, NA),
  par_name = NULL, par_int = "NA", par_phase = "NA", forecast_num = 0,
  run_change_e_full = TRUE, verbose = FALSE)

Value

  • Altered versions of SS3 .ctl and forecast.ss files are written to the disk and the altered dat_list is returned invisibly.

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.

Details

Turning parameters on and off is the main function of change_e. change_e was not created with the capability of adding parameters to a .ctl file. The function can only add parameters for age specific natural mortality, and only for models with one growth morph. Furthermore, the function is designed to add complexity to the natural mortality type and not remove complexity. Therefore, the function will fail if natural mortality in the ctl_file_in is not specified as "1Param" and natM_type is anything other than NULL or "1Param".

See Also

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

Examples

Run this code
library(r4ss)
# 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)

d <- system.file("extdata", package = "ss3sim")
ctl_file <- paste0(d, "/models/cod-om/codOM.ctl")
data.old <- r4ss::SS_readdat(file.path(d, "models", "cod-om", "codOM.dat"))
change_e(ctl_file_in = ctl_file, ctl_file_out = "change_e.ctl",
         dat_list = data.old, for_file_in = "forecast.ss",
         natM_type = "n_breakpoints", natM_n_breakpoints = c(1, 4),
         natM_lorenzen = NULL, natM_val = c(.2, 3, 0.4, 5),
         par_name = c("_steep", "SizeSel_1P_1_Fishery"),
         par_int = c(0.3, 40), par_phase = c(3, 2),
         forecast_num = 0, run_change_e_full = TRUE )
# clean up
file.remove("change_e.ctl")
setwd(wd)

Run the code above in your browser using DataLab