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)
 

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 )

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, applies the user's truncated prior via apply_prior_lp, and adds the natural-to-log Jacobian (the shift from sampled log-mean to derived log initial value contributes nothing, as its Jacobian determinant is one).

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.

Definition at line 145 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: