Package {IncAAM}


Type: Package
Title: Bayesian Age-at-Maturity Analysis from Increment-Width Growth Series
Version: 1.8
Description: Bayesian hierarchical nonlinear mixed-effects analysis for estimating age at sexual maturity from annual increment-width growth series. The method estimates age at maturity using tangent-ratio and jerk approaches and provides a posterior threshold-crossing ogive with an estimated A50. Methodological details and applications are described in Campana, Smoliński, Morrongiello and Black (2026, in press).
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.3.3
Imports: dplyr, tidyr, purrr, tibble, ggplot2, posterior, minpack.lm, brms
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-09-14 09:36:01 UTC; ssmolinski
Author: Steven Campana [aut, cre], Szymon Smoliński [aut], Bryan Black [aut], John Morrongiello [aut]
Maintainer: Steven Campana <steven.e.campana@gmail.com>
Depends: R (≥ 4.1.0)
LazyData: true
Repository: CRAN
Date/Publication: 2026-10-06 07:30:22 UTC

IncAAM (Version 1.8): Bayesian age-at-maturity analysis from increment-width growth series

Description

Fits a Bayesian hierarchical nonlinear mixed-effects model to annual increment-width data and estimates age at maturity using posterior threshold-ratio (TR) and jerk approaches. The model uses a negative exponential curve with fish-level varying parameters.

Usage

IncAAM(
  data,
  FishID = "FishID",
  Inc_num = "Inc_num",
  Inc_width = "Inc_width_mm",
  sex = "female",
  female_threshold = 0.14,
  male_threshold = 0.24,
  custom_threshold = NULL,
  known_A50 = NULL,
  min_Inc_num = 2,
  min_increments = 3,
  min_fish = 3,
  jerk_step = 0.01,
  chains = 4,
  cores = 4,
  n_iter = 1500,
  n_warmup = 750,
  n_keepdraws = 500,
  seed = 123,
  backend = "cmdstanr",
  n_adapt_delta = 0.995,
  n_logc_sd = 0.1,
  max_treedepth = 15,
  make_plots = TRUE,
  save_plots = FALSE,
  output_dir = NULL
)

Arguments

data

A data frame containing annual increment-width measurements, with one row per increment width. Data should be filtered to the desired analysis group before calling IncAAM().

FishID

Character string giving the column name identifying individual fish.

Inc_num

Character string giving the column name containing increment number (used as the age-like predictor).

Inc_width

Character string giving the column name containing increment width.

sex

Character string selecting the sex-specific TR threshold: "female", "male", or "custom". When "custom" is selected, the value supplied to custom_threshold is used.

female_threshold

Numeric TR threshold used when sex = "female". Default is 0.14.

male_threshold

Numeric TR threshold used when sex = "male". Default is 0.24.

custom_threshold

Numeric TR threshold used when sex = "custom".

known_A50

Optional numeric value giving a known or published A50 to display as a reference in plots.

min_Inc_num

Minimum increment number retained for analysis. Default is 2.

min_increments

Minimum number of increment observations required per fish. Default is 3.

min_fish

Minimum number of fish required for the hierarchical model. Default is 3.

jerk_step

Step size used when numerically locating the jerk maximum. Default is 0.01.

chains

Number of MCMC chains. Default is 4.

cores

Number of CPU cores used for model fitting. Default is 4.

n_iter

Total number of MCMC iterations per chain. Default is 1500.

n_warmup

Number of warm-up iterations per chain. Default is 750.

n_keepdraws

Number of posterior draws retained for downstream summaries.

seed

Random-number seed. Default is 123.

backend

Backend passed to brms::brm(). Default is "cmdstanr".

n_adapt_delta

Target acceptance probability for Stan adaptation. Default is 0.995.

n_logc_sd

Prior standard deviation for the fish-level random effect of logc. Default is 0.1.

max_treedepth

Maximum NUTS tree depth. Default is 15.

make_plots

Logical; if TRUE, create the posterior distribution and threshold-crossing ogive plots. Default is TRUE.

save_plots

Logical; if TRUE, save generated plots as PDF files. Default is FALSE.

output_dir

Directory used when save_plots = TRUE. Must be supplied by the user when plots are to be saved. Default is NULL.

Details

The input data should represent one analysis group. IncAAM() does not perform grouping by species, sex, axis, stock, or other variables; users should filter the data before calling the function.

The model describes increment width using a negative exponential function,

Increment = a + b exp(-c Inc\_num),

with fish-level varying parameters a, b, and c. The parameters are estimated in log space in a Bayesian hierarchical model using brms.

The TR estimate is derived from the posterior distribution of c and the selected threshold. Jerk is calculated numerically from posterior fitted curves. The function then summarizes the posterior estimates across fish and constructs a posterior threshold-crossing ogive. A logistic ogive is fitted to the crossing probabilities, providing an estimated ogive A50 where the fitted probability reaches 0.5.

The threshold-crossing ogive describes the probability that the Tangent Ratio (TR) has fallen below the defined TR threshold at a given increment number, and therefore indicates sexual maturity according to the selected threshold. Ogive_A50 is the estimated increment number at 50% maturity from the fitted logistic ogive. The TR index is the estimated age at 50% maturity when the selected TR threshold is the maturity criterion calibrated for that purpose. The Jerk index is the increment number corresponding to the maximum jerk and is not currently assigned to a defined proportion or stage of sexual maturity.

Details of the model, method, outputs and applications are provided in Campana, Smoliński, Morrongiello and Black (2026, in press). Users should consult this publication for the methodological background and interpretation of IncAAM outputs.

The function returns the fitted Bayesian model together with fish-level estimates, increment-level threshold-crossing probabilities, posterior group distributions, ogive results, fitted curves, diagnostics, settings, and optional plots.

Value

An object of class IncAAM (a list) containing:

summary

Group-level summary of TR and Jerk estimates.

fish

Fish-level posterior summaries of model parameters, TR, and Jerk.

increment

Fish- and increment-level posterior threshold-crossing probabilities.

posterior

Posterior group-level draws for TR and Jerk.

crossing_ogive

Observed posterior crossing-ogive summary by increment number.

crossing_ogive_prediction

Predicted values from the fitted logistic ogive.

ogive_summary

Estimated ogive A50, slope, and intercept.

ogive_plot

Threshold-crossing ogive plot, when plots are enabled.

fitted_curves

Fish-level fitted negative-exponential curves.

model

The fitted brms model object.

diagnostics

MCMC and sampling diagnostics.

settings

Analysis settings used by the function.

data

Basic information on the analyzed data.

plot

Posterior TR/Jerk density plot, when plots are enabled.

Examples


# Example based on the current IncAAM test workflow:
library(IncAAM)
library(dplyr)

data(plaice)
head(plaice)
plaice_female <- plaice |>
dplyr::filter(Sex == "female")

fit <- IncAAM(
  data = plaice_female,
  FishID = "FishID",
  Inc_num = "Inc_num",
  Inc_width = "Inc_width_mm",
  sex = "female",
  known_A50 = 7.6,
  n_iter = 1500,
  n_warmup = 750,
  n_keepdraws = 500,
  n_adapt_delta = 0.995,
  n_logc_sd = 0.1
)

#Users can display the complete set of model outputs with `print(fit)`,
#or inspect individual output components directly (e.g. `fit$summary`).

print(fit)

fit$summary
fit$crossing_ogive
fit$ogive_summary



Example plaice otolith increment data

Description

A small example dataset containing otolith increment-width measurements from 28 plaice (Pleuronectes platessa) of both sexes. The dataset is provided for demonstrating the IncAAM workflow, including data filtering, preparation, and age-at-maturity modelling.

Usage

data(plaice)

Format

A data frame with 347 rows and 7 variables:

Species

Species name.

FishID

Unique fish identifier.

Sex

Sex of the fish (male or female).

Axis

Otolith axis used for increment measurements (section).

Inc_num

Sequential increment number.

Inc_width_mm

Width of the otolith increment in millimetres.

Fishlen_cm

Fish length in centimetres.

Details

The dataset contains complete increment-width series for 28 individual fish and is intentionally composed of both males and females. In the example workflow, the data are first loaded with data(plaice) and subsequently filtered to retain female fish before fitting the age-at-maturity model.

Source

Example data prepared for the IncAAM package.