split_catch_by_sex: Split catch weights by relative weight or counts sampled for...

View source: R/split-by-sex-maturity.R

split_catch_by_sexR Documentation

Split catch weights by relative weight or counts sampled for sex and/or maturity

Description

Split catch weights by relative weight or counts sampled for sex and/or maturity

Usage

split_catch_by_sex(
  survey_sets,
  fish,
  catch_variable = "catch_weight",
  split_by_sex = TRUE,
  split_by_maturity = TRUE,
  immatures_pooled = FALSE,
  survey = NULL,
  years = NULL,
  min_sample_number = 10,
  prioritize_time = NULL,
  cutoff_quantile = 0.9995,
  p_threshold = 0.5,
  use_median_ratio = FALSE,
  sample_id_re = TRUE,
  year_re = FALSE,
  split_by_weight = FALSE,
  custom_maturity_at = NULL,
  custom_length_thresholds = NULL,
  plot = FALSE
)

Arguments

survey_sets

Data from gfdata::get_survey_sets().

fish

Data from gfdata::get_survey_samples() or matching format where female are coded as sex = 2.

catch_variable

Which biomass variable will be split. Can be total weight or densities. Variable by this name will be saved indicating which was used.

split_by_sex

Should catch be split by sex?

split_by_maturity

Should catch be split by maturity?

immatures_pooled

If split by maturity, TRUE when immatures not to be split by sex.

survey

List of survey abbreviations. Default NULL includes all surveys in survey_sets. Sets without samples will use annual survey mean/median proportions. If no samples were collected, other surveys in that year may be used (see prioritize_time option) or the global proportion. Because of this, one should only run this function on data of one population and gear type at a time such that morphological relationships and selectivity are relatively consistent. If you want only survey and year combinations with sample data, filter for !is.na(median_prop_ann). All available samples will still be used to determine thresholds.

years

List of years. Default NULL includes all years.

min_sample_number

If fewer sets sampled than this threshold, or fewer fish sampled than 3x this value, the proportion for unsampled sets will be based on either all other years of the survey, or other surveys in the same year, depending on prioritize_time option choice.

prioritize_time

Default NULL chooses to apply the annual mean (or median if use_median_ratio = TRUE) when annual sample number for a survey are fewer than min_sample_number and the SD of observed proportions across all years within a survey is larger than across all samples within a year. TRUE forces this behaviour without comparing SDs. FALSE uses survey level mean/median whenever the annual sample number for that survey is less than the min_sample_number.

cutoff_quantile

Set max cutoff quantile for weight modelled from lengths.

p_threshold

Probability of maturity to split at. Default = 0.5. Alternatives are 0.05 or 0.95.

use_median_ratio

If TRUE, uses median proportion mature when catch too small to have biological samples collected. Default is FALSE, which uses mean proportion mature.

sample_id_re

If TRUE then the ogive model will include random intercepts for sample ID.

year_re

Option to have lengths at maturity vary by year.

split_by_weight

Default is FALSE, but will automatically be switched to TRUE for the standard biomass variable names (catch_weight, density_kgpm2, density_kgkm2).

custom_maturity_at

A numeric vector of two threshold codes to define maturity at with the first being for males and the second for females. Defaults to NULL, which brings in default values from maturity assignment dataframe included with this package. NA in either position will also retain the default.

custom_length_thresholds

Instead of estimating length at maturity, they can be provided as a vector of length 2, first being for males and the second for females. Defaults to NULL to estimate these lengths from maturity ogives.

plot

Logical for whether to produce plots.

Examples

## Not run: 
d_survey_sets <- gfdata::get_survey_sets("pacific cod")
d_survey_samples <- gfdata::get_survey_samples("pacific cod")

d_by_maturity <- split_catch_by_sex(
  d_survey_sets, d_survey_samples,
  survey = c("SYN HS", "SYN QCS"),
  years = NULL,
  plot = TRUE
)

## End(Not run)

seananderson/pbs-synopsis documentation built on April 4, 2024, 1:36 p.m.