plot_compare_selectivity()
View source ↗On this page
Compare the fixed survey catchability at length that two fits were given, connecting the supplied values without smoothing.
Usage
plot_compare_selectivity(
model1,
model2,
model1_name = NULL,
model2_name = NULL,
colors = NULL,
linetypes = NULL,
line_size = NULL,
...,
point_size = NULL,
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. |
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. |
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
The curves are the survey catchability at length that each fit was given as a fixed input; the word selectivity in the function name does not mean an estimated fishery selectivity.
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. A visual comparison does not show that the likelihoods or the biological assumptions of the two fits are comparable.
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.
A saved fit read with read_assessment() can be plotted without refitting. The survey catchability is calculated again from the stored sel_L50 and sel_L95 at the fitted length-bin midpoints, or taken from survey_q when the fit was given survey catchability at length directly. When survey_q was given by length and time step, one line is drawn for each distinct curve and a caption says so. The survey catchability multiplier by age (survey_q_age) is not shown. A fit without its stored inputs and settings uses log_q of its live TMB object; a saved fit without them must first be saved again with its original input bundle x.
plot_survey_catchability() draws the catchability of one fit, names the time steps of each curve when catchability changes over time, and shows the catchability multiplier by age.
Additional details from R help
A saved fit is drawn without refitting. Survey catchability is computed from sel_L50 and sel_L95 of its recipe at the fitted length midpoints, or taken from its survey_q when the fit used survey catchability at length supplied directly. A fit without a recipe uses log_q from its live TMB object. When survey_q was supplied by length and time step, one line is drawn for each distinct curve and a caption says so. A survey catchability multiplier by age (survey_q_age) is not shown.
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_selectivity(a, b)

plot_compare_selectivity(a, b)