Learn R Programming

ss3sim (version 1.0.3)

change_data: Change the data that is available as output from an SS operating model.

Description

change_data alters the data structure for a data list as read in by SS_readdat, for use in preparing the data file for an SS operating model. Original data is removed and dummy data is added, as specified, to the SS .dat file. This causes SS to produce expected values (OM "truth") when the operating model is run, from which data can be sampled. For each data type altered, change_data will add data for the fleets and years given; potentially adding many rows of redundant data. Currently, .dat files with multiple sexes cannot be manipulated with change_data. calculate_data_units is used internally in ss3sim_base to create a superset of fleets and years from sample arguments, and clean_data to strip out unused data after change_data is called (see examples below). change_data is called internally automatically, but can also be used by an ss3sim user to manipulate data as a case, or to prepare a new OM for use in a simulation. See the vignette for more details.

Usage

change_data(dat_list, outfile = NULL, fleets, years, types,
  age_bins = NULL, len_bins = NULL, pop_binwidth = NULL,
  pop_minimum_size = NULL, pop_maximum_size = NULL,
  lcomp_constant = NULL, tail_compression = NULL, nsex = 1)

Value

An invisible data list, and a file is written to the disk if an entry other than NULL is provided for outfile.

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

The robustification constant is added to both the observed and expected proportions of length composition data, before being normalized internally. It is designed to help stabilize the model, but is unclear how and when to use it for optimal effect. The same value is used for all length data.

See Also

sample_lcomp, sample_agecomp

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

Examples

Run this code
# NOT RUN {
d <- system.file("extdata", package = "ss3sim")
fleets <- 1:2
years <- c(5, 10, 15)
types <- c("len", "age")
file_in <- r4ss::SS_readdat(file.path(d, "models", "cod-om", "codOM.dat"),
  version = NULL, verbose = FALSE)

# Basic test with just length data, default bins:
out <- change_data(file_in, outfile = NULL, types = "len",
  years = years, fleets = fleets)
print(out$lbin_vector)
print(out$lencomp)

# Change the length bins:
out <- change_data(file_in, outfile = NULL, types = "len",
  years = years, fleets = fleets, len_bins = 3:6)
out$lbin_vector
out$lencomp

# Change the population length bins:
out <- change_data(file_in, outfile = NULL, types = "len",
  years = years, fleets = fleets, pop_binwidth = 1, pop_minimum_size = 5,
  pop_maximum_size = 210)
out$binwidth
out$maximum_size
out$minimum_size
# }

Run the code above in your browser using DataLab