Skip to contents

Calculates the likelihood for observed age compositions.

Usage

get_age_like(
  af_switch = 1,
  removal_switch_f,
  af_year,
  af_fishery,
  af_min_age,
  af_max_age,
  af_obs,
  af_n,
  par_log_af_alpha,
  catch_pred_fya
)

Arguments

af_switch

Integer specifying likelihood type (1=multinomial, 2=Dirichlet, 3=Dirichlet-multinomial, 9=KL divergence).

removal_switch_f

A vector of flags indicating whether each fishery is active (0) or inactive.

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

A vector of log-scale concentration parameters for Dirichlet likelihoods, indexed by fishery.

catch_pred_fya

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

Value

A list containing:

pred

Matrix of predicted age composition proportions.

lp

Vector of negative log-likelihood contributions for each observation.