simulate_example_data()
View source ↗On this page
Generate small annual teaching datasets in the three-table input format.
Usage
simulate_example_data(
years = 2000:2025,
bin_breaks = c(0, 20, 25, 30, 35, 40, 45, 50, 55, 60),
Linf = 55,
vbk = 0.45,
t0 = -0.1,
M = 0.8,
nage = 7,
L50_sel = 28,
L95_sel = 36,
L50_mat = 33,
L95_mat = 40,
wgt_a = 2.2e-06,
wgt_b = 3.2,
mean_F = 0.3,
cv_catch = 0.3,
rec_sigma = 0.5,
seed = NULL,
save_csv = FALSE,
output_dir = "."
)
Arguments
| Argument | Default | Description |
|---|---|---|
years | 2000:2025 | Numeric vector of consecutive annual observation years, at least two. Use |
bin_breaks | c(0, 20, 25, 30, 35, 40, 45, 50, 55, 60) | Numeric vector of bin borders; n+1 borders define n length bins, which may have unequal widths. The default gives 9 bins, 0-20, 20-25, ..., 55-60. The outer borders set only the midpoints and labels of the first and last bins; in the probabilities these bins take the tails of the distribution. |
Linf | 55 | Numeric. VB asymptotic length, in the unit of the length bins. Default 55. |
vbk | 0.45 | Numeric. VB growth coefficient per year. Default 0.45. |
t0 | -0.1 | Numeric. VB theoretical age at length 0, in years; must be below the recruitment age of 1. Default -0.1. |
M | 0.8 | Numeric. Nonnegative natural mortality rate per year. Default 0.8. |
nage | 7 | Integer. Number of age classes (ages 1 to nage), the last being the plus group. Default 7. |
L50_sel | 28 | Numeric. Length at survey catchability 0.5. Default 28. |
L95_sel | 36 | Numeric. Length at survey catchability 0.95, greater than L50_sel. Default 36. |
L50_mat | 33 | Numeric. Length at 50 percent maturity. Default 33. |
L95_mat | 40 | Numeric. Length at 95 percent maturity, greater than L50_mat. Default 40. |
wgt_a | 2.2e-06 | Numeric. Coefficient a of the length-weight relationship W = a * L^b. Default 2.2 × 10⁻⁶. |
wgt_b | 3.2 | Numeric. Exponent b of the length-weight relationship W = a * L^b. Default 3.2. |
mean_F | 0.3 | Nonnegative arithmetic mean of the generated F trajectory over the returned years; zero gives zero fishing mortality. |
cv_catch | 0.3 | Numeric. Coefficient of variation (CV) of the multiplicative lognormal noise of the survey index, not its log-scale SD. Default 0.3. |
rec_sigma | 0.5 | Numeric. SD of log recruitment, independent between years. Default 0.5. |
seed | NULL | Integer or NULL. Random seed; NULL (default) gives a different result in each run. A supplied seed gives the same data in any session and does not change the caller's random-number stream. |
save_csv | FALSE | Logical. Save the three tables as the CSV files data.CatL.csv, data.wgt.csv and data.mat.csv in output_dir, the names that |
output_dir | "." | Character. Directory of the CSV files, created when it does not exist. Default ".", the working directory. |
Value
A list with the three aligned tables, the survey index table data.CatL, the weight table data.wgt and the maturity table data.mat, and true_params, the parameters and true values used to simulate.
Details
Set a seed for reproducible examples. save_csv = TRUE writes the three tables. For the full age- or length-based operating model and for quarterly scenarios, use initialize_params(), sim_cal() and sim_data() in that order.
In the quick annual simulator, mean_F is the arithmetic mean of the generated F trajectory; mean_F = 0 generates zero F.
The quick simulator integrates the first and last length bins to negative and positive infinity, as the fitted models do; finite bin_breaks set the labels and midpoints and do not truncate the probabilities. M, F and the noise scales must be nonnegative, the growth parameters positive and the weight coefficient nonnegative, and the 95 percent lengths of the selectivity and maturity curves must exceed the 50 percent lengths. Invalid parameters or nonfinite simulated values stop the function before any CSV file is written.
Additional details from R help
Biological inputs must be finite scalars, Linf and vbk must be
positive, t0 must be below recruitment age 1, and variation parameters and
the weight coefficient must be nonnegative. Invalid inputs and nonfinite
simulated values are rejected before any CSV files are created or replaced.
The age-length key uses the same open-tail probabilities as ACL, but the
recruitment process differs from that of the fitted models.
The simulated population differs from the default fitting assumptions in
three ways: t0 is -0.1 (the ACL default map fixes t0 at 1/60), the initial
numbers at age have no deviations, and fishing mortality follows a smooth
deterministic curve without process error. Recruitment is independent
between years. A fit with all defaults therefore estimates a biased vbk
and usually fails the numerical checks, because the standard deviation of
the initial deviations or the recruitment correlation goes to zero; see
the example for settings that match the data. Progress is reported with
message().
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)
# Use objects defined above
simulate_example_data(years = 2000:2019, seed = 42,
save_csv = TRUE, output_dir = "quick_simulation")