Skip to contents

Validates the minimal structure required by prepare_tam() and fit_tam(). data 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. Supply catch numbers at age in catch$obs and survey indices at age in index$obs. Total catch, total survey indices, and age or length compositions are unsupported fitting inputs, separately or jointly. See as_tam_data() for input preparation.

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 and index values are allowed. The default lognormal likelihood excludes zeros. Delta and Tweedie families can fit sampled zeros. See observation_families.

  • 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.

Explicit age-composition unit labels such as "proportion_at_age" in catch or index data produce an error. For a fleet or survey without a recognizable count or count-rate unit, the check warns if observations across ages sum to within 0.005 of one in every comparable year. This requires at least three years with all ages in the series observed and at least two positive ages in each of those years. The warning asks you to verify the scale.

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 summary and the advisory composition warning. 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 and advisory composition warning? 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)