prepare_alscl_data()
View source ↗On this page
Collect the three tables and the fitting settings in one input bundle that check_alscl_data(), inspect_parameters(), run_acl() and run_alscl() accept.
Usage
prepare_alscl_data(
data.CatL = NULL,
data.wgt = NULL,
data.mat = NULL,
file = NULL,
format = c("tables", "csv", "excel"),
fit_args = list(),
fit_config = NULL
)
Arguments
| Argument | Default | Description |
|---|---|---|
data.CatL | NULL | Survey index table, or a named list containing all three tables. |
data.wgt | NULL | Weight table (mean weight by length bin) aligned with the survey index table. |
data.mat | NULL | Maturity table (proportion mature by length bin) aligned with the survey index table. |
file | NULL | Directory for CSV input or workbook path for Excel input. |
format | c("tables", "csv", "excel") | Input format, "tables", "csv" or "excel". Letter case does not matter. |
fit_args | list() | Named list of shared biological and fitting settings, such as rec.age, nage, M, and either sel_L50 and sel_L95 or survey_q. M can be a single number, a matrix by age and time step or, for ALSCL, a vector by length; survey_q can be a vector by length or a matrix by length and time step; survey_q_age is an optional survey catchability multiplier by age. See |
fit_config | NULL | Optional list with an element acl, alscl or both, each holding the settings of that model only. |
Value
An input bundle, a list with data.CatL, data.wgt, data.mat, fit_args and, when given, fit_config.
Details
The function converts numeric text safely and checks the values and alignment of the three tables. It never fills or reorders missing time steps and does not infer biological parameters. Supply rec.age, nage, M, and either sel_L50 and sel_L95 or survey_q in fit_args, then run check_alscl_data(x, model). An argument given in the fitting call takes precedence over the entry of that model in fit_config, which takes precedence over the shared fit_args; a list-valued setting replaces the whole list. A named NULL entry of a map, which releases that parameter, is kept. Zeros stay zeros until the zero_action of the fit treats them as missing or rejects them. A model without an entry in fit_config uses the shared fit_args only, so a bundle whose fit_config has an entry for one model can be fitted with the other. A setting in fit_args that only one model takes (bounds for ACL, t0_lower for ALSCL) is left out, with a message, when the other model is checked or fitted. Only the three tables, fit_args and fit_config are fitting settings. A fitting argument stored at the top level of the returned list, for example x$M <- 0.3 or x$map <- ..., is not used, and fitting warns about it; store such a setting in x$fit_args, x$fit_config$acl or x$fit_config$alscl. The ALSCL arguments len_lower and len_upper are deprecated and cannot change a fit, so leave them out.
Additional details from R help
Settings are taken in this order, each replacing the one before: the shared fit_args, the fit_config of the model, then the arguments of the call to run_acl() or run_alscl(). A list given in the call replaces the whole stored list, and named NULL releases in a map are kept. Zeros stay zeros; the zero_action of the fit decides whether they are left out or rejected. Time steps without survey data must be columns of their own, with complete weights and maturity. The function never fills in or reorders time steps.
Only the three tables, fit_args and fit_config are fitting settings. A
fitting argument stored at the top level of the returned list, for example
x$M <- 0.3 or x$map <- ..., is not used, and fitting warns about it.
Store such a setting in x$fit_args or x$fit_config$acl or
x$fit_config$alscl. A top-level parameters entry is not reported:
example bundles such as YTF_example keep their simulation settings there.
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
tables <- YTF_example[c("data.CatL", "data.wgt", "data.mat")]
x <- prepare_alscl_data(tables, fit_args = YTF_example$fit_args,
fit_config = YTF_example$fit_config)
check_alscl_data(x, "acl")$valid
inspect_parameters(x, "alscl")