![]() |
EpiNow2 Stan Functions
|
Functions for parameter management. More...

Functions | |
| real | get_param (int id, array[] int params_fixed_lookup, array[] int params_variable_lookup, vector params_value, vector params) |
| vector | get_param (int id, array[] int params_fixed_lookup, array[] int params_variable_lookup, vector params_value, matrix params) |
| void | apply_prior_lp (real value, int dist, real p1, real p2, real lb, real ub) |
| void | params_lp (vector params, array[] int prior_dist, vector prior_dist_params, vector params_lower, vector params_upper) |
| void | init_priors_lp (array[] int init_param_ids, array[] int init_dists, vector init_dist_params, vector init_lower, vector init_upper, int param_id_R0, vector R, array[] real R_mean) |
Functions for parameter management.
Functions from params.stan for accessing, manipulating, and applying priors to model parameters.
| void apply_prior_lp | ( | real | value, |
| int | dist, | ||
| real | p1, | ||
| real | p2, | ||
| real | lb, | ||
| real | ub ) |
Apply a truncated prior to a value
Adds the log density of the chosen distribution, truncated to [lb, ub], to the target.
| value | Value to apply the prior to (sampled parameter or derived quantity). |
| dist | Prior distribution type (0: lognormal, 1: gamma, 2: normal). |
| p1 | First distribution parameter. |
| p2 | Second distribution parameter. |
| lb | Lower bound of the parameter's support. |
| ub | Upper bound of the parameter's support. |
Definition at line 82 of file params.stan.
Referenced by init_priors_lp(), and params_lp().

| vector get_param | ( | int | id, |
| array[]int | params_fixed_lookup, | ||
| array[]int | params_variable_lookup, | ||
| vector | params_value, | ||
| matrix | params ) |
Get a parameter value from either fixed or variable parameters (matrix version)
This function is an overloaded version of get_param that works with a matrix of parameter values, returning a vector of parameter values for multiple samples.
| id | Parameter ID |
| params_fixed_lookup | Array of fixed parameter lookup indices |
| params_variable_lookup | Array of variable parameter lookup indices |
| params_value | Vector of fixed parameter values |
| params | Matrix of variable parameter values (rows are samples) |
Definition at line 52 of file params.stan.
| real get_param | ( | int | id, |
| array[]int | params_fixed_lookup, | ||
| array[]int | params_variable_lookup, | ||
| vector | params_value, | ||
| vector | params ) |
Parameter Handlers
This group of functions handles parameter access, retrieval, and prior specification in the model. Parameters can be either fixed (specified in advance) or variable (estimated during inference). Get a parameter value from either fixed or variable parameters
This function retrieves a parameter value based on its ID, checking first if it's a fixed parameter and then if it's a variable parameter.
| id | Parameter ID |
| params_fixed_lookup | Array of fixed parameter lookup indices |
| params_variable_lookup | Array of variable parameter lookup indices |
| params_value | Vector of fixed parameter values |
| params | Vector of variable parameter values |
Definition at line 24 of file params.stan.
| void init_priors_lp | ( | array[]int | init_param_ids, |
| array[]int | init_dists, | ||
| vector | init_dist_params, | ||
| vector | init_lower, | ||
| vector | init_upper, | ||
| int | param_id_R0, | ||
| vector | R, | ||
| array[]real | R_mean ) |
Apply user priors on the initial values of centred-GP-wrapped trajectories
For each registered init prior, dispatches on the parameter id to the corresponding derived initial value and to the parameter actually sampled, then applies the user's truncated prior via apply_prior_lp.
The prior is declared on a derived value (e.g. R[1]) while the sampler moves on a different parameter (e.g. R_mean), whose <lower = 0> transform already contributes log(sampled_value) to the target. The Jacobian of the sampled-to-derived map is therefore taken relative to the sampled value, log(init_value) - log(sampled_value).
| init_param_ids | Per-prior id of the parameter the prior applies to. |
| init_dists | Per-prior distribution code (0: lognormal, 1: gamma, 2: normal). |
| init_dist_params | Flat ragged vector of distribution parameters, two per prior. |
| init_lower | Per-prior lower bound on the parameter's support. |
| init_upper | Per-prior upper bound on the parameter's support. |
| param_id_R0 | Registered id of R0. |
| R | Reproduction-number trajectory. |
| R_mean | Sampled mean reproduction number over the centring window. |
Definition at line 150 of file params.stan.
References apply_prior_lp().

| void params_lp | ( | vector | params, |
| array[]int | prior_dist, | ||
| vector | prior_dist_params, | ||
| vector | params_lower, | ||
| vector | params_upper ) |
Update log density for parameter priors
Adds the log density contributions from parameter priors to the target.
| params | Vector of parameter values |
| prior_dist | Array of prior distribution types (0: lognormal, 1: gamma, 2: normal) |
| prior_dist_params | Vector of prior distribution parameters |
| params_lower | Vector of lower bounds for parameters |
| params_upper | Vector of upper bounds for parameters |
Definition at line 109 of file params.stan.
References apply_prior_lp().
