update_ss3_maturity: Update maturity in an SS3 weight-at-age matrix

View source: R/utils-update-ss3-maturity.R

update_ss3_maturityR Documentation

Update maturity in an SS3 weight-at-age matrix

Description

Update maturity in an SS3 weight-at-age matrix

Usage

update_ss3_maturity(
  maturity,
  weight_at_age,
  ages = 0:15,
  weight_at_age_fleet = 0
)

Arguments

maturity

A data frame of maturity at age. The data frame must have at least three columns, age, year, and p_mature but it can also have model though this column will be removed as well as any other column not included in the needed three. These column names align with what is present in maturity_estimates_df, a data frame of maturity estimates by model, but information from only one model can be passed in a function call. See the example.

weight_at_age

A data frame of weight-at-age values as returned from r4ss::SS_readwtatage() or r4ss::SS_read()[["wtatage"]].

ages

An integer vector specifying which ages must be present. All missing combinations of ages and year will be filled in with a probability of being mature of 0.0. This is helpful when there are no values for age-0 fish in the data frame for a given year.

weight_at_age_fleet

An integer specifying which fleet you want to take the weight-at-age information from. The default is 0, which is the beginning of the year population-level weight-at-age data.

Details

Update the maturity information (i.e., fleet == -2) in a matrix of weight-at-age data read in using r4ss::SS_readwtatage(). Information for the fleets other than fleet -2 will not be altered. The information from fleet 0 (i.e., beginning of the season population weight-at-age) is used to create the fecundity information. This can be changed by altering the default value for the weight_at_age_fleet argument.

The input data frame for maturity need not contain all years available in weight_at_age. The last year available will be the last year before a five-year average is taken for the forecast years. The remaining missing years will be filled in using a global average of the available data. Typically, all fleets other than fleet -2 have the same information but in case they do not, then the population information seems to be the best to create fecundity.

Value

A data frame with the same format as the input data frame for weight_at_age is returned, and thus, the returned object can be passed to r4ss::SS_writewtatage().

Author(s)

Kelli F. Johnson

Examples

## Not run: 
# The following example does not actually work because the path to the
# weight-at-age file does not exist.
update_ss3_maturity(
  maturity = maturity_estimates_df |>
    dplyr::filter(model == "Null"),
  weight_at_age = r4ss::SS_readwtatage("wtatage.ss")
)

## End(Not run)

pacific-hake/hake-assessment documentation built on Jan. 14, 2025, 9:12 p.m.