On this page

Run a retrospective analysis of an ACL fit; a short form of retro_model(model_type = "acl").

Usage

retro_acl(
  nyear = 5,
  data.CatL,
  data.wgt,
  data.mat,
  rec.age,
  nage,
  M,
  sel_L50,
  sel_L95,
  parameters = NULL,
  parameters.L = NULL,
  parameters.U = NULL,
  map = NULL,
  len_mid = NULL,
  len_border = NULL,
  plot = FALSE,
  line_size = NULL,
  point_size = NULL,
  point_shape = 21,
  facet_scales = "free",
  facet_ncol = NULL,
  facet_nrow = NULL,
  train_times = 1,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  font_family = NULL,
  title_size = NULL,
  axis_title_size = NULL,
  axis_text_size = NULL,
  strip_text_size = NULL,
  legend_text_size = NULL,
  x_breaks = NULL,
  base_theme = NULL,
  title_hjust = NULL,
  rho_digits = 4,
  rho_position = "top_right",
  rho_size = 3.5,
  ncores = 1,
  ...
)

Arguments

ArgumentDefaultDescription
nyear5

Integer. Number of retrospective peels. Default 5. The number of time steps that each peel removes follows the peel_step argument of retro_model() (default 1).

data.CatLrequired

Survey index table (length labels followed by one column per time step), or the input bundle used by run_acl() or run_alscl(), as in retro_acl(x, nyear = 3).

data.wgtrequired

Weight table, with the same length bins and time steps as the survey index table.

data.matrequired

Maturity table, with values between 0 and 1 and the same length bins and time steps as the survey index table.

rec.agerequired

Recruitment age in years.

nagerequired

Number of age classes. The last class holds the fish of its starting age and older.

Mrequired

Natural mortality rate per model time step; see retro_model() for its forms.

sel_L50required

Length at 50 percent survey catchability.

sel_L95required

Length at 95 percent survey catchability, greater than sel_L50.

parametersNULL

Named list of starting values on the optimizer scale.

parameters.LNULL

Named list of lower bounds on the optimizer scale.

parameters.UNULL

Named list of upper bounds on the optimizer scale.

mapNULL

Named list of TMB factor maps, as in run_acl(); NULL uses the default map of the model. The maps of dev_log_R and dev_log_F cover the complete data, and each peel keeps the entries of the time steps it retains. Fixed entries or ties in these two maps work only when the standard deviation and correlations of that process are fixed too; otherwise the fits fail and the call stops with an error.

len_midNULL

Midpoints of the length bins, one per row of the data.

len_borderNULL

Interior boundaries of the length bins, one fewer than the number of bins.

plotFALSE

Logical. TRUE adds the plot to the result. When no finite estimates are available, plot is NULL and a warning is given; fit_diagnostics and errors remain available.

line_sizeNULL

Numeric or NULL. Line width. NULL inherits the global line_size setting (1 under the default style, 1.5 under "classic"). While that setting keeps the value of the style, facets of more than four panels draw thinner lines.

point_sizeNULL

Numeric or NULL. Size of the points. NULL inherits the global point_size setting (default 2.5).

point_shape21

Numeric. Shape of the points that mark the last estimate of each peel. Default 21.

facet_scales"free"

Character. Axis scales of the panels, "fixed", "free", "free_x" or "free_y". Letter case does not matter.

facet_ncolNULL

Integer or NULL. Number of columns of panels. NULL chooses it from the number of panels, for example 5 × 3 for 15 panels and 6 × 4 for 23.

facet_nrowNULL

Integer or NULL. Number of rows of panels.

train_times1

Positive integer. Number of successive optimization passes from each start; it does not add independent starts.

titleNULL

NULL (default) draws the default title, FALSE, NA or "" draws no title, and a character string draws that string; see acl_theme_set() for the default titles and the show_title setting.

xlabNULL

Character or NULL. Label of the x axis. NULL uses the global theme setting.

ylabNULL

Character or NULL. Label of the y axis. NULL uses the global theme setting.

font_familyNULL

Character or NULL. Font family of the text, which must be installed on the computer. NULL uses the global theme setting (default "sans").

title_sizeNULL

Numeric or NULL. Size of the plot title in pt. NULL uses the global theme setting (default 14).

axis_title_sizeNULL

Numeric or NULL. Size of the axis titles in pt. NULL uses the global theme setting (default 12).

axis_text_sizeNULL

Numeric or NULL. Size of the axis tick labels in pt. NULL uses the global theme setting (default 10).

strip_text_sizeNULL

Numeric or NULL. Size of the panel labels in pt. NULL uses the global theme setting (default 10).

legend_text_sizeNULL

Numeric or NULL. Size of the legend text in pt. NULL uses the global theme setting (default 10).

x_breaksNULL

Numeric vector or NULL. Positions of the x-axis breaks. NULL inherits the global x_breaks setting when at least one of its values lies on this axis; otherwise the breaks are chosen automatically.

base_themeNULL

Character or NULL. Name of the base ggplot2 theme, such as "bw", "minimal" or "theme_bw". NULL uses the global theme setting. Letter case does not matter.

title_hjustNULL

Numeric or NULL. Horizontal position of the title, 0 for left, 0.5 for centered and 1 for right. NULL uses the global theme setting.

rho_digits4

Integer. Number of decimals of the Mohn's rho label. Default 4.

rho_position"top_right"

Character. Position of the Mohn's rho label, "top_right" (default), "top_left", "bottom_right" or "bottom_left". Letter case does not matter.

rho_size3.5

Numeric. Text size of the Mohn's rho label. Default 3.5.

ncores1

Integer. Number of socket workers for the full fit and the peels. Default 1. With more than one worker, the full fit and the peels run in one batch, with the same estimates as with one worker. The ncores stored in an input bundle is not used, so give this argument in the call. Each fit runs its nstarts starts one after another.

...…

Other arguments of retro_model(), such as peel_step, nstarts or silent. A model or model_type that names the model of this function is ignored; one that names the other model is an error.

Value

The list that retro_model() returns, with results, last_points, rho_by_peel, rho_text, raw_rho_text, fit_diagnostics, errors, model_type, workers, nstarts, peel_step and, with plot = TRUE, plot; retro_model() describes each element.

Details

retro_acl() calls retro_model() with model_type = "acl". It takes the input bundle of the fitting functions, as in retro_acl(x, nyear = 3), and passes the arguments of retro_model() that are not listed here, such as peel_step, nstarts, silent or F_structure, through .... retro_model() describes how the peels are made, the numerical checks behind Mohn's rho, the records in fit_diagnostics and the restrictions on map.

When the full fit and every peel stop with an error, the call stops with an error that quotes their messages; when at least one fit returns, the result is returned with the failures recorded in fit_diagnostics and errors. rho_text$Rho gives a value only when the full fit and every peel pass the numerical checks.

Examples

Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.

Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
a <- run_acl(x, silent = TRUE)
b <- run_alscl(x, silent = TRUE)
# Use objects defined above
ra <- retro_acl(x, nyear = 3)
ra$fit_diagnostics
ra$rho_text
Example figure
Example figure: plot_retro(retro_acl(x, nyear = 3))

See also

Search documentation