plot_compare_F_ts()
View source ↗On this page
Compare the fishing mortality of two fits summarized over groups in each time step, as the maximum (apical) or the mean.
Usage
plot_compare_F_ts(
model1,
model2,
model1_name = NULL,
model2_name = NULL,
method = c("apical", "mean"),
colors = NULL,
linetypes = NULL,
line_size = NULL,
...,
point_size = NULL,
basis = c("native", "age"),
title = NULL
)
Arguments
| Argument | Default | Description |
|---|---|---|
model1 | required | The first fit. |
model2 | required | The second fit. |
model1_name | NULL | Character or NULL. Name of the first fit in the plot and in the default title. NULL takes the model type ("ACL" or "ALSCL"); when both fits have the same type, the F structure, or 1 and 2, is added in parentheses. |
model2_name | NULL | Character or NULL. Name of the second fit in the plot and in the default title. NULL takes the model type ("ACL" or "ALSCL"); when both fits have the same type, the F structure, or 1 and 2, is added in parentheses. |
method | c("apical", "mean") | Character. Summary over groups within each time step, "apical" for the maximum F and "mean" for the unweighted arithmetic mean. Rates are not annualized. ACL uses age classes and ALSCL length bins, and both summaries depend on that grouping. Letter case does not matter. |
colors | NULL | Character vector of two colors, named by model or in model order. NULL uses the global compare_colors setting; fewer than two colors give a warning, and the global setting is used. |
linetypes | NULL | Character vector of two line types, with the same rules as |
line_size | NULL | Numeric or NULL. Line width. NULL uses the global compare_line_size setting. |
... | … | The former argument name linewidth (for line_size), accepted with a warning. |
point_size | NULL | Numeric or NULL. Point size. NULL uses the global compare_point_size setting, or point_size (default 2.5) when that is NULL. |
basis | c("native", "age") | Character. The groups over which F is summarized. "native" (default) uses the F matrix that each model estimates, F at age for ACL and F at length for ALSCL. "age" uses F at age for both fits ( |
title | NULL | NULL (default) draws the default title, FALSE, NA or "" draws no title, and a character string draws that string; see |
Value
A ggplot object, which can be styled further or saved with acl_save_plot().
Details
apical is the maximum and mean the unweighted arithmetic mean across groups in each model time step. By default (basis = "native") ACL uses age groups and ALSCL length bins, so both summaries depend on the grouping; read the time pattern of such a pair, not the difference in level. basis = "age" uses F at age for both fits and summarizes only the fitted ages and time steps present in both. ALSCL F at age covers every age, including the plus group, and every time step. The values for the plus group and the last time step are not in the fitted report; the function computes them from the reported numbers at length and age (report$NLA) and total mortality at length (report$ZL) with the same formula. A result without numbers at length and age, for example a hand-made list, has no plus-group row and no value for the last time step, and the comparison then leaves out the ACL plus group and the last time step. The two fits must have the same time step, because F is a rate per time step, and the function stops when the steps differ. An age-group maximum need not equal a length-bin maximum, because age-specific F combines survival across lengths. Quarterly rates are not annualized. The y-axis label gives the time basis of the rate and the caption states the groups that each summary covers.
Two fits of the same model get distinct default names, such as ACL (group_year) and ACL (year); model1_name and model2_name set other names, which must differ. Each fit keeps its own time steps, so the two fits can cover different years. A visual comparison does not show that the likelihoods or the biological assumptions of the two fits are comparable.
plot_compare_annual_F() is the former name of this function; it still works and warns once per session.
Points take the global point_size setting (default 2.5) unless the global compare_point_size setting is given; a point_size in the call takes priority. acl_theme_set(compare_point_size = NULL) returns to the global point_size.
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
plot_compare_F_ts(a, b, method = "apical",
title = "Apical fishing mortality rate by time step")

plot_compare_F_ts(a, b, method = "apical", title = "Apical fishing mortality rate by time step")