Package 'JARA2'

Title: State-Space Population Trend Analysis for Red List Assessments in 'RTMB'
Description: The next generation of 'JARA' (Just Another Red-list Assessment). Fits the 'JARA' state-space models (a random walk with drift on log abundance, observed through relative abundance indices or census counts) in 'RTMB', in about a second per fit, with full posteriors through 'tmbstan' (NUTS) as an option. Estimates the change in abundance over three generation lengths and the probabilities of the IUCN Red List categories under criteria A1 and A2, with uncertainty in the generation length carried through. Includes projections, one-step-ahead residuals, retrospective analysis and hindcast cross-validation, graphics shared with 'JABBA3', inputs as data frames, 'FLIndices' or 'JABBA' objects, and a converter for 'JARA' inputs, so existing scripts continue to run.
Authors: Henning Winker [aut, cre], Richard Sherley [aut], Nathan Pacoureau [aut]
Maintainer: Henning Winker <[email protected]>
License: EUPL (>= 1.2)
Version: 2.0.0.9000
Built: 2026-12-03 09:12:58 UTC
Source: https://github.com/Henning-Winker/JARA2

Help Index


Assign IUCN categories from a change in abundance

Description

As in JARA: CR if the change (%) is at or below the CR threshold, and so on.

Usage

assign_iucn(change, criteria = "A2", NT = FALSE)

Arguments

change

change in abundance over the assessment window (%)

criteria

"A1", "A2", "A3" or "A4"

NT

add the Near Threatened band

Value

character vector of categories

Examples

assign_iucn(c(-85, -60, -35, -10))

Stock status of 73 ICES stocks, 1970-2020

Description

Fishing mortality and spawning biomass relative to reference points from the 73 quantitative ICES stock assessments analysed by Winker et al. (2026), used there for JARA's mixed-trend analysis of the joint trajectories of F/FMSY and B/BMSY in the Northeast Atlantic. A long table with one row per stock and year.

Format

data.frame with columns stock (ICES stock code), common.name, species, order, ecoregion, model (assessment model), year, FFmsy (F/FMSY), BBmsy (SSB/BMSY), BBtri (SSB/MSY Btrigger), BBlim (SSB/Blim), ABImsy (age-based indicator relative to MSY)

Source

https://github.com/Henning-Winker/ICES-Bmsy-FaF

References

Winker, H., Cardinale, M., Sharma, R., Kell, L.T., Mosqueira, I. and Griffiths, C. (2026). Assessing the progress of stock rebuilding in the Northeast Atlantic against levels that can produce maximum sustainable yield. Fish and Fisheries. doi:10.1111/faf.70066


Simple decline estimators (two-point and log-linear regression)

Description

As in JARA: the change over 3 GL from the first and last observation, and from a log-linear regression, extrapolated to 3 GL.

Usage

iucn_estimators(I, GL = 10, criteria = "A2")

Arguments

I

data.frame(year, index)

GL

generation length

criteria

IUCN criterion

Value

list with the regression rate, predictions, changes and categories


Category probabilities from posterior draws of the change

Description

Category probabilities from posterior draws of the change

Usage

iucn_probs(change, criteria = "A2", NT = FALSE)

Arguments

change

draws of the % change

criteria

IUCN criterion

NT

add the Near Threatened band

Value

named vector of probabilities (%)


IUCN thresholds for criterion A

Description

IUCN thresholds for criterion A

Usage

iucn_thresholds(criteria = "A2", NT = FALSE)

Arguments

criteria

"A1" or "A2" (A2, A3 and A4 share thresholds)

NT

add a Near Threatened band (JARA's NT_opt: 40% decline for A1, 20% otherwise)

Value

named vector of upper % change bounds for CR, EN, VU (and NT)


JARA 1.x helpers for JARA2 fits

Description

Functions of JARA 1.x used in analysis scripts, working on jara2() fits:

  • mixed.trend(): joint indicator of a mixed-trend fit by year, in JARA's layout (Year, Obs, n, ⁠5%⁠, ⁠25%⁠, ⁠50%⁠, ⁠75%⁠, ⁠95%⁠, run); type = "pr" gives the proportion of components above threshold. Computed by jr2_mixed() (geometric mean, bootstrap across components). JARA 1.x labelled its outer quantiles 5% and 95% but computed 2.5% and 97.5%; here the columns are the quantiles they are named after.

  • dfidx(): fitted trajectories (⁠$i⁠: name, yr, mu, lci, uci) and observations with their fits (⁠$o⁠) of each series, with backcast.na as in JARA.

  • jrplot_retrobias() = jrplot_retro(); jrplot_r() = jrplot_changes().

Usage

mixed.trend(
  jara,
  run = "joint",
  refyr = FALSE,
  type = c("mu", "pr"),
  threshold = 1,
  backcast.na = NULL,
  ...
)

dfidx(jara, run = "obs", backcast.na = NULL, ...)

jrplot_retrobias(rt, ...)

jrplot_r(jara, ...)

Arguments

jara

a jara2() fit

run

label in the run column

refyr

scale to the first year's median

type

"mu" (joint indicator) or "pr" (proportion above threshold)

threshold

threshold for type = "pr"

backcast.na

optional year: before it a series enters only from its first observation (as JARA)

...

passed to jr2_mixed() (mixed.trend) or unused

rt

a jr2_retro() object

Value

data.frame (mixed.trend), list (dfidx), ggplot (plots)

Examples

data(jrdat)
f <- jara2(jrdat$Cape_gannet$I, model.type = "mixed.trends", GL = 18.3, fixed.obsE = 0.1, silent = TRUE)
head(mixed.trend(f, run = "gannet"))
str(dfidx(f), max.level = 1)

Fit JARA2: state-space trend model and Red List assessment

Description

Fits the JARA state-space model in RTMB and evaluates the change in abundance over three generation lengths (GL) against the IUCN Red List criterion A thresholds. Arguments keep the names of JARA's build_jara() and fit_jara(), so existing settings carry over; jarainput2jara2() converts a build_jara() object directly.

Usage

jara2(
  I,
  se = NULL,
  model.type = c("relative", "census", "mixed.trends"),
  GL = NULL,
  GL.cv = 0,
  components = NULL,
  assessment = "Unnamed",
  scenario = "s1",
  start.year = NA,
  end.year = NA,
  fixed.obsE = NULL,
  variance.weighting = "model",
  defaults = c("jara2", "jara"),
  sigma.proc.fixed = FALSE,
  sigma.proc = c("shared", "component"),
  rho = 0,
  bias.correct = TRUE,
  timeblock = NULL,
  covariates = NULL,
  cov.lag = 0,
  cov.form = "linear",
  cov.period = NULL,
  proj.mod = "theta10",
  pk.prior = c(0.25, 0.1),
  pk.yr = NULL,
  pk.i = NULL,
  proj.r = "GL3",
  proj.yrs = NULL,
  proj.stoch = FALSE,
  priors = jr2_priors(),
  engine = c("rtmb", "nuts"),
  ndraws = 2000,
  nuts = list(),
  credibility = 0.95,
  criteria = c("A2", "A1"),
  min.yrs = 10,
  max.future = 100,
  window = c("iucn", "jara"),
  smooth = c("jara", "none"),
  osa = TRUE,
  seed = 1,
  silent = FALSE
)

Arguments

I

indices: a data.frame(year, index1, ...), FLIndices, a JABBA or JABBA3 input (see jr2_data()), a jr2_data() object, or a JARA build_jara() object

se

optional data.frame of log-scale SEs (same layout as I)

model.type

"relative", "census" or "mixed.trends" (see jr2_data())

GL

generation length (years). Default as JARA: floor((n.years - 3)/3), with a warning

GL.cv

log-scale CV of the generation length (0: known)

components

census only: component of each index (see jr2_data())

assessment, scenario

labels

start.year, end.year

optional subset of years

fixed.obsE

fixed observation SD added to all indices (default as JABBA3: 0.1 without se, a floor of 0.001 with se; JARA 1.x: 0.15 and 0.01, see defaults)

variance.weighting

"model" (one additional observation SD per index; default, as JABBA3 and MARSS), "equal" (one for all indices; the JARA 1.x default), "fixed" (none: input SEs and fixed.obsE only), or an integer vector assigning indices to variance sets (as sets.var in JABBA3), e.g. c(1, 1, 2)

defaults

"jara2", or "jara" to use the JARA 1.x defaults for the arguments not given explicitly (variance.weighting = "equal", fixed.obsE 0.15 without and 0.01 with se, proj.r = "all", window = "jara"), to reproduce earlier JARA runs

sigma.proc.fixed

FALSE (estimate the process SD) or a value to fix it at

sigma.proc

"shared" process SD across components (JARA) or one per "component"

rho

AR(1) coefficient of the process deviations: 0 (JARA), a fixed value, or "est"

bias.correct

subtract σ2/2\sigma^2/2 from the drift so that mu is the rate of change of mean abundance (JARA)

timeblock

optional year(s) after which the mean rate of change takes a new value

covariates

optional data.frame(year, z1, ...) of covariates (e.g. environmental indices) acting on the annual rate of change: xt=xt−1+μb+∑jβjzj,t−lag+etx_t = x_{t-1} + \mu_b + \sum_j \beta_j z_{j,t-\mathrm{lag}} + e_t. Each covariate is standardised over the data years (mean 0, SD 1), so μb\mu_b stays the mean rate and βj\beta_j is the change in the annual rate (log units) per SD of the covariate; missing years are set to the mean (0). Prior βj∼N(0,beta.sd)\beta_j \sim N(0, \code{beta.sd}) (jr2_priors()). Projections carry no covariate effect (covariates at their mean). Forms other than linear: see cov.form.

cov.lag

lag (years) between a covariate and the rate of change it acts on (default 0: the covariate of year t acts on the change from t-1 to t)

cov.form

form of each covariate effect (recycled, or named by covariate): "linear" (βz\beta z), "quadratic" (β1z+β2z2\beta_1 z + \beta_2 z^2, a dome or U), "asymptotic" (βtanh⁡(zes)\beta \tanh(z e^{s}): an effect that levels off at ±β\pm\beta, with the scale s∼N(0,1)s \sim N(0, 1) estimated) or "cyclic" (β1sin⁡(2πw/P)+β2cos⁡(2πw/P)\beta_1 \sin(2\pi w/P) + \beta_2 \cos(2\pi w/P) on the raw covariate ww, e.g. year for a cycle in time). Each effect is centred over the data years.

cov.period

period PP of each cyclic covariate (in the covariate's units; recycled or named)

proj.mod

"theta10" (JARA default), "logistic", a numeric theta, or "none" (no carrying capacity)

pk.prior

lognormal prior c(median, log.sd) on the ratio of current (maximum) abundance to K

pk.yr

years over which the maximum abundance for K is taken (default all years)

pk.i

census only: median pk per component

proj.r

rate of change used for projections: "GL3" (mean over the last 3 GL years, i.e. the years of the assessment window; default), "all" (mean over all years, the JARA 1.x default), "GL1" (last GL years), a number of recent years, or "mean" (the estimated mean rate of the last block). Series shorter than the window use all years.

proj.yrs

number of projection years (default: 3 GL ahead, enough for the projected state and for criteria A3/A4)

proj.stoch

projections with process error

priors

jr2_priors()

engine

"rtmb" or "nuts"

ndraws

number of draws from the MVN approximation (engine = "rtmb")

nuts

list of tmbstan settings: chains, iter, warmup, seed, cores, control

credibility

credible interval width

criteria

IUCN criteria evaluated: "A2" and "A1" by default; "A3" (projected) and "A4" (window through the present) on request, see jr2_iucn()

min.yrs

minimum length of the assessment window (IUCN: 10 years)

max.future

maximum years into the future for A3 and A4 windows (IUCN: 100)

window

length of the assessment window: "iucn", exactly max⁡(3GL,min.yrs)\max(3 GL, min.yrs) years, or "jara", round(3 GL) - 1 years between the end points as in JARA 1.x (use it to reproduce JARA results)

smooth

"jara": abundance at the ends of a window is the median of the three years around it (JARA); "none": the abundance of the year itself

osa

compute one-step-ahead residuals

seed

random seed for the draws

silent

suppress messages

Details

Model. Log abundance of each component follows a random walk with drift, xk,t=xk,t−1+μk−bσ2/2+ϵk,tx_{k,t} = x_{k,t-1} + \mu_{k} - b\sigma^2/2 + \epsilon_{k,t}, ϵ∼N(0,σ2)\epsilon \sim N(0, \sigma^2) (with rho, AR(1) deviations), observed as log⁡Iit∼N(xk(i),t+log⁡qi,seit2+fixed.obsE2+τ2)\log I_{it} \sim N(x_{k(i),t} + \log q_i, se_{it}^2 + fixed.obsE^2 + \tau^2). timeblock gives the mean rate μ\mu a separate value after each block year. Beyond the data the state is projected with the mean rate of change over the proj.r window, damped near a carrying capacity K=max⁡(N[pk.yr])/pkK = \max(N[pk.yr])/pk with a theta-logistic term (proj.mod), as in JARA.

Estimation. engine = "rtmb" finds the posterior mode (states integrated out by the Laplace approximation) and draws from the multivariate normal approximation of the joint posterior of parameters and states (from the joint precision matrix). engine = "nuts" samples the same posterior with NUTS (tmbstan). All derived quantities (population trajectory, rates of change, change over 3 GL, IUCN probabilities) are computed per draw.

Generation length. GL.cv > 0 gives the GL a lognormal distribution; each posterior draw gets its own GL, so the uncertainty in GL is carried into the 3-GL window and the category probabilities. The window is at least min.yrs (IUCN: 10 years) long.

Value

object of class jara2

Examples

data(jrdat)
fit <- jara2(jrdat$Yellowspot_skate$I, jrdat$Yellowspot_skate$SE, GL = 12)
fit
jrplot_iucn(fit)

Convert a JARA build_jara() object to JARA2

Description

Maps the data and settings of a JARA input (from JARA::build_jara()) to the arguments of jara2() and fits the model, so existing JARA scripts need only one changed line. Settings without a JARA2 counterpart (proc.pen, backcast.na) are dropped with a message. mixed.trends inputs map to model.type = "mixed.trends".

Usage

jarainput2jara2(jarainput, run = TRUE, ...)

Arguments

jarainput

object from JARA::build_jara()

run

fit the model (default) or return the argument list for jara2()

...

further arguments to jara2() (override the converted ones)

Value

a jara2 fit, or a list of arguments

Examples

## Not run: 
jrin <- JARA::build_jara(I = jrdat$Afr_penguin$I, GL = 9, model.type = "census")
fit  <- jarainput2jara2(jrin)

## End(Not run)

Runs test and 3-sigma limits for residuals

Description

As JARA's jr_runs() (Carvalho et al. 2021): a runs test for non-random residual patterns (by default one-sided, testing for positive autocorrelation), and 3-sigma control limits from the average moving range.

Usage

jr_runs(x, mixing = c("less", "two.sided"))

Arguments

x

residuals

mixing

"less" (positive autocorrelation, default) or "two.sided"

Value

list: sig3lim (lower and upper limits) and p.runs


Compare JARA2 fits by AIC

Description

AIC, AICc, Akaike weights and boundary checks for fits to the same index data, e.g. different variance.weighting, time blocks, rho or covariates. Fits must use the same observations and the same fixed parts of the observation variance (se, fixed.obsE); otherwise their likelihoods are not comparable and the function stops. Variances estimated at (near) zero are flagged: AIC is unreliable at the boundary, and differences below about 2 should not be read as support for one model (Auger-Methe et al. 2021).

Usage

jr2_aic(..., boundary = 0.001)

Arguments

...

jara2() fits, or one named list of fits

boundary

SD below which an estimated process or observation SD is flagged as at the boundary

Value

data.frame: model, logLik, df, AIC, AICc, dAIC, weight, A2 status and change, boundary flag

Examples

data(jrdat)
bm <- jrdat$Bluemarlin_Atl_CPUE
runs <- list(equal = jara2(bm$I, bm$SE, GL = 7.3, variance.weighting = "equal", silent = TRUE),
             model = jara2(bm$I, bm$SE, GL = 7.3, variance.weighting = "model", silent = TRUE))
jr2_aic(runs)

A JARA2 fit as a JABBA3 trend fit

Description

Returns the jara2() fit as a jb3trend object (the class of JABBA3::jb3_trend()), so that the JABBA3 trend and index tools apply directly: jbplot_trend(), jbplot_fits(), jbplot_residuals(), jbplot_runs(), jbplot_ppc(), jbplot_jointindex(), jbplot_q(), jbplot_indexcor(), jbplot_noise(), jb3_qtable(), jb3_noise() and jb3_jointindex(). The JARA2 aliases (jrplot_fits() etc.) call them through this function. Intervals and the posterior predictive check use the JARA2 draws (MVN or NUTS).

Usage

jr2_as_jb3trend(fit)

Arguments

fit

a jara2() fit

Value

object of class jb3trend

Examples

data(jrdat)
fit <- jara2(jrdat$Yellowspot_skate$I, jrdat$Yellowspot_skate$SE, GL = 12, silent = TRUE)
tr <- jr2_as_jb3trend(fit)
JABBA3::jb3_qtable(tr)

Prepare abundance data for JARA2

Description

Arranges abundance indices or census counts and their log-scale standard errors for jara2(). Each index belongs to a population component with its own state (log abundance):

"relative"

all indices observe one common trend (CPUE, surveys). Each index has a catchability q; the q of the anchor index (by default the one with the earliest observation) is 1, so the trend is on its scale.

"census"

each index is the absolute abundance of a subpopulation (colony, area). The total population is the sum of the components. With components, several series can observe the same subpopulation: the first series of a component is the absolute count (q = 1), the others get a q.

"mixed.trends"

as census (one state per index), but the components are relative trends of different sites and the population trend is their geometric mean (JARA's mixed.trends).

In relative models the anchor index is moved to the first column (as in JARA), so that it is the reference for q. Zeros are replaced by 0.1 times the index mean (as in JARA) or set to NA (zeros = "na"). Leading years without any observation are dropped.

Usage

jr2_data(
  I,
  se = NULL,
  model.type = c("relative", "census", "mixed.trends"),
  components = NULL,
  anchor = NULL,
  start.year = NA,
  end.year = NA,
  se.na = 0.2,
  zeros = c("replace", "na")
)

Arguments

I

indices in any of these formats: a data.frame(year, index1, index2, ...) (JARA and JABBA format); FLIndices, FLIndexBiomass or FLIndex (or a list of them; SEs from index.var); a JABBA3 data object (JABBA3::jb3_data()); a JABBA input (JABBA::build_jabba()) or a JABBA data list with cpue and se

se

optional data.frame(year, se1, se2, ...) of log-scale standard errors with the columns of I (ignored when I carries its own SEs)

model.type

"relative", "census" or "mixed.trends"

components

census only: component (subpopulation) name of each index; default one component per index

anchor

optional index name(s) whose q is fixed at 1 (one per component)

start.year, end.year

optional subset of years

se.na

SE used where an index value has no SE (only if se is given)

zeros

"replace" (0.1 x index mean, JARA) or "na"

Value

object of class jr2data

Examples

data(jrdat)
d <- jr2_data(jrdat$Afr_penguin$I, model.type = "census")
d

Residual diagnostics table

Description

Runs test p-value, 3-sigma limits and RMSE for each index.

Usage

jr2_diags(fit, type = c("osa", "ordinary"), mixing = "less")

Arguments

fit

a jara2() fit

type

"osa" (one-step-ahead, default) or "ordinary" (log residuals, JARA)

mixing

see jr_runs()

Value

data.frame


Change in abundance and IUCN Red List categories under criterion A

Description

Computes, for every posterior draw, the change in population size over the assessment window of W=max⁡(3GL,min.yrs)W = \max(3 GL, min.yrs) years and the probability of each category:

A1, A2

past reduction: the window ends in the last data year. If the series is shorter than W, the window starts in the first year and ends in the future, using the projection (as in JARA).

A3

(on request) projected reduction: from the last data year to W years ahead (at most max.future).

A4

(on request) any window of length W that includes the last data year (past and future): the window ending 0 to W years after the last data year with the largest median decline.

The window length follows window in jara2(): exactly W years ("iucn", default) or round(3 GL) - 1 years between the end points ("jara", as JARA 1.x, which reproduces its results). With GL.cv > 0 in jara2() each draw has its own GL and window. The status is the most probable category (rule = "max", JARA), the category of the median change ("median"), or the highest category whose cumulative probability reaches p.cut ("cumulative").

Usage

jr2_iucn(
  fit,
  criteria = c("A2", "A1"),
  GL = NULL,
  NT = FALSE,
  rule = c("max", "median", "cumulative"),
  p.cut = 0.5
)

Arguments

fit

a jara2() fit

criteria

any of "A1", "A2", "A3", "A4"

GL

optional generation length to override the fit's (draws are rescaled)

NT

add a Near Threatened band

rule

status rule, see Details

p.cut

probability for rule = "cumulative"

Value

object of class jr2iucn: table (one row per criterion) and change (draws, % change)

Examples

data(jrdat)
fit <- jara2(jrdat$Yellowspot_skate$I, jrdat$Yellowspot_skate$SE, GL = 12, silent = TRUE)
jr2_iucn(fit, c("A2", "A1"), NT = TRUE)

Joint index

Description

A joint index from a relative model, as in JARA: the state-space trend plus, for each year, the mean residual of the indices observed in that year (log scale), applied to every posterior draw of the trend, so the joint index carries the uncertainty of the trend. With weights = "precision" (default) the residuals are weighted by 1/observation variance, which equals the precision-weighted mean of the q-scaled observations and reproduces the hierarchical index of Conn (2010); weights = "equal" gives the unweighted mean residual of JARA 1.x. Relative models only.

Usage

jr2_jointindex(
  fit,
  scale = c("mean", "none"),
  weights = c("precision", "equal")
)

Arguments

fit

a jara2() fit

scale

"mean" (trend and joint index scaled to the mean of the trend) or "none"

weights

"precision" or "equal" (JARA 1.x)

Value

data.frame(year, trend, lci, uci, index, index.lci, index.uci, log.se, n)

References

Conn, P.B. (2010). Hierarchical analysis of multiple noisy abundance indices. Canadian Journal of Fisheries and Aquatic Sciences 67: 108-120.


Generation length and maximum rate of increase from life history

Description

Support tool for setting GL and GL.cv in jara2(). Both methods build a Leslie matrix by age with survival e−Mae^{-M_a} and return the generation length as the mean age of spawners in the unfished population (the IUCN definition), the maximum intrinsic rate of increase r=log⁡λr = \log\lambda from the dominant eigenvalue λ\lambda, and the persistence of process error ρ=exp⁡(−2.2/GL)\rho = \exp(-2.2/GL) (JABBA3::jb3_rho_gt()).

Usage

jr2_lifehistory(
  x,
  method = NULL,
  h = NULL,
  S0 = NULL,
  sex.ratio = 0.5,
  M.cv = 0,
  h.sd = 0,
  nsim = 500,
  seed = 1,
  ...
)

Arguments

x

for "steepness": life-history parameters as for JABBA3::jb3_leslie() (named vector, list or FLPar with linf, k, M, L50, a, b, optional t0, s, amax), an FLStock, or a data.frame with age, M, mat and wt; for "fecundity": a data.frame with age, M, mat and fec (offspring per female per year at age)

method

"steepness" or "fecundity" (default: "fecundity" if x has a fec column)

h

steepness for "steepness" (default from x$s, else 0.7)

S0

first-year survival for "fecundity" (default e−M0e^{-M_0}, the survival of the first age)

sex.ratio

share of females among offspring for "fecundity"

M.cv

lognormal CV of natural mortality for the Monte Carlo (0: point estimate)

h.sd

SD of steepness ("steepness"), or lognormal CV of first-year survival ("fecundity")

nsim

number of Monte Carlo draws (used when M.cv or h.sd > 0)

seed

random seed

...

passed to JABBA3::jb3_leslie() (e.g. sex, amax, plus_group)

Details

method = "steepness" (bony fish; JABBA3::jb3_leslie()): reproduction is spawning biomass per recruit (weight x maturity), and recruitment at low spawning biomass follows the slope at the origin of the Beverton-Holt relationship, 4h/(ϕ0(1−h))4h/(\phi_0(1-h)), with ϕ0\phi_0 the unfished spawning biomass per recruit (SPR0). The absolute scale of weight or fecundity cancels, so steepness hh sets rr.

method = "fecundity" (elasmobranchs and other species with known fecundity): the first row of the Leslie matrix is the number of female offspring per female at age that survive their first year, S0⋅s⋅famaS_0 \cdot s \cdot f_a m_a, with fecundity faf_a (e.g. pups per female per year, divided by the breeding interval), maturity mam_a, the share of females ss and first-year survival S0S_0. No steepness is needed. The implied steepness h=αϕ0/(4+αϕ0)h = \alpha\phi_0/(4 + \alpha\phi_0), with α=S0s\alpha = S_0 s and ϕ0\phi_0 the unfished offspring per recruit, is returned for comparison with steepness priors.

Uncertainty in natural mortality (and steepness or first-year survival) is propagated by Monte Carlo, which gives GL.cv.

Value

list of class jr2lh: GL (median generation length), GL.cv (SD of log GL), rmax, rho, method, summary (median and 95% interval of r, GL, lambda, SPR0 or offspring per recruit, and the implied steepness for "fecundity") and draws

References

Cortés, E. (2002). Incorporating uncertainty into demographic modeling: application to shark populations and their conservation. Conservation Biology 16: 1048-1062.

Examples

# bony fish: steepness and SPR0
lh <- c(linf = 55.7, k = 0.08, M = 0.162, L50 = 31.2, a = 0.0047, b = 3.15, s = 0.75)
jr2_lifehistory(lh, M.cv = 0.2, h.sd = 0.1, nsim = 200)
# shark: 8 pups every second year from age 12, first-year survival 0.6
bio <- data.frame(age = 0:30, M = 0.12, mat = plogis((0:30 - 12)/1.5), fec = c(0, rep(8/2, 30)))
jr2_lifehistory(bio, S0 = 0.6, M.cv = 0.2, nsim = 200)

Compare the JARA2 core with MARSS

Description

Fits the core of a JARA2 model (one latent trend, several relative indices) in the configuration that equals the univariate random walk with drift of MARSS (Holmes et al. 2012), and fits that MARSS model to the same data:

xt=xt−1+u+wt, wt∼N(0,Q);yit=xt+ai+vit, vit∼N(0,Ri), a1=0.x_t = x_{t-1} + u + w_t,\ w_t \sim N(0, Q);\quad y_{it} = x_t + a_i + v_{it},\ v_{it} \sim N(0, R_i),\ a_1 = 0.

The JARA2 run uses flat priors, no bias correction (so u=μu = \mu), no sampling SEs (fixed.obsE = 0) and one observation SD per index (variance.weighting = "model"). Both start from the same diffuse prior on the first state, N(x1,52)N(x_1, 5^2), so both maximise the same marginal likelihood (the Laplace approximation of RTMB is exact for this linear Gaussian model) and the estimates, log-likelihood and smoothed states should agree to numerical precision. Use it to show that the state-space core is standard; what JARA2 adds is the observation model with known SEs, census and multistock totals, time blocks and covariates, and the Red List decision layer.

Usage

jr2_marss(fit, GL = NULL, ..., maxit = 5000, silent = TRUE)

jrplot_marss(x)

Arguments

fit

a jara2() fit of model type "relative" with one component (its data are reused), or the data I as for jara2()

GL

generation length for the Red List output of the JARA2 run (taken from fit if it is a fit)

...

further arguments to jara2() for the JARA2 run (e.g. GL.cv, proj.r, ndraws); arguments that define the MARSS configuration are fixed

maxit

maximum iterations for MARSS

silent

suppress messages

x

a jr2_marss() object

Value

list of class jr2marss: table (parameter, JARA2, MARSS), logLik (MARSS log-likelihood at its own estimates and at the JARA2 estimates), states (year, JARA2, MARSS smoothed log states, centred), max.diff, jara2 (the JARA2 fit in MARSS configuration, a full fit with Red List output: plot(), jrplot_iucn(), ...) and marss (the MARSS fit)

References

Holmes, E.E., Ward, E.J. and Wills, K. (2012). MARSS: multivariate autoregressive state-space models for analyzing time-series data. The R Journal 4, 11-19. doi:10.32614/RJ-2012-002

Examples

if (requireNamespace("MARSS", quietly = TRUE)) {
  bm <- jr2_marss(jrdat$StripedMarlin_IO_CPUE$I, GL = 4.2)
  bm
  jrplot_marss(bm)
}

Joint indicator across stocks or sites (mixed trends)

Description

For model.type = "mixed.trends" (or census) fits: combines the component trajectories into a joint indicator for each posterior draw, as JARA's mixed-trend option used for the CFP stock status indicators (STECF 2022) and the Northeast Atlantic B/BMSY and F/FMSY trajectories (Winker et al. 2026). Each component is, for example, the B/BMSY series of one stock, fitted with q = 1 so that the states stay on the indicator scale.

Usage

jr2_mixed(
  fit,
  scale = c("geomean", "mean", "median"),
  bootstrap = TRUE,
  coverage = c("all", "observed"),
  backcast.na = NULL,
  threshold = NULL,
  direction = c("above", "below"),
  years = NULL,
  seed = 1
)

Arguments

fit

a jara2() fit with more than one component, or a named list of fits (runs, e.g. one per quantity: list("F/Fmsy" = fitf, "B/Bmsy" = fitb)); threshold, direction, scale and coverage can then be given per run (vectors or lists, recycled)

scale

"geomean" (default), "mean" or "median" across components

bootstrap

resample components in each draw

coverage

"all" or "observed" (see Details)

backcast.na

optional year: components enter the indicator before this year only from their first observation

threshold

optional value(s); proportion of components above (or below) each

direction

"above" (e.g. B > BMSY) or "below" (e.g. F < FMSY): the side of threshold whose proportion is returned

years

years to return (default the data years)

seed

random seed for the bootstrap

Details

With bootstrap = TRUE the components are resampled with replacement in each draw, so the uncertainty of the joint indicator includes the variation among stocks as well as the estimation error of each stock. coverage = "observed" leaves out a component in the years before its first and after its last observation (JARA's backcast.na), so the indicator in a year only uses stocks assessed in that year; "all" uses the state-space predictions for missing years. backcast.na = year (as JARA) leaves out a component only in years before both its first observation and the given year, so later missing years are still filled by the state-space predictions. With threshold the function also returns the proportion of components above the threshold (e.g. the proportion of stocks with B/BMSY > 1, or with F/FMSY > 1).

Value

for one fit, a list of class jr2mixed: trj (joint indicator by year: median, credible interval lci-uci, 50\ interval l50-u50, number of components n, and obs, the indicator of the observations of that year), prop (proportion above each threshold, with the observed proportion obs, if thresholds are given), and the draws (draws, prop.draws); for a list of fits, a named list of them (class jr2mixedlist) for jrplot_mixed()

Examples

data(jrdat)
# census counts used here only to illustrate; mixed.trends fits use q = 1 indicator series
f <- jara2(jrdat$Cape_gannet$I, model.type = "mixed.trends", GL = 18.3, fixed.obsE = 0.1, silent = TRUE)
mx <- jr2_mixed(f, threshold = 10)
jrplot_mixed(mx)

Priors for JARA2

Description

Weak priors that keep the posterior proper (needed for NUTS) and stop the variance terms collapsing to zero at the posterior mode. Lognormal priors are given as c(median, log.sd).

Usage

jr2_priors(
  mu.sd = 10,
  sigma = c(0.1, 1.5),
  tau = c(0.1, 1.5),
  q.sd = 10,
  rho = c(0, 1),
  beta.sd = 1
)

Arguments

mu.sd

SD of the normal prior (mean 0) on the mean annual rate of change (log scale); JARA used 31.6

sigma

lognormal prior on the process SD (JARA: gamma(0.001, 0.001) on the precision)

tau

lognormal prior on the additional observation SD, where it is estimated

q.sd

SD of the normal prior (mean 0) on log q of non-anchor indices

rho

normal prior c(mean, sd) on the AR(1) coefficient on the logit scale of (rho + 1)/2, if it is estimated

Value

list of class jr2priors

Examples

jr2_priors(sigma = c(0.1, 2))

Is the process error endogenous or exogenous?

Description

Diagnostics of the fitted process deviations of a one-component model, meant as a first check before trends or reference points are used for advice. Process error from outside the population (exogenous, e.g. environmental regimes) appears as shifts in the mean or variance of the deviations: productivity, and hence any reference point, changes over time. Process error from the population's own dynamics (endogenous, e.g. density dependence that the random walk ignores) depends on the state and is autocorrelated: treating it as noise overstates recovery rates and understates risk. The diagnostics are computed per posterior draw:

  • regimes in the mean (STARS, jr2_stars()), drawn as boxes of mean +- 2 SD per regime;

  • lag-1 autocorrelation of the deviations, before and after removing the regime means: autocorrelation that disappears once the regimes are removed points to exogenous step changes;

  • slope of the deviation on the (centred) log state of the previous year, minus the mean slope of a pure random walk of the same length (a random walk regressed on its own level gives a negative slope, the Dickey-Fuller bias): a corrected slope below zero points to compensation (endogenous). In simulations (50 years) P(< 0) exceeded 0.95 for 85% of Gompertz series (compensation 0.3) and for 20% of random walks, so treat it as a screen and confirm with a model that includes density dependence;

  • ratio of the SD of the deviations in the last and first regime (a change in variability);

  • correlation with each covariate in env (e.g. environmental indices), at lag env.lag.

The smoothed deviations of a state-space model are themselves slightly autocorrelated, and the two explanations are not exclusive, so read the results as a screen, not a test.

Usage

jr2_procdiag(fit, env = NULL, env.lag = 0, L = 10, p = 0.1, seed = 1)

jrplot_procdiag(x, ...)

Arguments

fit

a jara2() fit with one component

env

optional data.frame(year, covariate1, ...) of covariates

env.lag

lag (years) of the covariates relative to the deviations (default 0)

L, p

passed to jr2_stars()

seed

random seed for the random-walk reference of the slope

x

a jr2_procdiag() object (or a jara2() fit, passed to jr2_procdiag())

...

passed to jr2_procdiag() when x is a fit

Value

list of class jr2procdiag: summary (median, interval and probability per diagnostic), series (year, deviation quantiles, lagged state, regime), regimes, acf (autocorrelation by lag across draws), stars, env and the draws of each statistic

Examples

data(jrdat)
s <- jrdat$SmoothhoundShark
fit <- jara2(s$I, s$SE, GL = 13.7, silent = TRUE)
pd <- jr2_procdiag(fit, L = 6)
pd
jrplot_procdiag(pd)

Retrospective analysis and hindcast cross-validation

Description

Refits the model with the last peels years removed (all settings unchanged, including GL), as JARA's jara_hindcast(). Returns the population trajectories, the IUCN tables of each peel, Mohn's rho of the population trajectory and the hindcast cross-validation of one-step-ahead index predictions (MASE; Kell et al. 2021). MASE < 1 means the model predicts the index better than a naive random walk (last observed value).

Usage

jr2_retro(fit, peels = 1:5, ndraws = 1000)

Arguments

fit

a jara2() fit

peels

number of years removed, e.g. 1:5

ndraws

draws per refit (fewer than the main fit is enough)

Value

object of class jr2retro

Examples

data(jrdat)
fit <- jara2(jrdat$Yellowspot_skate$I, jrdat$Yellowspot_skate$SE, GL = 12, silent = TRUE)
rt <- jr2_retro(fit, 1:5)
rt$rho
jrplot_retro(rt)

Change over the assessment window by end year

Description

The posterior of the change over the preceding W=max⁡(3GL,10)W = \max(3 GL, 10) years for every possible end year, from the first year a full window is available to W years after the last data year (end years after the last data year use the projection). This shows A2 (end = last data year), A3 (start = last data year) and every A4 window in one view, and how the assessment would have looked in earlier years given the full series.

Usage

jr2_rolling(fit, criterion = "A2")

Arguments

fit

a jara2() fit

criterion

IUCN criterion for the category probabilities

Value

data.frame(end, start, change, lci, uci, projected, category probabilities)


Regime shifts in the process deviations (STARS)

Description

Sequential t-test analysis of regime shifts (STARS; Rodionov 2004), in the version of Szuwalski et al. (search resumes one regime length after a confirmed shift, no Huber weights), applied to the fitted process deviations (for models with one component; the deviations of the annual rate of change from its mean) or to the annual rate of change of the population total (census and mixed models). A shift in the mean of these series is a change in the rate of change, so the detected shift years suggest where to set timeblock in jara2().

Usage

jr2_stars(fit, L = 10, p = 0.1, sig = NULL, ndraws = 500, on = NULL)

jrplot_stars(x, ...)

Arguments

fit

a jara2() fit (typically without timeblock)

L

minimum regime length (cut-off length, years; default 10, at most a third of the series)

p

significance level of the t-test (two-sided); ignored if sig is given

sig

critical t value (default qt(1 - p/2, 2L - 2); Szuwalski used 1.68)

ndraws

number of posterior draws for P.shift (0 for none)

on

"procdev" (process deviations; one-component models) or "rate" (annual rate of change of the total)

x

a jr2_stars() object (or a jara2() fit, passed to jr2_stars())

...

passed to jr2_stars() when x is a fit

Details

STARS is run on the posterior median series, and on ndraws posterior draws to give the probability of a shift starting in each year (P.shift, and within +-1 year of each detected shift, P.shift.pm1), which shows how firm each change point is. The posterior median is smoother than the data, so the t-test on it finds shifts easily: treat the suggested years as exploratory, weigh them by their support across draws and by prior knowledge (e.g. the year of a management measure), and note that effects estimated for breaks chosen from the same data are overstated.

Value

list of class jr2stars: shifts (start year of each new regime, suggested timeblock year = start - 1, P.shift of that year and P.shift.pm1 within +-1 year), regimes (start, end, mean, sd), series (year, median, lci, uci, P.shift), timeblock (suggested years) and the settings

References

Rodionov, S.N. (2004). A sequential algorithm for testing climate regime shifts. Geophysical Research Letters 31, L09204. doi:10.1029/2004GL019448

Examples

data(jrdat)
s <- jrdat$SmoothhoundShark
fit <- jara2(s$I, s$SE, GL = 13.7, silent = TRUE)
st <- jr2_stars(fit, L = 6)
st$shifts
jrplot_stars(st)

Current and projected state relative to a reference period

Description

As JARA's jrplot_state(): the posterior of the population in the last data year (current) and at the end of the projection relative to the mean of the reference years (default the first three years), with the probability that the projected population falls below extinction (quasi-extinction relative to the reference).

Usage

jr2_state(fit, ref.yr = NULL, prj.yr = NULL, extinction = 0.01)

jrplot_state(fit, projected = TRUE, ...)

Arguments

fit

a jara2() fit

ref.yr

reference year(s); default the first three years

prj.yr

projected year; default 3 GL after the last data year (max(3 GL, 10) years, at most 100)

extinction

quasi-extinction threshold relative to the reference

projected

also show the projected state

...

passed to jr2_state()

Value

jr2_state(): list with state (median and credible interval of the current and projected state), prob.extinct and the draws; jrplot_state(): a ggplot

Examples

data(jrdat)
fit <- jara2(jrdat$Yellowspot_skate$I, jrdat$Yellowspot_skate$SE, GL = 12, silent = TRUE)
jr2_state(fit)$state
jrplot_state(fit)

Effect of time block breaks on the rate of change

Description

The change in the mean rate of change across each timeblock year (the "effect", as JARA's mean.dr): the rate of the block after minus the rate of the block before, on the log scale, expressed as % change in the annual rate, 100(erb+1−rb−1)100(e^{r_{b+1} - r_b} - 1), with its credible interval and the probability of a positive effect (a higher rate of change after the break, e.g. after a management measure). For models with one component (relative indices) the rates are the estimated drifts of the blocks (JARA's effect); for census and mixed models, with one drift per component, they are the mean rates of change of the population total in each block. jrplot_tbeffect() plots the posterior of each effect with its median and P(effect > 0).

Usage

jr2_tbeffect(fit)

jrplot_tbeffect(fit)

Arguments

fit

a jara2() fit with timeblock

Value

jr2_tbeffect(): data.frame(break.year, before, after, effect, lci, uci, P.positive) with the draws (%) in attribute "draws"; jrplot_tbeffect(): a ggplot

Examples

data(jrdat)
s <- jrdat$SmoothhoundShark
fit <- jara2(s$I, s$SE, GL = 13.7, timeblock = c(1998, 2008), silent = TRUE)
jr2_tbeffect(fit)
jrplot_tbeffect(fit)

Rates of change by time block

Description

For a fit with timeblock year(s): the mean annual rate of change of the population (%) in each block, from the posterior draws of the population total (the mean log change between the first and last year of the block), with its credible interval and the probability of an increase, and the probability that the rate increased from each block to the next (e.g. after a management measure, as in Pacoureau et al. 2023). Without time blocks the whole series is one block.

Usage

jr2_timeblock(fit)

Arguments

fit

a jara2() fit

Value

data.frame(block, start, end, rate, lci, uci, P.increase, P.faster) with the draws in attribute "draws"

Examples

data(jrdat)
s <- jrdat$SmoothhoundShark
fit <- jara2(s$I, s$SE, GL = 13.7, timeblock = c(1998, 2008), silent = TRUE)
jr2_timeblock(fit)

JARA example datasets

Description

jrdat: the example datasets of JARA, each a list with I (data.frame(year, indices)) and, for relative indices, SE (log-scale standard errors): Afr_penguin, Cape_gannet, Mountain_zebra (census counts by colony or reserve), StripedMarlin_IO_CPUE, Bluemarlin_Atl_CPUE, Bluemarlin_ICCAT, SmoothhoundShark, Yellowspot_skate (relative indices). jara.examples: the settings used in the JARA examples (generation length, model type).

Format

lists and a data.frame

Source

JARA (https://github.com/Henning-Winker/JARA)


Compare several JARA2 runs

Description

Sensitivity plots for a (named) list of jara2() fits, in the style of JABBA3::jbplot_ensemble(): "trajectory" overlays the estimated population trajectories (projections dotted), and "change" overlays the posteriors of the change over the assessment window on the IUCN category bands, with each run's status and its probability in the legend. Runs are told apart by colour and line type, so overlapping runs stay visible.

Usage

jrplot_compare(
  fits,
  type = c("trajectory", "change", "both"),
  criterion = NULL,
  ci = c("none", "ribbon"),
  scale = c("none", "mean"),
  projection = TRUE,
  colours = NULL
)

Arguments

fits

named list of jara2() fits (unnamed fits are called run1, run2, ...)

type

"trajectory", "change" or "both"

criterion

criterion for "change" (default: the first of each fit)

ci

add credible intervals to the trajectories ("ribbon") or not ("none")

scale

"none" or "mean" (each trajectory divided by its mean over the data years, for runs with different scaling)

projection

show the projected years in the trajectories (FALSE: data years only)

colours

optional colours (named by run, or recycled); default the JABBA3 palette as in JABBA3::jbplot_ensemble()

Value

a ggplot object (patchwork for "both")

Examples

data(jrdat)
bm <- jrdat$Bluemarlin_Atl_CPUE
runs <- list(model = jara2(bm$I, bm$SE, GL = 7.3, silent = TRUE),
             equal = jara2(bm$I, bm$SE, GL = 7.3, variance.weighting = "equal", silent = TRUE),
             GL1   = jara2(bm$I, bm$SE, GL = 7.3, proj.r = "GL1", silent = TRUE))
jrplot_compare(runs, type = "both")

Plot covariate effects

Description

Estimated effect of each covariate on the annual rate of change (log units per year), with credible bands, over the observed range of the covariate (rug: observed values).

Usage

jrplot_covariates(fit, n.grid = 60)

Arguments

fit

a jara2() fit with covariates

n.grid

number of grid points

Value

a ggplot object

Examples

set.seed(11); yr <- 1976:2020
env <- data.frame(year = yr, SST = as.numeric(arima.sim(list(ar = 0.6), 45)))
x <- cumsum(c(0, -0.02 + 0.1*tanh(2*env$SST[-1]) + rnorm(44, 0, 0.05)))
I <- data.frame(year = yr, cpue = exp(x + rnorm(45, 0, 0.1)))
fit <- jara2(I, GL = 6, covariates = env, cov.form = "asymptotic", silent = TRUE)
jrplot_covariates(fit)

Hindcast cross-validation plot

Description

Drawn by JABBA3::jbplot_hcxval(): for each index, the observations (open circles), the reference fit (black), and the fit of each retrospective peel up to the first year it did not see, with that one-step-ahead prediction marked, and the mean absolute scaled error (MASE; Kell et al. 2021) in the panel label. MASE < 1: the model predicts the next year of the index better than the naive prediction (the last observed value).

Usage

jrplot_hcxval(rt, nyears = 5, indices = NULL, ncol = NULL)

Arguments

rt

a jr2_retro() object

nyears

years before the hindcast horizon to show

indices

optional subset of indices

ncol

facet columns

Value

a ggplot (MASE table in attribute "mase")

Examples

data(jrdat)
fit <- jara2(jrdat$Yellowspot_skate$I, jrdat$Yellowspot_skate$SE, GL = 12, silent = TRUE)
rt <- jr2_retro(fit, 1:5)
jrplot_hcxval(rt)

Plot joint indicators

Description

jrplot_mixed(): the joint indicator of one or several runs (quantities) with its 50\ the observed values of each year (points), as the indicator plots of Winker et al. (2026). Runs are given as a named list of jr2_mixed() objects, or as the output of jr2_mixed() for a list of fits, and are colour-coded. type = "median" plots the joint indicators (e.g. F/FMSY and B/BMSY), type = "prob" the proportion of components on the chosen side of each run's threshold (e.g. F < FMSY and B > BMSY, set by direction in jr2_mixed()).

Usage

jrplot_mixed(
  mx,
  type = c("both", "median", "prob", "indicator", "proportion"),
  ref = NULL,
  obs = TRUE,
  cols = NULL,
  ...
)

Arguments

mx

a jr2_mixed() object, or a named list of them (runs)

type

"median", "prob", or "both" (a list of two ggplots); "indicator" and "proportion" are accepted as synonyms

ref

reference line(s) for type = "median" (e.g. 1)

obs

show the observed values

cols

optional colours, one per run

...

unused

Value

a ggplot, or a list of two

Examples

data(jrdat)
f <- jara2(jrdat$Cape_gannet$I, model.type = "mixed.trends", GL = 18.3, fixed.obsE = 0.1, silent = TRUE)
mx <- jr2_mixed(list(above = f, below = f), threshold = 10, direction = c("above", "below"))
jrplot_mixed(mx, type = "prob")

Prior and posterior of the variance parameters

Description

Densities of the prior (grey) and the posterior (blue) of the process SD and, where estimated, the additional observation SD (as JABBA3::jbplot_priorpost()), with the ratio of posterior to prior median (PPMR) and of posterior to prior variance on the log scale (PPVR). A posterior equal to the prior (PPVR near 1) means the data carry little information on that parameter; a posterior piled up at the lower end of the prior means the variance is weakly identified and the prior holds it away from zero.

Usage

jrplot_priorpost(fit)

Arguments

fit

a jara2() fit

Value

a ggplot; the table in attribute "table"

Examples

data(jrdat)
fit <- jara2(jrdat$SmoothhoundShark$I, jrdat$SmoothhoundShark$SE, GL = 13.7, silent = TRUE)
jrplot_priorpost(fit)

Retrospective plots

Description

jrplot_retro(): population trajectories of the retrospective peels with Mohn's rho (as JABBA3::jbplot_retro()). jrplot_retroiucn(): category probabilities by terminal year of each peel.

Usage

jrplot_retro(rt, ...)

jrplot_retroiucn(rt, criterion = NULL, style = c("density", "bars"), ...)

Arguments

rt

a jr2_retro() object

...

unused

criterion

IUCN criterion

style

"density" (default): for each terminal year, the posterior of the change over the assessment window as a half-violin coloured by IUCN category, with the status on top (as Grüss et al. 2024, Fig. 4b); "bars": stacked category probabilities

Value

a ggplot


Trajectories with the observations

Description

Relative models: the population trend with the q-scaled indices coloured by index (as the B panel of JABBA3::jabbaplot3()). Census and mixed models: the trajectory of each component with its observations, colour-coded by component, on the absolute scale, with credible intervals at cr (default 90%); the y-axis is set by the data and the medians, so wide intervals in years without observations do not dominate.

Usage

jrplot_trjobs(fit, log = FALSE, cr = 0.9, ...)

Arguments

fit

a jara2() fit

log

log scale

cr

credibility of the component intervals (census and mixed models)

...

unused

Value

a ggplot


JARA2 population and Red List plots

Description

Plots of the population trajectory and the Red List assessment, in the JABBA3 style. The index and trend diagnostics are the JABBA3 functions (jrplots_jb3); jaraplot2() (and plot(fit)) combines both.

Usage

jrplot_indices(fit, log = FALSE, ...)

jrplot_poptrj(fit, projection = TRUE, obs = TRUE, stacked = FALSE, ...)

jrplot_components(fit, projection = FALSE, overlay = FALSE, ...)

jrplot_rate(fit, ...)

jrplot_changes(fit, ...)

jrplot_procdev(fit, ...)

jrplot_iucn(
  fit,
  criterion = NULL,
  NT = FALSE,
  labels = c("bands", "legend"),
  ...
)

jrplot_criteria(fit, NT = FALSE, ...)

jrplot_rolling(fit, criterion = "A2", ...)

jrplot_timeblock(fit, ...)

Arguments

fit

a jara2() fit (or index data for jrplot_indices, see jr2_data())

log

plot on log scale

...

unused

projection

show the projection years

obs

show the q-scaled observations (relative models)

stacked

census models: the component trajectories as stacked areas under the total (data years)

overlay

jrplot_components: all components in one panel (log scale) instead of one panel each

criterion

IUCN criterion

NT

show the Near Threatened band

labels

jrplot_iucn(): "bands" (default; category and probability written on each band) or "legend"

Details

  • jrplot_indices(): observed indices with 95\

  • jrplot_poptrj(): population trajectory with credible interval, projection and the 1-3 GL marks back from the last data year; relative models show the q-scaled observations by index

  • jrplot_components(): census and mixed models: trajectory of each component with its observations

  • jrplot_rate(): annual rate of change of the population by year

  • jrplot_changes(): posteriors of the mean annual rate of change over all years and the last 1, 2 and 3 GL

  • jrplot_procdev(): process deviations

  • jrplot_iucn(): posterior of the change over the assessment window on the IUCN category bands

  • jrplot_criteria(): category probabilities for each criterion evaluated, with the status

  • jrplot_rolling(): change over the assessment window for every end year (jr2_rolling()) on the IUCN bands

  • jrplot_timeblock(): posteriors of the mean annual rate of change in each time block (jr2_timeblock()); block boundaries are marked in jrplot_poptrj() and jrplot_rate(), which also shows the block means (dark red)

Value

a ggplot

Examples

data(jrdat)
fit <- jara2(jrdat$Yellowspot_skate$I, jrdat$Yellowspot_skate$SE, GL = 12, silent = TRUE)
jrplot_poptrj(fit)
jrplot_iucn(fit)
jrplot_rolling(fit)

JARA plots from JABBA3

Description

The index and trend plots of JARA, drawn by the JABBA3 functions on a jara2() fit (through jr2_as_jb3trend()), so JARA2 and JABBA3 graphics are the same. Names follow JARA 1.x:

jrplot_trjfit() JABBA3::jbplot_trend(): q-scaled indices with the trend (relative); component states and total (census)
jrplot_fits() JABBA3::jbplot_fits(): fits to each index with credible and predictive intervals
jrplot_logfits() jbplot_fits(log = TRUE)
jrplot_residuals() JABBA3::jbplot_residuals(): residuals by year, OSA by default
jrplot_runstest() JABBA3::jbplot_runs(): runs tests with 3-sigma limits
jrplot_PPC() JABBA3::jbplot_ppc(): posterior predictive check
jrplot_jointindex() JABBA3::jbplot_jointindex(): joint index
jrplot_q() JABBA3::jbplot_q(): catchability relative to the reference index
jrplot_indexcor() JABBA3::jbplot_indexcor(): correlation of the log indices
jrplot_noise() JABBA3::jbplot_noise(): observation and process noise by index
jr_qtable(), jr_noise() JABBA3::jb3_qtable(), JABBA3::jb3_noise()

Usage

jrplot_trjfit(fit, ...)

jrplot_fits(fit, log = FALSE, years = c("observed", "all"), ...)

jrplot_logfits(fit, years = c("observed", "all"), ...)

jrplot_residuals(fit, type = c("osa", "ordinary"), ...)

jrplot_runstest(fit, type = c("osa", "ordinary"), ...)

jrplot_PPC(fit, ...)

jrplot_jointindex(fit, ...)

jrplot_q(fit, ...)

jrplot_indexcor(fit, ...)

jrplot_noise(fit, ...)

jr_qtable(fit, ...)

jr_noise(fit, ...)

Arguments

fit

a jara2() fit

...

passed to the JABBA3 function

log

plot on log scale

years

jrplot_fits(), jrplot_logfits(): "observed" (default; years with observations) or "all" (the expected index with credible and predictive intervals in every model year, also before the first and after the last observation of an index)

type

residual type: "osa" (default) or "ordinary" (JARA's log residuals)

Value

a ggplot (tables for jr_qtable(), jr_noise())

Examples

data(jrdat)
fit <- jara2(jrdat$Yellowspot_skate$I, jrdat$Yellowspot_skate$SE, GL = 12, silent = TRUE)
jrplot_fits(fit)
jrplot_fits(fit, years = "all")
jrplot_runstest(fit)

Log-likelihood and AIC of a JARA2 fit

Description

The marginal log-likelihood of the index data, with the latent states integrated out (Laplace approximation; exact for the Gaussian JARA2 model), evaluated at the mode and with the prior densities of the parameters removed. The first state keeps its diffuse prior, as the initial-state variance V0 in MARSS. df counts the estimated parameters that enter the likelihood (drift per block, process and observation SDs, catchabilities, AR(1), covariate effects). stats::AIC() and stats::BIC() then work on JARA2 fits; jr2_aic() compares several.

Usage

## S3 method for class 'jara2'
logLik(object, ...)

Arguments

object

a jara2() fit

...

unused

Value

object of class logLik


JARA2 summary plot with selectable panels

Description

A grid of panels, as JABBA3::jabbaplot3(). type = "full" (2 x 3): population trajectory, rate of change over all years and the last 1-3 GL, current and projected state relative to the first years / trend with the q-scaled indices (relative models) or the component trajectories with their observations (census and mixed models), OSA residuals and the IUCN plot. type = "simple" (2 x 2): population trajectory (with the q-scaled indices for relative models), rate of change, state and the IUCN plot. For census models the population panel shows the component trajectories as stacked areas under the total (its legend identifies the colours of the components panel). plot(fit) calls jaraplot2(fit).

Usage

## S3 method for class 'jara2'
plot(x, ...)

jaraplot2(
  fit,
  type = c("full", "simple"),
  criterion = NULL,
  panels = NULL,
  ncol = NULL,
  base_size = 9
)

Arguments

x

a jara2() fit

...

passed to jaraplot2()

fit

a jara2() fit

type

"full" (6 panels) or "simple" (4 panels); ignored when panels is given

criterion

IUCN criterion of the IUCN panel ("A2" or "A1"; default the first evaluated)

panels

panel names, in order: any of "poptrj", "poptrj.obs", "rate", "state", "trjobs", "residuals", "iucn", "changes", "timeblock", "tbeffect", "priorpost", "criteria", "procdev", "jointindex", "components", "fits", "runs", "indices", "rolling"

ncol

number of columns

base_size

font size

Value

a patchwork (or a list of ggplots if patchwork is not installed)

Examples

data(jrdat)
fit <- jara2(jrdat$Yellowspot_skate$I, jrdat$Yellowspot_skate$SE, GL = 12, silent = TRUE)
jaraplot2(fit)
jaraplot2(fit, type = "simple", criterion = "A1")

Summary of a JARA2 fit

Description

Summary of a JARA2 fit

Usage

## S3 method for class 'jara2'
summary(object, ...)

Arguments

object

a jara2() fit

...

unused

Value

list with parameters, IUCN table, rates of change, goodness of fit and residual diagnostics