|
Rceattle C++ template
The CEATTLE likelihood: src/TMB/ceattle.cpp and its headers
|
Go to the source code of this file.
Functions | |
| template<class Type> | |
| Type | length_sd_at_age (Type current_age, Type age_L1, bool plus_group, int sd_style, int sd_form, Type l1, Type linf, Type len, Type log_sd0, Type log_sd1) |
| SD of length-at-age (cm) for one age, year and sex. | |
| template<class Type> | |
| void | fill_age_length_key (int wtind, int sp, int sex, int age, int yr, Type mu, Type sd, const vector< int > &nlengths_pop, matrix< Type > &lengths_pop, matrix< Type > &weight_length_pars, const vector< int > &mat_len_use, matrix< Type > &mat_len_pars, array< Type > &growth_matrix, array< Type > &weight_hat, array< Type > &mat_weight_hat) |
| Age-length key, weight-at-age and mature weight-at-age for one cell. | |
| template<class Type> | |
| void | estimate_growth (int wtind, int sp, int nspp, int nyrs, const vector< int > &nsex, const vector< int > &nages, const vector< int > &nlengths, const vector< int > &minage, const vector< Type > &growth_age_L1, const vector< int > &growth_model, const vector< int > &growth_sd_style, const vector< int > &growth_sd_form, const vector< int > &growth_plus_length, const vector< Type > &plus_group_decay, matrix< Type > &lengths, const vector< int > &nlengths_pop, matrix< Type > &lengths_pop, array< Type > &growth_parameters, array< Type > &growth_log_sd, matrix< Type > &weight_length_pars, const vector< int > &mat_len_use, matrix< Type > &mat_len_pars, array< Type > &log_M1, array< Type > &length_hat, array< Type > &growth_matrix, array< Type > &weight_hat, array< Type > &mat_weight_hat) |
| Jan-1 (month 0) mean length, age-length key and weight-at-age for one species. | |
| template<class Type> | |
| void | estimate_growth_within_yr (int wtind, int id_pop, int sp, Type fracyr, int nspp, int nyrs, const vector< int > &nsex, const vector< int > &nages, const vector< int > &nlengths, const vector< int > &minage, const vector< Type > &growth_age_L1, const vector< int > &growth_model, const vector< int > &growth_sd_style, const vector< int > &growth_sd_form, const vector< int > &growth_plus_length, matrix< Type > &lengths, const vector< int > &nlengths_pop, matrix< Type > &lengths_pop, array< Type > &growth_parameters, array< Type > &growth_log_sd, matrix< Type > &weight_length_pars, const vector< int > &mat_len_use, matrix< Type > &mat_len_pars, array< Type > &length_hat, array< Type > &growth_matrix, array< Type > &weight_hat, array< Type > &mat_weight_hat) |
| Mean length-at-age, age-length key and weight-at-age fracyr into the year. | |
| template<class Type> | |
| void | calculate_weight (array< Type > &weight_hat, array< Type > &length_hat, array< Type > &growth_matrix, array< Type > &mat_weight_hat, array< Type > &weight_obs, const vector< int > &growth_model, const vector< int > &growth_sd_style, const vector< int > &growth_sd_form, const vector< int > &growth_plus_length, const vector< Type > &plus_group_decay, const int &nspp, const int &nyrs, const int &nyrs_hind, const int &n_flt, const vector< int > &flt_spp, vector< Type > flt_month, const vector< int > &nsex, const vector< int > &minage, const vector< Type > &growth_age_L1, const vector< int > &nages, const vector< int > &nlengths, const vector< int > &pop_wt_index, const vector< int > &ssb_wt_index, const vector< int > &flt_wt_index, vector< Type > spawn_month, matrix< Type > &lengths, const vector< int > &nlengths_pop, matrix< Type > &lengths_pop, array< Type > &growth_parameters, array< Type > &growth_log_sd, matrix< Type > weight_length_pars, const vector< int > &mat_len_use, matrix< Type > &mat_len_pars, array< Type > &log_M1) |
| Population, SSB and fleet weight-at-age (kg) for every species and fleet. | |
| void calculate_weight | ( | array< Type > & | weight_hat, |
| array< Type > & | length_hat, | ||
| array< Type > & | growth_matrix, | ||
| array< Type > & | mat_weight_hat, | ||
| array< Type > & | weight_obs, | ||
| const vector< int > & | growth_model, | ||
| const vector< int > & | growth_sd_style, | ||
| const vector< int > & | growth_sd_form, | ||
| const vector< int > & | growth_plus_length, | ||
| const vector< Type > & | plus_group_decay, | ||
| const int & | nspp, | ||
| const int & | nyrs, | ||
| const int & | nyrs_hind, | ||
| const int & | n_flt, | ||
| const vector< int > & | flt_spp, | ||
| vector< Type > | flt_month, | ||
| const vector< int > & | nsex, | ||
| const vector< int > & | minage, | ||
| const vector< Type > & | growth_age_L1, | ||
| const vector< int > & | nages, | ||
| const vector< int > & | nlengths, | ||
| const vector< int > & | pop_wt_index, | ||
| const vector< int > & | ssb_wt_index, | ||
| const vector< int > & | flt_wt_index, | ||
| vector< Type > | spawn_month, | ||
| matrix< Type > & | lengths, | ||
| const vector< int > & | nlengths_pop, | ||
| matrix< Type > & | lengths_pop, | ||
| array< Type > & | growth_parameters, | ||
| array< Type > & | growth_log_sd, | ||
| matrix< Type > | weight_length_pars, | ||
| const vector< int > & | mat_len_use, | ||
| matrix< Type > & | mat_len_pars, | ||
| array< Type > & | log_M1 ) |
Population, SSB and fleet weight-at-age (kg) for every species and fleet.
Empirical weight-at-age (growth_model == 0) is read straight from weight_obs, each projection year carrying the last hindcast year forward. Under estimated growth (growth_model > 0) population weight comes from estimate_growth() at Jan-1, and SSB and fleet weight from estimate_growth_within_yr() at the spawning month and at each fleet's own month. Arguments not listed below pass through to those two, except n_flt, which this function's own fleet loop consumes.
| weight_hat | [ref] weight-at-age (wt_index, sex, age, year), kg |
| length_hat | [ref] mean length-at-age (cm) |
| growth_matrix | [ref] age-length key on the population length bins |
| mat_weight_hat | [ref] mature weight-at-age (kg), maturity-at-length species only |
| weight_obs | Empirical weight-at-age input (wt_index, sex, age, year), kg |
| growth_model | Per species, 0 = empirical, 1 = von Bertalanffy, 2 = Richards |
| nyrs | Years, hindcast plus projection. |
| nyrs_hind | Years in the hindcast. |
| flt_spp | Species index of each fleet |
| flt_month | Fleet observation month (0 = not specified); flt_month/12 of a year |
| pop_wt_index | Weight-at-age input index for population biomass |
| ssb_wt_index | Weight-at-age input index for spawning-stock biomass |
| flt_wt_index | Weight-at-age input index per fleet |
| spawn_month | Spawning month per species; spawn_month/12 of a year (0 = Jan-1) |
Definition at line 498 of file growth.hpp.
References estimate_growth(), and estimate_growth_within_yr().
| void estimate_growth | ( | int | wtind, |
| int | sp, | ||
| int | nspp, | ||
| int | nyrs, | ||
| const vector< int > & | nsex, | ||
| const vector< int > & | nages, | ||
| const vector< int > & | nlengths, | ||
| const vector< int > & | minage, | ||
| const vector< Type > & | growth_age_L1, | ||
| const vector< int > & | growth_model, | ||
| const vector< int > & | growth_sd_style, | ||
| const vector< int > & | growth_sd_form, | ||
| const vector< int > & | growth_plus_length, | ||
| const vector< Type > & | plus_group_decay, | ||
| matrix< Type > & | lengths, | ||
| const vector< int > & | nlengths_pop, | ||
| matrix< Type > & | lengths_pop, | ||
| array< Type > & | growth_parameters, | ||
| array< Type > & | growth_log_sd, | ||
| matrix< Type > & | weight_length_pars, | ||
| const vector< int > & | mat_len_use, | ||
| matrix< Type > & | mat_len_pars, | ||
| array< Type > & | log_M1, | ||
| array< Type > & | length_hat, | ||
| array< Type > & | growth_matrix, | ||
| array< Type > & | weight_hat, | ||
| array< Type > & | mat_weight_hat ) |
Jan-1 (month 0) mean length, age-length key and weight-at-age for one species.
Mean length-at-age (cm) is anchored at \(L(a_{L1}) = l_1\):
Weight-at-age (kg) is integrated across the length distribution rather than taken at mean length, which Jensen's inequality would bias: \(W_a = \sum_{ln} P(ln | a) \cdot \alpha \cdot L_{mid}^{\beta}\).
| wtind | Weight index slot to write into. |
| sp | Species index. |
| minage | Minimum modelled age per species; 0 is supported. |
| growth_model | Per species, 1 = von Bertalanffy, 2 = Richards. |
| growth_parameters | Time-varying growth parameters by species, sex, year and parameter: K (per year), L1 and Linf (cm), Richards m. |
| growth_log_sd | Log-scale variability endpoints: index 0 at L1, index 1 at Linf. |
| weight_length_pars | Allometric \(\alpha\) and \(\beta\), kg from cm. |
| length_hat | [Output] mean length-at-age (cm). |
| growth_matrix | [Output] age-length key on the population length bins. |
| weight_hat | [Output] integrated weight-at-age (kg). |
Definition at line 129 of file growth.hpp.
References fill_age_length_key(), and length_sd_at_age().
Referenced by calculate_weight().
| void estimate_growth_within_yr | ( | int | wtind, |
| int | id_pop, | ||
| int | sp, | ||
| Type | fracyr, | ||
| int | nspp, | ||
| int | nyrs, | ||
| const vector< int > & | nsex, | ||
| const vector< int > & | nages, | ||
| const vector< int > & | nlengths, | ||
| const vector< int > & | minage, | ||
| const vector< Type > & | growth_age_L1, | ||
| const vector< int > & | growth_model, | ||
| const vector< int > & | growth_sd_style, | ||
| const vector< int > & | growth_sd_form, | ||
| const vector< int > & | growth_plus_length, | ||
| matrix< Type > & | lengths, | ||
| const vector< int > & | nlengths_pop, | ||
| matrix< Type > & | lengths_pop, | ||
| array< Type > & | growth_parameters, | ||
| array< Type > & | growth_log_sd, | ||
| matrix< Type > & | weight_length_pars, | ||
| const vector< int > & | mat_len_use, | ||
| matrix< Type > & | mat_len_pars, | ||
| array< Type > & | length_hat, | ||
| array< Type > & | growth_matrix, | ||
| array< Type > & | weight_hat, | ||
| array< Type > & | mat_weight_hat ) |
Mean length-at-age, age-length key and weight-at-age fracyr into the year.
Advances the Jan-1 mean length stored at id_pop by fracyr of growth, for SSB weight-at-age at the spawning month and each fleet's weight-at-age at its own month:
Under growth_plus_length == 1 the plus group keeps the Jan-1 mean length estimate_growth() set for it; under the SS3 forms (2-4) it grows within the year like every other age, as SS3 does.
Weight-at-age (kg) is integrated over the length distribution as in estimate_growth().
| wtind | Weight index slot to write into. |
| id_pop | Weight index holding the Jan-1 lengths the advance starts from. |
| sp | Species index. |
| fracyr | Fraction of the year (0.0 - 1.0) to advance growth by. |
| growth_parameters,growth_log_sd,weight_length_pars | As in estimate_growth(). |
| length_hat,growth_matrix,weight_hat | [Output] As in estimate_growth(). |
Definition at line 338 of file growth.hpp.
References fill_age_length_key(), and length_sd_at_age().
Referenced by calculate_weight().
| void fill_age_length_key | ( | int | wtind, |
| int | sp, | ||
| int | sex, | ||
| int | age, | ||
| int | yr, | ||
| Type | mu, | ||
| Type | sd, | ||
| const vector< int > & | nlengths_pop, | ||
| matrix< Type > & | lengths_pop, | ||
| matrix< Type > & | weight_length_pars, | ||
| const vector< int > & | mat_len_use, | ||
| matrix< Type > & | mat_len_pars, | ||
| array< Type > & | growth_matrix, | ||
| array< Type > & | weight_hat, | ||
| array< Type > & | mat_weight_hat ) |
Age-length key, weight-at-age and mature weight-at-age for one cell.
Length is normal with mean mu and SD sd (cm) on the population length bins lengths_pop (lower edges): the first bin is a minus group, the last a plus group (SS3's convention).
Weight-at-age is \(\sum_l P(l|a) \alpha L_{mid}^\beta\) at population-bin midpoints (kg). With maturity-at-length, mature weight-at-age is the same sum with the logistic maturity \(1/(1+e^{-s(L_{mid} - L_{50})})\) inside: SS3's fecundity-at-age when fecundity equals body weight.
Definition at line 45 of file growth.hpp.
Referenced by estimate_growth(), and estimate_growth_within_yr().
| Type length_sd_at_age | ( | Type | current_age, |
| Type | age_L1, | ||
| bool | plus_group, | ||
| int | sd_style, | ||
| int | sd_form, | ||
| Type | l1, | ||
| Type | linf, | ||
| Type | len, | ||
| Type | log_sd0, | ||
| Type | log_sd1 ) |
SD of length-at-age (cm) for one age, year and sex.
The variability term v is \(e^{sd_0}\) at or below age_L1, pinned to \(e^{sd_1}\) for the plus group under sd_style == 1 (WHAM; also SS3 with Growth_Age_for_L2 = 999), and otherwise interpolated linearly in length between \((l_1, e^{sd_0})\) and \((L_\infty, e^{sd_1})\). sd_form 1 makes v an SD in cm (SS3 CV_Growth_Pattern 2), 2 a CV, so SD = v * L (SS3 CV_Growth_Pattern 0).
Definition at line 14 of file growth.hpp.
Referenced by estimate_growth(), and estimate_growth_within_yr().