Skip to contents

Validates the minimal structure required by prepare_tam() and fit_tam(). The obs object must be a list containing data.frames catch, index, weight, and maturity. Each table must include columns year, age, and obs. Types must be numeric (integerish allowed) for year and age, and numeric for obs.

Additional requirements:

  • index$samp_time is required, numeric in [0, 1], and no NA.

  • weight$obs and maturity$obs must not contain NA.

  • Optional maturity$spawn_time must contain finite numeric fractions in [0, 1] for every year and age. Absence means zero; see prepare_tam().

  • Non-missing observations must be finite and non-negative; maturity must be a proportion in [0, 1]. Zero catch/index values are accepted here but treated as missing by prepare_tam(), because the observation model is on logs.

  • catch and maturity must contain exactly one row for every (year, age) combination over the global modeled range (from min to max year and age across all tables). Weight requires the same grid within each supplied type.

  • Survey tables may omit year-age combinations.

  • Optional weight$type contains "stock" or "catch". Stock weights are required. With types, the unique key is (year, age, type) and every supplied type must cover the complete same grid. Without types, or with stock alone, stock weights also supply yield and catch targets.

  • Optional catch$fleet adds fleet to its unique key and requires a complete year-age grid within every fleet. weight$fleet can identify complete fleet-specific catch weights; stock weights remain unlabelled (NA).

  • Optional character unit columns must be consistent throughout catch and weight, and within each survey. Missing columns are valid; a supplied column requires nonempty labels on every row. Units never change input values. See as_tam_data() for units of derived quantities.

On failure the function aborts with a cli error. On success, it prints a concise summary and returns TRUE invisibly. Use quiet = TRUE to suppress the success summary; validation errors are always reported.

Usage

check_tam_data(data, quiet = FALSE)

Arguments

data

A named list expected to contain data.frames catch, index, weight, and maturity with the columns described above.

quiet

Logical. Suppress the success summary? Defaults to FALSE.

Value

TRUE (invisibly) if validation passes; otherwise aborts.

Examples

data(cod_obs)
check_tam_data(cod_obs)
#> ✔ Input data passed validation.
#> ℹ Years 1954-2025; ages 0-20; fleets: 1; surveys: 1.
check_tam_data(cod_obs, quiet = TRUE)