Format stock assessment output file to a standardized tibble.

convert_output(
  files,
  models = NULL,
  fleet_names = NULL,
  save_dir = NULL,
  start_year = NULL,
  file = lifecycle::deprecated(),
  model = lifecycle::deprecated()
)

Arguments

files

List of paths. Assessment model output file paths. Currently accepts SS3 r4ss::ss_output() or Report.sso file (being deprecated), BAM .rda file, Rceattle model object, and FIMS output (the tibble returned by FIMS::get_estimates(), a FIMSFit object, or an .rds file with either). If multiple elements, all valid models will be read, converted, and appended together.

names(files) will be used as the name of the model in the output.

models

Character vector. Assessment model used in evaluation

Default: NULL

Options: "ss3", "bam", "fims", "rceattle"

Should match length of files if >1 model.

fleet_names

List of named character vectors. Names of fleets in the assessment model as shortened in the output file or names of fleets to replace the native fleet names in the output. For example, if fleet names in the model are 1, 2, 3 then fleet_names = c("fleet1" = 1, "fleet2" = 2, "fleet3" = 3).

Default: NULL

Should match length of files if >1 model.

save_dir

Path. Full file path to save the converted output file. If saved file name is not indicated, the file will be saved as "std_output.rda" in the file path provided.

Default: NULL

start_year

Number. First year of the model, for FIMS output only. FIMS reports years as indices (1 = first model year), which are converted to years when start_year is given.

Default: NULL (years are left as indices)

file

[Deprecated] This argument was deprecated in favor of the files argument in order to clarify that multiple files can be processed simultaneously.

model

[Deprecated] This argument was deprecated in favor of the models argument in order to clarify that multiple models can be processed simultaneously.

Value

A reformatted and standardized tibble of assessment model results for application in building stock assessment reports and to easily adapt results among regional assessments.

Details

The resulting object is a long-format, transformed and machine readable version of a model output file. Converted data frame is always returned. It will also be saved if save_dir is not NULL.

For FIMS, each data point (index, landings, and age and length compositions) is split into an observed row (e.g., "index_observed") and a predicted row (e.g., "index_predicted"), as for the other models. Observed rows hold the observation error (a log-scale standard error for lognormal data) in uncertainty and the negative log-likelihood in likelihood. Other estimates are relabeled with fims_var_names.csv (e.g., "expected_recruitment" becomes "recruitment").

Author

Samantha Bredeck

Examples

if (FALSE) { # \dontrun{
convert_output(
  files = here::here("model1", "Report.sso"),
  models = "ss3",
  fleet_names = c("TWL", "NONTWL"),
  save_dir = here::here("standard_output.rda")
)
convert_output(
  files = list(
    "model1" = here::here("model1", "Report.sso"),
    "model2" = here::here("model2", "Report.sso")
  ),
  models = c("ss3", "ss3"),
  fleet_names = list(
    "model1" = c("TWL", "NONTWL"),
    "model2" = c("Fishery1", "Survey1", "Survey2")
  ),
  save_dir = here::here("standard_output.rda")
)
} # }