EpiNow2 Stan Functions
Parameter Handlers

Functions for parameter management. More...

Collaboration diagram for Parameter Handlers:

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)
 

Description

Functions for parameter management.

Functions from params.stan for accessing, manipulating, and applying priors to model parameters.

Function Documentation

◆ apply_prior_lp()

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.

Parameters
valueValue to apply the prior to (sampled parameter or derived quantity).
distPrior distribution type (0: lognormal, 1: gamma, 2: normal).
p1First distribution parameter.
p2Second distribution parameter.
lbLower bound of the parameter's support.
ubUpper bound of the parameter's support.

Definition at line 82 of file params.stan.

Referenced by init_priors_lp(), and params_lp().

Here is the caller graph for this function:

◆ get_param() [1/2]

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.

Parameters
idParameter ID
params_fixed_lookupArray of fixed parameter lookup indices
params_variable_lookupArray of variable parameter lookup indices
params_valueVector of fixed parameter values
paramsMatrix of variable parameter values (rows are samples)
Returns
A vector of parameter values across samples

Definition at line 52 of file params.stan.

◆ get_param() [2/2]

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.

Parameters
idParameter ID
params_fixed_lookupArray of fixed parameter lookup indices
params_variable_lookupArray of variable parameter lookup indices
params_valueVector of fixed parameter values
paramsVector of variable parameter values
Returns
The parameter value (scalar)

Definition at line 24 of file params.stan.

◆ init_priors_lp()

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).

Parameters
init_param_idsPer-prior id of the parameter the prior applies to.
init_distsPer-prior distribution code (0: lognormal, 1: gamma, 2: normal).
init_dist_paramsFlat ragged vector of distribution parameters, two per prior.
init_lowerPer-prior lower bound on the parameter's support.
init_upperPer-prior upper bound on the parameter's support.
param_id_R0Registered id of R0.
RReproduction-number trajectory.
R_meanSampled mean reproduction number over the centring window.

Definition at line 150 of file params.stan.

References apply_prior_lp().

Here is the call graph for this function:

◆ params_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.

Parameters
paramsVector of parameter values
prior_distArray of prior distribution types (0: lognormal, 1: gamma, 2: normal)
prior_dist_paramsVector of prior distribution parameters
params_lowerVector of lower bounds for parameters
params_upperVector of upper bounds for parameters

Definition at line 109 of file params.stan.

References apply_prior_lp().

Here is the call graph for this function: