sample_gadget: Create length distributions and sample Gadget output

Description Usage Arguments Details Value Examples

Description

These functions create length distributions from Gadget StockStdPrinter output and sample that output to simulate surveys. Error can be added to simulated surveys in survey_gadget and age and length subsamples can be taken with strip_age_length_data to more closely mimic real world surveys

Usage

1
2
3
4
5
6
7
8
9
survey_gadget(stock_data, length_groups, survey_suitability, survey_sigma,
  variable = "number", keep_zero_counts = FALSE)

strip_age_length_data(stock_data, length_samples = 1, age_samples = 1,
  quiet = FALSE)

replicate_datasets(stock_data, length_groups, survey_suitability, survey_sigma,
  length_samples = 1, age_samples = NULL, quiet = FALSE, n = 10,
  keep_zero_counts = FALSE)

Arguments

stock_data

A data.frame of stock data retrieved via get_stock_std or read_gadget_stock_std

length_groups

Numeric vector of length groups to distribute by. The difference in values probably should be the same as dl in Gadget model

survey_suitability

Numeric vector the same length as length_groups representing the selection probability for each length in length_groups

survey_sigma

Numeric value of multiplicative error to place on samples

variable

Character vector of the variable on which to distribute length groups. Default is "number". Can be "number.consumed" or "biomass.consumed"

keep_zero_counts

Logical. Keep year/step/area/age combinations with no individuals

length_samples

Numeric. If length_samples <= 1, that proportion of stock_data will be sampled for each year/step/area combination. If length_samples > 1, then a number of length samples equal to the integer value provided will be sampled for each year/step/area combination.

age_samples

Numeric. If age_samples <= 1, that proportion of length_samples will be sampled for each year/step/area combination. If age_samples > 1, then a number of age samples equal to the integer value provided will be sampled for each year/step/area combination from the length data already sampled. Note that if age_samples >= 1 then this corresponds to the proportion of length samples to also sample for age. Therefore the actual proportion of age samples relative to sampled numbers is length_samples * age_samples. Sampling is similar for if length_samples and age_samples > 1; however, if length_samples is given as an integer value then age_samples must be <= length_samples

quiet

Logical. If either length_samples or age_samples are equal to 1, then this will not strip any length or age data, respectively, and will issue a warning stating so. quiet = TRUE suppresses this warning.

n

Integer. The number of times to replicate the sampling procedure

Details

Length-structured population information from Gadget is output as mean length and standard deviation for each year, step, area, and age combination. survey_gadget takes output from get_stock_std (or read_gadget_stock_std) and distributes the number for each respective combination into numbers at each length specified by length_groups, simulates surveys given the selectivity provided in survey_suitability and error given by survey_sigma. If it is desired to have a subsample of length and age data to more closely mimic real world scenarios, then the output from survey_gadget can be fed into strip_age_length_data and subsamples of length and age data will be returned according to the given proportions. The entire process can be replicated n number of times using replicate_datasets

Value

survey_gadget returns a data.frame similar to stock_data, but disaggregated by length based on the std. dev. found in the StockStdPrinter. strip_age_length_data returns a named list of two data.frames. One for length data and one for age data. replicate_datasets returns a names list of length 3, each element containing a data.frame with nrows the number of replications times the nrow of stock_data. The first of these data.frames is for survey indices, the second for length data, and the third for age data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
path <- system.file(gad_mod_dir, package = "gadgetSim")
cod_stock_std <- get_stock_std(main = "main",
                               path = path)
lengrps <- seq(0.5, 150.5, by = 1)
suitability <- logistic_selectivity(lengrps, 0.15, 20, 0.1)
cod_samples <- survey_gadget(cod_stock_std$cod, lengrps, suitability, 0.1)
cod_comp_data <-
  strip_age_length_data(cod_samples, length_samples = 0.2, age_samples = 0.2)

# the above process can be automated n number of times
cod_comp_data <-
    replicate_datasets(cod_stock_std$cod, lengrps, suitability,
                       survey_sigma = 0.1, length_samples = 0.2,
                       age_samples = 0.2, n = 10)

inspktrgadget/gadgetSim documentation built on May 10, 2019, 9:51 a.m.