This function creates an index of discards sampled from the expected available discards for specified fleets in specified years. Let \(D_y\) be the discard from the operating model for year y. Then the sampled value is calculated as: \(D_y*exp(stats::rnorm(1, 0, sds_obs)-sds_obs^2/2)\). The second term adjusts the random samples so that their expected value is \(D_y\), i.e., the log-normal bias correction.

sample_discard(
  dat_list,
  outfile = NULL,
  fleets,
  years,
  sds_obs,
  seas = list(1)
)

Arguments

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.

outfile

A character string specifying the file name to use when writing the information to the disk. The string must include the proper file extension. No file is written using the default value of NULL, which leads to increased speed because writing the file takes time and computing resources.

fleets

*A vector of integers specifying which fleets to include. The order of the fleets pertains to the input order of other arguments. An entry of fleets=NULL leads to zero samples for any fleet.

years

*A list the same length as fleets giving the years as numeric vectors. If no fleet collected samples, keep the value to years=NULL.

sds_obs

A list the same length as fleets. The list should contain either single values or numeric vectors of the same length as the number of years which represent the standard deviation of the observation error. Single values are repeated for all years.

seas

A list the same length as fleets. The list should contain either single numeric values or numeric vectors, where the length of each vector matches the length of each vector present in years. Single values are repeated for all years. This parameter operates the same as sds_obs but it specifies the season rather than the standard deviation of the observations.

Value

A modified .dat file if !is.null(outfile). A list object containing the modified .dat file is returned invisibly.

Author

Kelli F. Johnson