Skip to contents

Calculates the likelihood for observed age compositions.

Usage

get_age_like(
  af_switch = 1L,
  removal_switch_f,
  af_year,
  af_fishery,
  af_min_age,
  af_max_age,
  af_obs,
  af_n,
  par_log_af_alpha,
  catch_pred_fya,
  af_logistic_normal_min_prop = 1e-06,
  af_logistic_normal_epsilon = 1e-06
)

Arguments

af_switch

Integer specifying likelihood type (1=multinomial, 2=Dirichlet, 3=Dirichlet-multinomial, 4=Francis LN1 logistic-normal, 9=KL divergence).

removal_switch_f

A vector of removal flags: 0 uses the composition as a likelihood for a standard selectivity-based fishery; 1 uses it to condition direct catch-at-age removals and excludes its likelihood contribution.

af_year

A vector of year indices for each age composition observation.

af_fishery

A vector of fishery indices for each age composition observation.

af_min_age

A vector of minimum ages for aggregation in each observation.

af_max_age

A vector of maximum ages for aggregation in each observation.

af_obs

A matrix of observed age composition proportions with rows as observations and columns as ages.

af_n

A vector of effective sample sizes for each observation.

par_log_af_alpha

Vector of log concentration parameters for the Dirichlet likelihoods. The implementation indexes these as af_fishery - 4 and therefore expects age compositions only for fisheries 5 and 6 when a Dirichlet option is active. This argument is not used for the logistic-normal option because its dispersion is profiled conditionally within fishery.

catch_pred_fya

A 3D array of predicted catch with dimensions fishery by year by age.

af_logistic_normal_min_prop

Positive minimum observed proportion used to identify the first and last retained bins for year-specific tail compression under the logistic-normal option. Bins between those two endpoints are retained even when they fall below this threshold.

af_logistic_normal_epsilon

Positive replacement for exact observed zeros that remain between the retained tail endpoints under the logistic-normal option. The adjusted composition is renormalized before evaluating the likelihood.

Value

A numeric vector of negative log-likelihood contributions for each observation. Predicted age composition proportions are reported via REPORT(af_pred) after the standard observation-specific end pooling, but before logistic-normal tail compression or zero replacement. For af_switch = 4, the conditionally profiled LN1 standard deviation for each fishery is also reported as af_logistic_normal_sigma_f.