Learn R Programming

SlotLim (version 0.0.2)

slotlim_once: slotlim_once

Description

Run a single SlotLim pass: compute rb, P, TBA, SAM, and catch advice Ay_percent; optionally show a composite plot (P, TBA, SAM, Ay_percent).

Usage

slotlim_once(
  Cy = NULL,
  b_index = NULL,
  method = c("annual", "1over2", "2over3"),
  minLS = NULL,
  maxLS = NULL,
  Lc = NULL,
  growth_model = c("vb", "gompertz", "schnute"),
  Linf = NULL,
  K = NULL,
  l0 = 0,
  tmax = NULL,
  Gom_Linf = NULL,
  Gom_K = NULL,
  Gom_l0 = NULL,
  g1 = NULL,
  g2 = NULL,
  l2 = NULL,
  M = NULL,
  lower = NULL,
  upper = NULL,
  LF = NULL,
  probs = c(0.025, 0.975),
  constraint = 1,
  T1 = NULL,
  T2 = NULL,
  plots = FALSE,
  length_units = NULL
)

Value

A list with Ay, Ay_percent, TBA, SAM, rb, P, and (if plots=TRUE) a composite plot. Also returns the resolved M and the lower/upper bounds actually used; tmax is echoed back.

Arguments

Cy

Numeric. Historical catch.

b_index

Numeric vector of a biomass or abundance index in descending time order (most recent first).

method

Character. Method for calculating rb ("annual", "1over2", or "2over3").

minLS, maxLS, Lc

Numeric. Slot limits and length at first capture.

growth_model

One of "vb", "gompertz", "schnute".

Linf, K, l0

von Bertalanffy (vB) parameters; l0 is the start length (default 0).

tmax

Numeric. Maximum observed age; used for integration bounds and (if M is NULL) to compute default M.

Gom_Linf, Gom_K, Gom_l0

Gompertz parameters; requires 0 < Gom_l0 < Gom_Linf.

g1, g2, l2

Schnute parameters; l2 is length at tmax; requires g1 > 0, l2 > 0, and this parameterization assumes g2 != 0.

M

Numeric or NULL. Natural mortality. If NULL, defaults to \(M = 4.899 \times tmax^{-0.916}\).

lower, upper

Optional values at specified percentiles. If provided, used directly by SAM().

LF

Optional numeric vector of length-frequency data. If lower/upper are NULL and LF is supplied, the function computes percentiles via percentile(LF, probs) and uses them.

probs

Numeric vector of probabilities in \([0,1]\) passed to percentile() when LF is used. Default c(0.025, 0.975).

constraint

Numeric (default 1). Passed to SAM().

T1, T2

Optional numerics passed to catch_advice().

plots

Logical; if TRUE, a \(2 \times 2\) composite plot is printed (if patchwork is available).

length_units

Optional character; x-axis units for the prop_target and SAM plots (e.g., "mm").

Details

Precedence for size inputs: if both lower and upper are provided, they are used. Otherwise, if LF is provided, they are derived via percentile(LF, probs). Else error.

Examples

Run this code
# Minimal, fast example (no plotting), passing lower/upper directly:
slotlim_once(
  Cy = 1000,
  b_index = c(0.5, 0.6, 0.7, 0.6, 0.5), method = "2over3",
  minLS = 120, maxLS = 240, Lc = 80,
  growth_model = "vb", Linf = 405, K = 0.118, l0 = 0,
  tmax = 34,
  lower = 100, upper = 220
)

# \donttest{
# Derive lower/upper from length-frequency percentiles:
set.seed(1)
LF <- rnorm(200, mean = 180, sd = 40)  # toy example LF

# Compute M from tmax:
slotlim_once(
  Cy = 1000,
  b_index = c(0.5, 0.6, 0.7, 0.6, 0.5),
  minLS = 120, maxLS = 240, Lc = 80,
  growth_model = "vb", Linf = 405, K = 0.118, l0 = 0,
  tmax = 34,
  LF = LF, probs = c(0.05, 0.95),
  method = "1over2"  # rb method chosen
)

# Use explicit M (still provide tmax for bounds):
slotlim_once(
  Cy = 1000,
  b_index = c(0.5, 0.6, 0.7, 0.6, 0.5),
  minLS = 120, maxLS = 240, Lc = 80,
  growth_model = "vb", Linf = 405, K = 0.118, l0 = 0,
  tmax = 34,
  M = 0.19,
  LF = LF, probs = c(0.025, 0.975),
  method = "1over2"  # rb method chosen
)

# Plotting example (needs ggplot2 and patchwork):
slotlim_once(
  Cy = 1000,
  b_index = c(0.5, 0.6, 0.7, 0.6, 0.5),
  minLS = 120, maxLS = 240, Lc = 80,
  growth_model = "vb", Linf = 405, K = 0.118, l0 = 0,
  tmax = 34,
  LF = LF, probs = c(0.025, 0.975),
  method = "1over2",  # rb method chosen
  plots = TRUE, length_units = "mm"
)
# }

Run the code above in your browser using DataLab