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

Description Usage Arguments Details Value Which arguments to specifiy in case files Author(s) See Also Examples

View source: R/change_e.r

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

1
2
3
4
5
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, natM_type = NULL, natM_n_breakpoints = NULL,
  natM_lorenzen = NULL, natM_val = NULL)

Arguments

ctl_file_in

A string providing the path to the input SS .ctl file.

ctl_file_out

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

dat_list

An SS data list object as read in from SS_readdat in the r4ss package. Make sure you select option section=2.

for_file_in

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

par_name

*A vector of values, separated by commas. Each value corresponds to a parameter that you wish to turn on or off in the ctl_file_in. The values will later be turned into character values and used to search for specific lines for each parameter in the ctl_file_in, therefore it is best to use full parameter names as they are specified in ctl_file_in.

par_int

*A vector of initial values, one for each parameter in par_name. Values can be NA if you do not wish to change the initial value for a given parameter.

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.

forecast_num

*Number of years to perform forecasts. For those years, the data will be removed from the dat_list, enabling SS3 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.

natM_type

Deprecated. Should have value NULL.

natM_n_breakpoints

Deprecated. Should have value NULL.

natM_lorenzen

Deprecated. Should have value NULL.

natM_val

Deprecated. Should have value NULL.

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".

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.

Author(s)

Kelli Johnson

See Also

Other change functions: change_data, change_em_binning, change_f_par, change_f, change_o, change_retro, change_tv

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 

d <- system.file("extdata", "models", "cod-om", package = "ss3sim")
data.old <- r4ss::SS_readdat(
  system.file("extdata", "models", "cod-om", "codOM.dat",
    package = "ss3sim"),
  version = NULL, verbose = FALSE)
change_e(
  ctl_file_in = file.path(d, "codOM.ctl"),
  ctl_file_out = file.path(tempdir(), "change_e.ctl"),
  dat_list = data.old,
  for_file_in = file.path(d, "forecast.ss"),
         natM_type = NULL, natM_n_breakpoints = NULL,
         natM_lorenzen = NULL, natM_val = NULL,
         par_name = c("_steep", "SizeSel_P1_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"))

## End(Not run)

ss3sim documentation built on Nov. 9, 2019, 1:06 a.m.