Skip to contents

Computes likelihood for observed length compositions using age-length keys (ALKs).

Usage

get_length_like(
  lf_switch = 1,
  removal_switch_f,
  lf_year,
  lf_season,
  lf_fishery,
  lf_minbin,
  lf_obs,
  lf_n,
  par_log_lf_alpha,
  catch_pred_fya,
  alk_ysal
)

Arguments

lf_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.

lf_year

A vector of year indices for each length composition observation.

lf_season

A vector of season indices for each length composition observation.

lf_fishery

A vector of fishery indices for each length composition observation.

lf_minbin

A vector of minimum length bins to aggregate, indexed by fishery.

lf_obs

A matrix of observed length composition proportions with rows as observations and columns as length bins.

lf_n

A vector of effective sample sizes for each observation.

par_log_lf_alpha

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

catch_pred_fya

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

alk_ysal

A 4D array of age-length keys with dimensions year by season by age by length bin.

Value

A list containing:

pred

Matrix of predicted length composition proportions.

lp

Vector of negative log-likelihood contributions for each observation.