Skip to contents

Functino to run retrospective analyses

Usage

do_retrospective(
  n_retro,
  data,
  parameters,
  mapping,
  random = NULL,
  do_par,
  n_cores,
  do_francis,
  n_francis_iter = NULL
)

Arguments

n_retro

Number of retrospective peels to do

data

Data list for RTMB model

parameters

Parameter list for RTMB model

mapping

Mapping list for RTMB model

random

Random effects as a character vector - default is NULL

do_par

Whether to do parrallelization, boolean

n_cores

Number of cores to use for parrallelization

do_francis

Whether to do francis reweighitng within a given retrospective peel, boolean

n_francis_iter

Number of francis iterations to do

Value

Dataframe of retrospective estiamtes of SSB and recruitment

Examples

if (FALSE) { # \dontrun{
 # Do retrospective here
 ret <- do_retrospective(n_retro = 7, data, parameters, mapping, random = NULL, do_par = TRUE, n_cores = 7, do_francis = TRUE, n_francis_iter = 5)
 ggplot(ret, aes(x = Year + 1959, y = value, group = peel, color = 2024 - peel)) +
   geom_line(lwd = 1.3) +
   facet_wrap(~Type) +
   guides (color = guide_colourbar(barwidth = 10, barheight = 1.3)) +
   labs(x = 'Year', y = 'Value', color = 'Retrospective Year') +
   scale_color_viridis_c() +
   theme_bw(base_size = 15) +
   theme(legend.position = 'top')

 ret %>%
   dplyr::mutate(Year = Year + 1959, terminal = 2024 - peel, cohort = Year - 2, years_est = terminal-Year) %>%
   filter(Type == 'Recruitment', cohort %in% c(2014:2022), terminal != Year) %>%
   ggplot(aes(x = years_est - 1, y = value, group = Year, color = factor(cohort))) +
   geom_line(lwd = 1.3) +
   geom_point(size = 4) +
   theme_bw(base_size = 15) +
   labs(x = 'Years since cohort was last estimated', y = 'Recruitment (millions)', color = 'Cohort')
} # }