retro_acl()
View source ↗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
| Argument | Default | Description |
|---|---|---|
nyear | 5 | Integer. Number of retrospective peels. Default 5. The number of time steps that each peel removes follows the peel_step argument of |
data.CatL | required | Survey index table (length labels followed by one column per time step), or the input bundle used by |
data.wgt | required | Weight table, with the same length bins and time steps as the survey index table. |
data.mat | required | Maturity table, with values between 0 and 1 and the same length bins and time steps as the survey index table. |
rec.age | required | Recruitment age in years. |
nage | required | Number of age classes. The last class holds the fish of its starting age and older. |
M | required | Natural mortality rate per model time step; see |
sel_L50 | required | Length at 50 percent survey catchability. |
sel_L95 | required | Length at 95 percent survey catchability, greater than sel_L50. |
parameters | NULL | Named list of starting values on the optimizer scale. |
parameters.L | NULL | Named list of lower bounds on the optimizer scale. |
parameters.U | NULL | Named list of upper bounds on the optimizer scale. |
map | NULL | Named list of TMB factor maps, as in |
len_mid | NULL | Midpoints of the length bins, one per row of the data. |
len_border | NULL | Interior boundaries of the length bins, one fewer than the number of bins. |
plot | FALSE | 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_size | NULL | 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_size | NULL | Numeric or NULL. Size of the points. NULL inherits the global point_size setting (default 2.5). |
point_shape | 21 | 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_ncol | NULL | 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_nrow | NULL | Integer or NULL. Number of rows of panels. |
train_times | 1 | Positive integer. Number of successive optimization passes from each start; it does not add independent starts. |
title | NULL | NULL (default) draws the default title, FALSE, NA or "" draws no title, and a character string draws that string; see |
xlab | NULL | Character or NULL. Label of the x axis. NULL uses the global theme setting. |
ylab | NULL | Character or NULL. Label of the y axis. NULL uses the global theme setting. |
font_family | NULL | Character or NULL. Font family of the text, which must be installed on the computer. NULL uses the global theme setting (default "sans"). |
title_size | NULL | Numeric or NULL. Size of the plot title in pt. NULL uses the global theme setting (default 14). |
axis_title_size | NULL | Numeric or NULL. Size of the axis titles in pt. NULL uses the global theme setting (default 12). |
axis_text_size | NULL | Numeric or NULL. Size of the axis tick labels in pt. NULL uses the global theme setting (default 10). |
strip_text_size | NULL | Numeric or NULL. Size of the panel labels in pt. NULL uses the global theme setting (default 10). |
legend_text_size | NULL | Numeric or NULL. Size of the legend text in pt. NULL uses the global theme setting (default 10). |
x_breaks | NULL | 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_theme | NULL | 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_hjust | NULL | 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_digits | 4 | 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_size | 3.5 | Numeric. Text size of the Mohn's rho label. Default 3.5. |
ncores | 1 | 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 |
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

plot_retro(retro_acl(x, nyear = 3))