Compute OSA residuals for composition data
get_osa.Rd
Formats observed and expected composition data and calculates one-step-ahead (OSA) residuals using multinomial, Dirichlet-multinomial, or logistic-normal likelihoods. This function is the main interface for residual diagnostics, internally calling [run_osa()] to perform the residual calculations.
Usage
get_osa(
obs_mat,
exp_mat,
N = NULL,
DM_theta = NULL,
LN_Sigma = NULL,
years,
fleet,
bins,
comp_type,
bin_label,
comp_like = 0
)
Arguments
- obs_mat
Array of observed compositions, dimensioned by
[region, year, bin, sex, fleet]
. May containNA
s, which are removed when filtering byyears
.- exp_mat
Array of expected compositions, dimensioned the same as
obs_mat
. May containNA
s, which are removed when filtering byyears
.- N
Input (or effective if Multinomial) sample size. Dimensions depend on
comp_type
:comp_type = 0
(aggregated): vector of lengthn_years
.comp_type = 1
(split by region and sex): array[n_regions, n_years, n_sexes]
.comp_type = 2
(split by region, joint by sex): matrix[n_regions, n_years]
.
- DM_theta
Dirichlet-multinomial overdispersion parameter(s). Dimensions must match
N
:aggregated: scalar
split by sex: matrix
[n_regions, n_sexes]
joint by sex: vector of length
n_regions
- LN_Sigma
Logistic-normal covariance matrix. Dimensions depend on
comp_type
:aggregated: matrix
[n_bins, n_bins]
split by region and sex: array
[n_regions, n_bins, n_bins, n_sexes]
joint by sex: array
[n_regions, n_bins, n_bins]
Use [get_logistN_Sigma()] to help construct this input.
- years
Vector of years to filter to. Must match dimensions of
obs_mat
andexp_mat
.- fleet
Fleet identifier (character or numeric) to filter to.
- bins
Vector of age or length bin labels corresponding to the composition categories.
- comp_type
Integer specifying how compositions are structured:
0 = aggregated across regions and sexes
1 = split by region and sex
2 = split by region, joint by sex
- bin_label
Character label describing whether bins represent ages or lengths.
- comp_like
Integer specifying the likelihood type (defaults to 0):
0 = multinomial
1 = Dirichlet-multinomial
2–4 = logistic-normal variants
Value
A list with one element:
- res
Data frame of OSA residuals. Columns include:
fleet
,index_label
,year
,index
,resid
,region
,sex
, andcomp_type
.
See also
Other Model Diagnostics:
do_jitter()
,
do_likelihood_profile()
,
do_retrospective()
,
do_runs_test()
,
get_catch_fits_plot()
,
get_comp_prop()
,
get_idx_fits()
,
get_idx_fits_plot()
,
get_model_rep_from_mcmc()
,
get_nLL_plot()
,
get_retrospective_plot()
,
get_retrospective_relative_difference()
,
plot_resids()