Takes Stock Synthesis .ctl and forecast.ss files, along with a list structure which houses the data file as read in by r4ss::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.

change_e(
  ctl_file_in = "em.ctl",
  ctl_file_out = "em.ctl",
  dat_list = NULL,
  for_file_in = "forecasts.ss",
  par_name = NULL,
  par_int = "NA",
  par_phase = "NA",
  forecast_num = 0,
  verbose = FALSE
)

Arguments

ctl_file_in

A string providing the path to the input Stock Synthesis .ctl file.

ctl_file_out

A string providing the path to the output Stock Synthesis control file. If the value is NULL, the file will not be written to the disk.

dat_list

A Stock Synthesis data list object as read in from SS_readdat. Be sure to correctly specify which section of the data file you want to work with when reading it in using the section argument. Where, section = 1 reads in the input values used to run the model and section = 2 reads in the expected values generated given all the input to the OM. section = 3 is not used within ss3sim, but this section provides bootstrapped data sets that have been sampled internally within SS.

for_file_in

A string providing the path to the input SS forecast.ss file.

par_name

A vector of character values corresponding to parameter names that you wish to initialize at different values or change the phase in which they are estimated. Entries are searched for in ctl_file_in, and therefore, it is best to use full parameter names as they are specified in the file.

par_int

A vector of initial values, one for each entry in par_name. Values of NA leave the INIT value for that parameter at the value found in the .ctl file.

par_phase

A vector of phase values, one for each parameter in par_name. Values can be NA if you do not wish to change the phase for a given parameter. Negative values will fix the parameter at the INIT value.

forecast_num

Number of years to perform forecasts. For those years, the data will be removed from the dat_list, enabling Stock Synthesis to generate forecasts rather than use the data to fit the model.

verbose

When TRUE messages will be returned from the function. Often useful for debugging. The default is FALSE.

Value

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

See also

Other change functions: change_data(), change_em_binning(), change_f(), change_o(), change_retro(), change_tv()

Author

Kelli F. Johnson

Examples

d <- system.file("extdata", "models", "cod-om", package = "ss3sim")
change_e(
  ctl_file_in = file.path(d, "codOM.ctl"),
  ctl_file_out = file.path(tempdir(), "change_e.ctl"),
  dat_list = codomdat,
  for_file_in = file.path(d, "forecast.ss"),
  par_name = c("_steep", "Size_DblN_peak_Fishery(1)"),
  par_int = c(0.3, 40), par_phase = c(3, 2),
  forecast_num = 0
)
# clean up the temporary files
file.remove(file.path(tempdir(), "change_e.ctl"))
#> [1] TRUE