|
Rceattle C++ template
The CEATTLE likelihood: src/TMB/ceattle.cpp and its headers
|
Go to the source code of this file.
Classes | |
| struct | LinkageTable< Type > |
| The linkage table: one entry per row, and the shared design matrix. More... | |
Functions | |
| void | rceattle_stratum_range (int id, int n_levels, int &lo, int &hi) |
| Expand a stratum id into the loop range [lo, hi). | |
| template<class Type> | |
| void | rceattle_apply_growth_linkages (array< Type > &growth_offset, int link_code, const LinkageTable< Type > <, int nspp, const vector< int > &nsex, int nyrs) |
| Add growth offsets to growth_offset[sp, sex, yr, param]. | |
| template<class Type> | |
| void | rceattle_apply_M_linkages (array< Type > &M_offset, int link_code, const LinkageTable< Type > <, int nspp, const vector< int > &nsex, const vector< int > &nages, int nyrs) |
| Add natural-mortality offsets to M_offset[sp, sex, age, yr]. | |
| template<class Type> | |
| void | rceattle_apply_recruitment_linkages (array< Type > &rec_offset, int link_code, const LinkageTable< Type > <, int nspp, int nyrs) |
| Add recruitment offsets to rec_offset[sp, param, yr]. | |
| template<class Type> | |
| void | rceattle_apply_q_linkages (matrix< Type > &q_offset, int link_code, const LinkageTable< Type > <, int n_flt, int nyrs) |
| Add catchability offsets to q_offset[fleet, yr]. | |
| template<class Type> | |
| void | rceattle_apply_sel_linkages (array< Type > &slp_offset, array< Type > &inf_offset, array< Type > &coff_offset, array< Type > &apical_offset, array< Type > &dn6_offset, int link_code, const LinkageTable< Type > <, int n_flt, int max_sex, int n_sel_bins, int nyrs) |
| Add selectivity offsets, by fleet, sex and year, to one of five arrays. | |
| vector< int > | rceattle_group_slots (const vector< int > &group_of_slot, int grp) |
| The random-effect slots of one group, in slot order, which is time order within a group (.assign_re_registry()). | |
| template<class Type> | |
| void | rceattle_re_group_nll (int structure, vector< Type > re, Type sigma, Type rho, Type &nll, Type &nll_unweighted) |
| Add the negative log density of one group's deviations to two accumulators. | |
| #define RCEATTLE_COMP_THETA_CAAL 1 |
Definition at line 70 of file linkage.hpp.
| #define RCEATTLE_COMP_THETA_COMP 0 |
Definition at line 69 of file linkage.hpp.
| #define RCEATTLE_COMP_THETA_DIET 2 |
Definition at line 71 of file linkage.hpp.
| #define RCEATTLE_LINK_EXPONENTIAL 3 |
Definition at line 45 of file linkage.hpp.
| #define RCEATTLE_LINK_IDENTITY 0 |
Definition at line 42 of file linkage.hpp.
| #define RCEATTLE_LINK_LOG 1 |
Definition at line 43 of file linkage.hpp.
| #define RCEATTLE_LINK_LOGIT 2 |
Definition at line 44 of file linkage.hpp.
| #define RCEATTLE_N_GROWTH_PARAMS 4 |
Definition at line 31 of file linkage.hpp.
Referenced by rceattle_apply_growth_linkages().
| #define RCEATTLE_N_REC_PARAMS 4 |
Definition at line 35 of file linkage.hpp.
Referenced by rceattle_apply_recruitment_linkages().
| #define RCEATTLE_PROC_COMP 5 |
Definition at line 27 of file linkage.hpp.
| #define RCEATTLE_PROC_GROWTH 2 |
Definition at line 24 of file linkage.hpp.
Referenced by rceattle_apply_growth_linkages().
| #define RCEATTLE_PROC_M 1 |
Definition at line 23 of file linkage.hpp.
Referenced by rceattle_apply_M_linkages().
| #define RCEATTLE_PROC_Q 3 |
Definition at line 25 of file linkage.hpp.
Referenced by rceattle_apply_q_linkages().
| #define RCEATTLE_PROC_RECRUIT 0 |
Definition at line 22 of file linkage.hpp.
Referenced by rceattle_apply_recruitment_linkages().
| #define RCEATTLE_PROC_SEL 4 |
Definition at line 26 of file linkage.hpp.
Referenced by rceattle_apply_sel_linkages().
| #define RCEATTLE_RE_AR1 2 |
Definition at line 51 of file linkage.hpp.
Referenced by rceattle_re_group_nll().
| #define RCEATTLE_RE_IID 0 |
Definition at line 49 of file linkage.hpp.
| #define RCEATTLE_RE_RW 1 |
Definition at line 50 of file linkage.hpp.
Referenced by rceattle_re_group_nll().
| #define RCEATTLE_REC_ALPHA 1 |
Definition at line 37 of file linkage.hpp.
| #define RCEATTLE_REC_BETA 2 |
Definition at line 38 of file linkage.hpp.
| #define RCEATTLE_REC_R0 0 |
Definition at line 36 of file linkage.hpp.
| #define RCEATTLE_REC_R_INIT 3 |
Definition at line 39 of file linkage.hpp.
| #define RCEATTLE_SEL_APICAL 5 |
Definition at line 60 of file linkage.hpp.
Referenced by rceattle_apply_sel_linkages().
| #define RCEATTLE_SEL_ASCEND_SE 8 |
Definition at line 63 of file linkage.hpp.
| #define RCEATTLE_SEL_COFF 4 |
Definition at line 59 of file linkage.hpp.
Referenced by rceattle_apply_sel_linkages().
| #define RCEATTLE_SEL_DESCEND_SE 9 |
Definition at line 64 of file linkage.hpp.
| #define RCEATTLE_SEL_DN_PEAK 6 |
Definition at line 61 of file linkage.hpp.
Referenced by rceattle_apply_sel_linkages().
| #define RCEATTLE_SEL_END_LOGIT 11 |
Definition at line 66 of file linkage.hpp.
Referenced by rceattle_apply_sel_linkages().
| #define RCEATTLE_SEL_INF_ASC 2 |
Definition at line 57 of file linkage.hpp.
Referenced by rceattle_apply_sel_linkages().
| #define RCEATTLE_SEL_INF_DESC 3 |
Definition at line 58 of file linkage.hpp.
Referenced by rceattle_apply_sel_linkages().
| #define RCEATTLE_SEL_SLP_ASC 0 |
Definition at line 55 of file linkage.hpp.
Referenced by rceattle_apply_sel_linkages().
| #define RCEATTLE_SEL_SLP_DESC 1 |
Definition at line 56 of file linkage.hpp.
Referenced by rceattle_apply_sel_linkages().
| #define RCEATTLE_SEL_START_LOGIT 10 |
Definition at line 65 of file linkage.hpp.
| #define RCEATTLE_SEL_TOP_LOGIT 7 |
Definition at line 62 of file linkage.hpp.
| void rceattle_apply_growth_linkages | ( | array< Type > & | growth_offset, |
| int | link_code, | ||
| const LinkageTable< Type > & | lt, | ||
| int | nspp, | ||
| const vector< int > & | nsex, | ||
| int | nyrs ) |
Add growth offsets to growth_offset[sp, sex, yr, param].
Growth is not age-specific, so the age-bin id is ignored. The SD codes (sd_L1 = 4, sd_Linf = 5) take intercept rows only and are skipped here.
| growth_offset | [in,out] Offsets [nspp, max_sex, nyrs, n_growth_params]. |
| link_code,lt | See the note above. |
Definition at line 136 of file linkage.hpp.
References LinkageTable< Type >::beta, LinkageTable< Type >::link, LinkageTable< Type >::param, LinkageTable< Type >::process, RCEATTLE_N_GROWTH_PARAMS, RCEATTLE_PROC_GROWTH, rceattle_stratum_range(), LinkageTable< Type >::sex, LinkageTable< Type >::species, LinkageTable< Type >::X, and LinkageTable< Type >::X_col.
| void rceattle_apply_M_linkages | ( | array< Type > & | M_offset, |
| int | link_code, | ||
| const LinkageTable< Type > & | lt, | ||
| int | nspp, | ||
| const vector< int > & | nsex, | ||
| const vector< int > & | nages, | ||
| int | nyrs ) |
Add natural-mortality offsets to M_offset[sp, sex, age, yr].
Age-specific, unlike growth. M1 (code 0) is the only parameter.
| M_offset | [in,out] Offsets [nspp, max_sex, max_age, nyrs]. |
| link_code,lt | See the note above. |
Definition at line 185 of file linkage.hpp.
References LinkageTable< Type >::age_bin, LinkageTable< Type >::beta, LinkageTable< Type >::link, LinkageTable< Type >::process, RCEATTLE_PROC_M, rceattle_stratum_range(), LinkageTable< Type >::sex, LinkageTable< Type >::species, LinkageTable< Type >::X, and LinkageTable< Type >::X_col.
| void rceattle_apply_q_linkages | ( | matrix< Type > & | q_offset, |
| int | link_code, | ||
| const LinkageTable< Type > & | lt, | ||
| int | n_flt, | ||
| int | nyrs ) |
Add catchability offsets to q_offset[fleet, yr].
By fleet, which already implies the species, so species, sex and age ids are ignored. q (code 0) is the only parameter.
| q_offset | [in,out] Offsets [n_flt, nyrs]. |
| link_code,lt | See the note above. |
Definition at line 280 of file linkage.hpp.
References LinkageTable< Type >::beta, LinkageTable< Type >::fleet, LinkageTable< Type >::link, LinkageTable< Type >::process, RCEATTLE_PROC_Q, rceattle_stratum_range(), LinkageTable< Type >::X, and LinkageTable< Type >::X_col.
| void rceattle_apply_recruitment_linkages | ( | array< Type > & | rec_offset, |
| int | link_code, | ||
| const LinkageTable< Type > & | lt, | ||
| int | nspp, | ||
| int | nyrs ) |
Add recruitment offsets to rec_offset[sp, param, yr].
Recruitment parameters are not sex- or age-specific (sex_ratio splits recruits later), so those ids are ignored. Parameters are RCEATTLE_REC_* (above).
| rec_offset | [in,out] Offsets [nspp, n_rec_params, nyrs]. |
| link_code,lt | See the note above. |
Definition at line 236 of file linkage.hpp.
References LinkageTable< Type >::beta, LinkageTable< Type >::link, LinkageTable< Type >::param, LinkageTable< Type >::process, RCEATTLE_N_REC_PARAMS, RCEATTLE_PROC_RECRUIT, rceattle_stratum_range(), LinkageTable< Type >::species, LinkageTable< Type >::X, and LinkageTable< Type >::X_col.
| void rceattle_apply_sel_linkages | ( | array< Type > & | slp_offset, |
| array< Type > & | inf_offset, | ||
| array< Type > & | coff_offset, | ||
| array< Type > & | apical_offset, | ||
| array< Type > & | dn6_offset, | ||
| int | link_code, | ||
| const LinkageTable< Type > & | lt, | ||
| int | n_flt, | ||
| int | max_sex, | ||
| int | n_sel_bins, | ||
| int | nyrs ) |
Add selectivity offsets, by fleet, sex and year, to one of five arrays.
Offsets are per fleet; fleets sharing a Selectivity_index still share one parameter block through the map. The param code (RCEATTLE_SEL_*, above) picks the array: slopes slp_offset, inflections inf_offset, non-parametric coefficients coff_offset (every bin), apical height apical_offset, and DoubleNormalSS3 P1-P6 (SS3 pattern 24) dn6_offset.
| slp_offset | [in,out] Slope offsets [2, n_flt, max_sex, nyrs]. |
| inf_offset | [in,out] Inflection offsets [2, n_flt, max_sex, nyrs]. |
| coff_offset | [in,out] Nonparametric offsets [n_flt, max_sex, n_sel_bins, nyrs]. |
| apical_offset | [in,out] Apical-height offsets [n_flt, max_sex, nyrs]. |
| dn6_offset | [in,out] DoubleNormalSS3 offsets [6, n_flt, max_sex, nyrs]. |
| link_code,lt | See the note above. |
Definition at line 328 of file linkage.hpp.
References LinkageTable< Type >::beta, LinkageTable< Type >::fleet, LinkageTable< Type >::link, LinkageTable< Type >::param, LinkageTable< Type >::process, RCEATTLE_PROC_SEL, RCEATTLE_SEL_APICAL, RCEATTLE_SEL_COFF, RCEATTLE_SEL_DN_PEAK, RCEATTLE_SEL_END_LOGIT, RCEATTLE_SEL_INF_ASC, RCEATTLE_SEL_INF_DESC, RCEATTLE_SEL_SLP_ASC, RCEATTLE_SEL_SLP_DESC, rceattle_stratum_range(), LinkageTable< Type >::sex, LinkageTable< Type >::X, and LinkageTable< Type >::X_col.
|
inline |
The random-effect slots of one group, in slot order, which is time order within a group (.assign_re_registry()).
| group_of_slot | Each slot's group (ceattle.cpp's linkage_re_sigma: an index, not an sd). |
| grp | The group. |
Definition at line 389 of file linkage.hpp.
| void rceattle_re_group_nll | ( | int | structure, |
| vector< Type > | re, | ||
| Type | sigma, | ||
| Type | rho, | ||
| Type & | nll, | ||
| Type & | nll_unweighted ) |
Add the negative log density of one group's deviations to two accumulators.
RCEATTLE_RE_IID: sd sigma. RCEATTLE_RE_RW: sd sigma on first differences (the first deviation has no term of its own; build_map() holds it at its start, 0 by default, so the base parameter carries the level). RCEATTLE_RE_AR1: stationary, MARGINAL sd sigma and correlation rho (the glmmTMB / Rogers QAR1 convention).
| structure | RCEATTLE_RE_IID, RCEATTLE_RE_RW or RCEATTLE_RE_AR1. |
| re | The group's deviations, in time order. |
| sigma | The group's sd, natural scale (AR1: the marginal sd). |
| rho | The AR1 correlation in (-1, 1); read only under RCEATTLE_RE_AR1. |
| nll,nll_unweighted | Cells of jnll_comp and unweighted_jnll_comp to add to. |
Definition at line 414 of file linkage.hpp.
References RCEATTLE_RE_AR1, and RCEATTLE_RE_RW.
|
inline |
Expand a stratum id into the loop range [lo, hi).
Clamped to n_levels, so an id past the last level gives an empty range.
| id | 1-based stratum id, or 0 for "all levels". |
| n_levels | Number of levels the caller loops over. |
| lo,hi | [out] First level, and one past the last level. |
Definition at line 82 of file linkage.hpp.
Referenced by rceattle_apply_growth_linkages(), rceattle_apply_M_linkages(), rceattle_apply_q_linkages(), rceattle_apply_recruitment_linkages(), and rceattle_apply_sel_linkages().