Skip to contents

Refit models after peeling terminal years. Hindcasts additionally forecast held-out observations, conditional on observed removals by default.

Usage

fit_retro(
  fit,
  ...,
  folds = 2,
  start_from_fit = FALSE,
  hindcast = FALSE,
  proj_settings = NULL,
  grad_tol = NULL,
  progress = TRUE,
  globals = NULL
)

fit_hindcast(
  fit,
  ...,
  folds = 2,
  start_from_fit = FALSE,
  hindcast = TRUE,
  proj_settings = list(n_proj = 1, n_mean = 1, catch = "observed"),
  grad_tol = NULL,
  progress = TRUE,
  globals = NULL
)

# S3 method for class 'tam_retro'
print(x, ...)

Arguments

fit, ...

One or more tam_fit objects. Name additional models for distinct labels. All other controls must be named.

folds

Number of peels, leaving at least two historical years per fit.

start_from_fit

Use each supplied fit to initialize its peels?

hindcast

Project peeled fits? Defaults to FALSE for fit_retro() and TRUE for fit_hindcast().

proj_settings

Hindcast settings: n_proj (default 1), n_mean (default 1), and either catch = "observed" (default) or one non-negative F_mult. Partial lists inherit these defaults; supplying F_mult clears catch. Numeric catch targets and control vectors are not accepted in hindcasts. Forecasts are shortened to available validation years. Ordinary retrospectives reject projection settings. NULL uses hindcast defaults when hindcast = TRUE. Ordinary model projections retain scalar/vector numeric catch and F controls; see prepare_tam().

grad_tol

Numerical check tolerance; defaults to each fit's stored value.

progress

Show progress using progressr?

globals

Global names passed to furrr workers. Configure your own future plan.

x

A tam_retro object.

Value

A tam_retro list with fits nested by model and terminal year; stacked pop and obs_pred with model, fold and horizon (zero historically); mohns_rho; detailed scores; matched forecast_pairs; fold_diagnostics; and resolved projection_controls. Failed references make rho unavailable. When there are eligible forecasts from delta or Tweedie models, also returns occurrence_scores, occurrence_comparable and forecast_pairs$occurrence with the individual cases. All-failed runs still return diagnostics.

Details

Only observed years determine folds. Historical references have no forecasts. Each fold fits catch numbers at age and survey indices in its training years. Forecast biology uses training years and n_mean.

Forecast assumptions. The hindcast default catch = "observed" conditions each forecast on total catch biomass in the held-out year. tinyAM calculates it from complete catch numbers at age and catch weights across all fleets, using stock weights if catch weights are absent. Forecast stock and catch weights are averaged separately by type and fleet using training years only. The forecast scales the terminal fishing mortality pattern to meet the biomass target. Agreement with the imposed catch biomass does not measure forecast skill. Missing catch or weight coverage fails that fold. An alternative is proj_settings = list(F_mult = 1), retaining the F-at-age estimated at each fold's terminal year. Any scalar multiplier applies to that terminal profile at every available horizon, rather than compounding annually. Controls therefore follow each fold's shifting calendar window. Use F_mult if catch counts were supplied only for a pooled plus group and separate weights for its constituent ages are retained. The pooled counts alone cannot recover observed catch biomass for those ages.

Printed summary. One row per model shows Mohn's rho for SSB, recruitment and average F, relative to the unpeeled reference fit. Hindcasts also show log_RMSE (pooled survey-age log prediction errors), MASE (persistence-relative absolute log error, averaged across ages within survey, surveys within horizon, then horizons), and n (survey observation-forecast pairs used for log-RMSE). scored_folds counts folds with eligible survey predictions; failed_folds counts failed numerical/projection attempts, including a failed reference. The unpeeled reference does not contribute forecast scores. A failed reference makes rho unavailable; missing forecast pairs or persistence baselines make the corresponding scores unavailable. Catch-composition and detailed survey, age and horizon scores remain in scores. Unequal validation coverage is flagged and no automatic ranking is produced.

Survey log-RMSE pools observation errors. MASE compares absolute log errors with persistence on identical cases; see compute_hindcast_mase(). Overall MASE averages ages within survey, surveys within horizon, then horizons. Delta, Tweedie, Gamma and generalized gamma models use their positive conditional medians for both log scores. Age-summed log scores are available for lognormal surveys with complete, consistent age coverage.

Quotas can constrain catch biomass, while the ages caught depend on cohort abundance and fishing selectivity. Composition scores assess how well projected cohorts and the assumed fishing pattern reproduce the age mix. The scores compare proportions derived from observed and predicted catch numbers at age within each fleet. Both the observed and predicted catch must cover all modeled ages and have a positive total. The scores retain zeros at individual ages and also assess mean age, using the lower bound for the plus group. Overlapping forecasts are distinct origin/horizon cases from the same data history.

For delta and Tweedie models, occurrence_scores reports the mean squared error of predicted zero probabilities (Brier score), with numbers of scored observations and zeros. This score includes observed zeros and positives at eligible ages. It excludes missing and known structural-zero rows. Survey and catch scores are separate. Catch occurrence predictions with catch = "observed" are conditional on the observed total removal.

Compare equivalent observations and age definitions. No ranking is produced. For a cross-family comparison, use the matched survey-age cases in forecast_pairs$index. Age-summed scores may be unavailable for some models. Missing baselines or zero persistence error make MASE unavailable. Failed numerical fits remain in fits, but not in stacked results or scores. Supplied fits and fitted objectives are unchanged.

Parallel execution

Set the execution plan before calling either function, for example future::plan(future::multisession, workers = 4). Without a parallel plan, folds run sequentially. Neither function changes your plan or worker count. Use future::plan(future::sequential) afterwards to shut down the workers.

Examples

if (FALSE) { # \dontrun{
future::plan(future::multisession, workers = 4)
retro <- fit_retro(fit, alternative = other_fit, folds = 5)
hind <- fit_hindcast(fit, folds = 10,
  proj_settings = list(n_proj = 3, n_mean = 3, catch = "observed"))
print(hind)
hind$scores
vis_tam(hind)
vis_tam(retro, model = names(retro$fits)[1])
future::plan(future::sequential)
} # }