Skip to contents

Function to format comp data and get OSA residuals from afscOSA (uses afscOSA and compresid as backend to get OSA residuals)

Usage

get_osa(obs_mat, exp_mat, N, years, fleet, bins, comp_type, bin_label)

Arguments

obs_mat

Matrix of observed values, which can have NAs - gets removed with years arge (dimensioned by region, year, age, sex, fleet)

exp_mat

Matrix of expceted values, which can have NAs - gets removed with years arg (dimensioned by region, year, age, sex, fleet)

N

Input or effective sample size. If aggregated (comp_type == 0), then a vector of n_years is provided. If split by region, split by sex (comp_type == 1), then provide a array dimensioned by n_regions x n_years x n_sexes. If joint by sex, by split by region (comp_type == 2), then provide a matrix of n_regions x n_years

years

Years we want to point to and filter to

fleet

Fleet we want to filter to

bins

Vector of age or length bins

comp_type

Composition type - whether this is aggregated == 0, split by region and sex == 1, split by region joint by sex = =2, and joint by region and sex == 3

bin_label

Bin label for whether these are ages or lengths

Value

OSA residuals

Examples

if (FALSE) { # \dontrun{
comp_props <- get_comp_prop(data = data, rep = rep, age_labels = 2:31, len_labels = seq(41, 99, 2), year_labels = 1960:2024)
osa_results <- get_osa(obs_mat = comp_props$Obs_FishAge_mat,
                      exp_mat = comp_props$Pred_FishAge_mat,
                      N = 20 * data$Wt_FishAgeComps[1,1,1],
                      years = 1999:2023,
                      fleet = 1,
                      bins = 2:31,
                      comp_type = 0,
                      bin_label = "Age")
} # }