Skip to contents

Fits an ARIMA model separately to each supplied reconstruction draw and simulates future recruitment deviations.

Usage

project_rec_devs(
  data,
  obj,
  mcmc = NULL,
  first_yr = 2021L,
  last_yr = 2035L,
  samp_years = 1931L:2022L,
  iters = NULL,
  max.p = 3L,
  max.d = 3L,
  max.q = 3L,
  option = "auto",
  bootstrap = TRUE,
  pin_year = first_yr - 1L
)

Arguments

data

A list containing model data including dimensions and years.

obj

A TMB model object returned from MakeADFun.

mcmc

Optional MCMC fit object from SparseNUTS. If NULL, uses MLE parameters.

first_yr

An integer specifying the first projection year (default: 2021).

last_yr

An integer specifying the last projection year (default: 2035).

samp_years

An integer vector of historical years to sample recruitment deviates from (default: 1931:2022).

iters

An integer vector specifying which MCMC iterations to use. If NULL, uses all iterations.

max.p

An integer specifying the maximum AR order to consider in ARIMA model selection (default: 3).

max.d

An integer specifying the maximum degree of differencing for stationarity (default: 3).

max.q

An integer specifying the maximum MA order to consider in ARIMA model selection (default: 3).

option

A character string specifying the ARIMA fitting method: "auto" for automatic selection or "AR1" for AR(1) model (default: "auto").

bootstrap

A logical indicating whether to bootstrap residuals (TRUE) or use normal random errors (FALSE) (default: TRUE).

pin_year

Optional integer historical year used to pin the first projected recruitment deviate. The first simulated projection deviate is forced to equal the posterior recruitment deviate in this year. If NULL, the first projected deviate is not pinned. The default is first_yr - 1, matching the previous projection setup.

Value

A list containing:

rdev_y

A matrix of historical recruitment deviates with dimensions \[n_iter, n_years\].

proj_rdev_y

A matrix of projected recruitment deviates with dimensions \[n_iter, n_proj\].

arima_pars

A matrix of ARIMA(p,d,q) specifications with dimensions \[n_iter, 3\].

ar_pars

A matrix of AR coefficients with dimensions \[n_iter, max.p\].

ma_pars

A matrix of MA coefficients with dimensions \[n_iter, max.q\].

pin_year

The historical year used to pin the first projected recruitment deviate, or NULL.

pin_rdev

The posterior recruitment deviate values used for pinning, or NULL.

Details

The output row order follows iters. Simulation and optional residual bootstrapping consume the caller's random-number state. The function does not set or restore a seed.