Skip to contents

Add the optional tam_data class to a list of tinyAM input tables. Printing shows a compact preview of each table; table values and types are unchanged. Plain lists can also be passed directly to prepare_tam() and fit_tam().

Usage

as_tam_data(data)

# S3 method for class 'tam_data'
print(x, n = 5, ...)

Arguments

data

A named list of input data.frames; see check_tam_data().

x

A tam_data object.

n

Number of first and last rows to show per table (default five).

...

Arguments passed to table printing.

Value

The same list with class tam_data added.

The print method returns x invisibly.

Details

The required tables are catch, index, weight and maturity. For a catch-only model, keep index as a zero-row table with its required columns. Catchability and survey observation-SD settings then contribute no parameters. Model identification still depends on the remaining assumptions. An optional pop_covariates table supplies columns used by N and M formulas, including recruitment covariates and supplied M assumptions. It has one row per input year and age, with year and age keys and no required obs column. Values may be missing where a formula does not use them. Recruitment covariates are read at the youngest modeled age.

Population formulas use these columns and intrinsic year and age, never search other tables. Process-SD designs must remain constant across years and within shared M age blocks. For a model plus group, the supplied row at its terminal age is used; covariates are not averaged or summed. Projections carry terminal covariates forward by age. Modeled SSB is calculated internally.

Catch/index observation-SD covariates and survey catchability covariates stay in their respective observation tables. Weight, maturity and spawning timing stay in the biological tables. Validation does not add the class, and inputs are checked again during preparation after any edits. F mean, process-SD and correlation-group covariates belong in catch, including rows with missing catch. The response obs cannot predict F. Optional catch$fleet identifies separate fisheries on a shared population; each fleet requires a complete year-age grid, using NA for missing catches.

The optional weight$type key distinguishes "stock" and "catch" average individual weights. Stock weights are required and determine biomass and SSB. Catch weights determine yield and catch targets; if absent, stock weights serve both purposes. Each supplied type needs the complete same year-age grid, including retained biological ages beyond a modeled plus age. Missing catch-weight cells never fall back individually to stock weights. Optional weight$fleet applies only to catch weights: stock rows use NA. Supply either shared catch weights (no fleet labels), or complete catch-weight grids for every declared catch fleet. Shared and fleet-specific rows cannot mix. For a prepared wide table with stock and catch columns, the tidy form is:

tidyr::pivot_longer(wide, c(stock, catch),
  names_to = "type", values_to = "obs")

Optional unit columns label catch numbers, average individual weight and each survey index. Use one unit throughout catch and weight, and one per survey. Values are never converted during fitting. For example, "thousand fish" catch and "kg" weight give abundance in thousands and biomass/SSB in tonnes. Unknown units are left unlabeled; descriptive index units such as "fish per tow" are retained. Reported tables and default plot labels carry these units. Explicit plot labels take precedence. Matrix views convert recognized abundance/mass units to fish/kg for comparisons, independently of aggregate comparison scales; missing reference units remain unavailable.

Examples

data <- as_tam_data(cod_obs)
data
#> 
#> ── tinyAM data ─────────────────────────────────────────────────────────────────
#> 
#> ── catch: 1512 rows, 6 columns ──
#> 
#> Years 1954–2025; ages 0–20
#>      year age obs          unit F_y_block F_a_block
#> 1    1954   0  NA thousand fish 1954-1991       0-1
#> 2    1955   0  NA thousand fish 1954-1991       0-1
#> 3    1956   0  NA thousand fish 1954-1991       0-1
#> 4    1957   0  NA thousand fish 1954-1991       0-1
#> 5    1958   0  NA thousand fish 1954-1991       0-1
#> ⋮       ⋮   ⋮   ⋮             ⋮         ⋮         ⋮
#> 1508 2021  20   0 thousand fish 2006-2022     18-20
#> 1509 2022  20   0 thousand fish 2006-2022     18-20
#> 1510 2023  20   0 thousand fish 2023-2025     18-20
#> 1511 2024  20   0 thousand fish 2023-2025     18-20
#> 1512 2025  20   0 thousand fish 2023-2025     18-20
#> 
#> ── index: 1512 rows, 7 columns ──
#> 
#> Years 1954–2025; ages 0–20
#>      year age       obs     survey samp_time q_block          unit
#> 1    1954   0        NA Fall 2J3KL       0.8       0 thousand fish
#> 2    1954   1        NA Fall 2J3KL       0.8       1 thousand fish
#> 3    1954   2        NA Fall 2J3KL       0.8       2 thousand fish
#> 4    1954   3        NA Fall 2J3KL       0.8       3 thousand fish
#> 5    1954   4        NA Fall 2J3KL       0.8       4 thousand fish
#> ⋮       ⋮   ⋮         ⋮          ⋮         ⋮       ⋮             ⋮
#> 1508 2025  16  74.00868 Fall 2J3KL       0.8    6-20 thousand fish
#> 1509 2025  17 120.43751 Fall 2J3KL       0.8    6-20 thousand fish
#> 1510 2025  18   0.00000 Fall 2J3KL       0.8    6-20 thousand fish
#> 1511 2025  19   0.00000 Fall 2J3KL       0.8    6-20 thousand fish
#> 1512 2025  20   0.00000 Fall 2J3KL       0.8    6-20 thousand fish
#> 
#> ── weight: 1512 rows, 4 columns ──
#> 
#> Years 1954–2025; ages 0–20
#>      year age          obs unit
#> 1    1954   0 2.965967e-04   kg
#> 24   1955   0 2.965967e-04   kg
#> 47   1956   0 2.965967e-04   kg
#> 70   1957   0 2.965967e-04   kg
#> 93   1958   0 2.965967e-04   kg
#> ⋮       ⋮   ⋮            ⋮    ⋮
#> 1562 2021  20 1.406005e+01   kg
#> 1585 2022  20 1.453274e+01   kg
#> 1608 2023  20 1.426399e+01   kg
#> 1631 2024  20 1.409146e+01   kg
#> 1654 2025  20 1.369174e+01   kg
#> 
#> ── maturity: 1512 rows, 3 columns ──
#> 
#> Years 1954–2025; ages 0–20
#>      year age obs
#> 1    1954   0   0
#> 2    1955   0   0
#> 3    1956   0   0
#> 4    1957   0   0
#> 5    1958   0   0
#> ⋮       ⋮   ⋮   ⋮
#> 1708 2021  20   1
#> 1709 2022  20   1
#> 1710 2023  20   1
#> 1711 2024  20   1
#> 1712 2025  20   1
#> 
#> ── pop_covariates: 1512 rows, 4 columns ──
#> 
#> Years 1954–2025; ages 0–20
#>      year age allometric_M_assumption M_a_block
#> 1    1954   0               4.9990199       0-1
#> 2    1955   0               4.9990199       0-1
#> 3    1956   0               4.9990199       0-1
#> 4    1957   0               4.9990199       0-1
#> 5    1958   0               4.9990199       0-1
#> ⋮       ⋮   ⋮                       ⋮         ⋮
#> 1508 2021  20               0.1873957      8-20
#> 1509 2022  20               0.1855152      8-20
#> 1510 2023  20               0.1865744      8-20
#> 1511 2024  20               0.1872682      8-20
#> 1512 2025  20               0.1889190      8-20
data$pop_covariates$age_group <- factor(data$pop_covariates$age)
check_tam_data(data)
#> ✔ Input data passed validation.
#> ℹ Years 1954-2025; ages 0-20; fleets: 1; surveys: 1.