get_age_props: Calculate the weighted age proportions for the input data

Description Usage Arguments Details Value

Description

Calculate the weighted age proportions for the input data

Usage

1
2
3
4
5
6
7
8
9
get_age_props(
  d = readRDS(here("data", sample_data_raw_file)),
  min_date = as.Date("1972-01-01"),
  plus_grp = 15,
  lw_cutoff = 10,
  lw_tol = 0.1,
  lw_maxiter = 1000,
  by_month = FALSE
)

Arguments

d

Dataframe as extracted by fetch_sample_data()

min_date

Earliest date to include

plus_grp

Age plus group for maximum grouping

lw_cutoff

How many length-weight records are required to estimate a length/weight model

lw_tol

See fit_lw()

lw_maxiter

See fit_lw()

by_month

Logical. If TRUE the return dataframe with have a month column

Details

Each record will have an lw_alpha and lw_beta assigned to it. To get these: Estimate them for sample_ids with enough (lw_cutoff) length samples in them. Next, group the data by year and coalesce those into the same columns. To fill in the remaining ones, use an overall (all years) estimate (local variable all_yrs_lw). At this point, the lw_alpha and lw_beta columns will be fully populated for every specimen (no NAs). Hake sampling for length has been very good, so specimen weights are calculated using the length/weight parameters estimated for each specimen (for records in which weights haven't been recorded as data).

Calculate missing sample weights, by summing individual specimen weights in each sample They are divided by 1,000 because the specimen samples are in grams and sample weights in kilograms. If there is no catch weight for a sample, both catch_weight and sample_weight are set to 1 so that the ratio multiplied later for weighting is 1 and raw proportions are used instead for these samples.

Counts of ages by sample_id are made, and missing ages are filled in using tidyr::complete(). Missing year, sample_weight, and catch_weight for cases added with tidyr::complete() are added. Numbers-at-age are weighted by catch_weight / sample_weight. Numbers for each year and age are summed. Weighted proportions by year and age are produced.

Value

Age proportion dataframe with ages as columns and years as rows


pbs-assess/hakedata documentation built on Jan. 16, 2021, 9:15 p.m.