This function cleans up the catch data for a specific species and then performs resampling tests,

clean_and_resample(
  spp_info,
  catch,
  seq_from = 0.1,
  seq_to = 1,
  seq_by = 0.1,
  tot_dataframes = 91,
  replicate_num = 10,
  grid_yrs,
  dir_out,
  test = FALSE,
  n_knots = 500,
  model_type = "wrapper_sdmtmb",
  bio = NULL
)

Arguments

spp_info

A data frame row containing information about the species.

catch

A data frame containing the catch data.

seq_from

A numeric value specifying the start of the sequence for data frames.

seq_to

A numeric value specifying the end of the sequence for data frames.

seq_by

A numeric value specifying the step size of the sequence for data frames.

tot_dataframes

An integer specifying the total number of data frames to generate.

replicate_num

An integer specifying the number of replicates.

grid_yrs

A data frame or list containing grid years information.

dir_out

A character string specifying the directory for output files.

test

Logical. TRUE/FALSE. If TRUE, will only run first two resampling tests.

n_knots

Numeric. Default = 500.

model_type

String. Default = "wrapper_sdmtmb", but can be any preset wrapper_*() function or a premade home built function.

bio

A data frame containing the biological data, if applicable. NULL is default.

Value

A list of data frames containing the cleaned and resampled catch data.

Details

This function performs the following steps:

  • Cleans up the catch data for the specified species using `cleanup_by_species`.

  • Performs resampling tests on the cleaned data using `resample_tests`.

Examples

dir_out <- here::here("vignettes", "output")
catch <- surveyresamplr::noaa_nwfsc_catch
bio <- surveyresamplr::noaa_nwfsc_bio
grid_yrs <- replicate_df(
  dat = surveyresamplr::noaa_nwfsc_catch, time_name = "year",
  time_values = unique(catch$year)
)
#> Error in replicate_df(dat = surveyresamplr::noaa_nwfsc_catch, time_name = "year",     time_values = unique(catch$year)): could not find function "replicate_df"
spp_list <- data.frame(
  srvy = "CA",
  common_name = "arrowtooth flounder",
  file_name = "arrowtooth_flounder",
  filter_lat_gt = 34,
  filter_lat_lt = NA,
  filter_depth = NA,
  model_fn = "total_catch_wt_kg ~ 0 + factor(year) + pass",
  model_family = "delta_gamma",
  model_anisotropy = TRUE,
  model_spatiotemporal = "iid, iid"
)
clean_and_resample(
  spp_info = spp_list,
  catch,
  seq_from = 0.1,
  seq_to = 1,
  seq_by = 0.1,
  tot_dataframes = 91,
  replicate_num = 10,
  grid_yrs = grid_yrs,
  dir_out = dir_out,
  bio = bio
)
#> CA arrowtooth flounder
#> Error: object 'grid_yrs' not found