Compute Process Error Log-Likelihood for a Deviation Surface (Positive Scale)
Get_PE_loglik.RdCalculates the positive log-likelihood contribution for a surface of
deviations indexed by year and by some second dimension, under a variety of
temporal and spatiotemporal structures. Selectivity deviations use it over
years and bins, growth's semi-parametric deviations over years and ages, and
a time-varying growth parameter over years alone (a surface one column wide).
The argument names still read bin for that second dimension.
Usage
Get_PE_loglik(
PE_model,
PE_pars,
ln_devs,
map_sel_devs,
map_sel_devs_full,
min_sel_devs_shared_bins,
rw_init_sigma = 5
)Arguments
- PE_model
Integer specifying the process error structure:
1 = IID: deviations drawn independently as \(N(0, \sigma^2)\).
2 = Random walk: deviations follow a first-order random walk initialized with a diffuse prior (\(\sigma = 5\)) at
y = 1.3 = 3D GMRF with marginal variance parameterization.
4 = 3D GMRF with conditional variance parameterization.
5 = Separable 2D AR(1) across bins and years.
- PE_pars
Array of process error parameters dimensioned
[1, par_index, sex, 1]. Thepar_indexslot meaning depends onPE_model:Models 1-2:
[1,1,s,1]= log standard deviation (\(\log \sigma\)) for sexs, indexed by bin/age.Models 3-4:
[1,1,s,1]= unconstrained partial correlation by age/bin;[1,2,s,1]= unconstrained partial correlation by year;[1,3,s,1]= unconstrained partial correlation by cohort;[1,4,s,1]= log variance.Model 5:
[1,1,s,1]= unconstrained bin correlation (transformed via \(2/(1+e^{-2x})-1\));[1,2,s,1]= unconstrained year correlation;[1,4,s,1]= log standard deviation.
- ln_devs
Array of log-scale selectivity deviations dimensioned
[1, year, bin, sex, 1].- map_sel_devs
Integer array dimensioned
[fleet, year, bin, sex]mapping deviations to unique estimated parameters. Shared deviations hold the same integer value;NAentries are treated as fixed and excluded from likelihood evaluation.- map_sel_devs_full
The same map across every unit this penalty is evaluated over, that unit being the first dim: regions for selectivity, populations by region for growth. A deviation shared over those units is one parameter appearing in each of their slices, and this function runs one unit at a time, so its contribution is divided by the number holding it. Without the split, a series shared over
nunits is penalizedntimes, an implicit \(\sigma / \sqrt{n}\). A deviation that is not shared appears once, divides by one, and is unaffected.Integer vector. Indices of the reference (minimum) bin within each shared deviation group, used to subset the bin dimension when evaluating GMRF or 2D AR(1) likelihoods (PE models 3-5). When no bin sharing is specified, defaults to
1:n_bins(i.e., all bins are included).- rw_init_sigma
Standard deviation given to the first year of a random walk. A number (5 by default) leaves that year effectively unconstrained;
NAstarts the walk at zero under its own sigma instead.
Value
Numeric scalar: the positive log-likelihood contribution from selectivity process error. Negated externally to form the negative log-likelihood.
Details
The function supports:
IID process error
Random walk process error
3D Gaussian Markov Random Field (GMRF) models (marginal or conditional variance)
Separable 2D AR(1) models
Note: The returned value is on the positive log-likelihood scale. It must be negated to obtain a negative log-likelihood contribution, which is handled outside this function.