![]() |
EpiNow2 Stan Functions
|
Functions for delay distribution handling. More...

Functions | |
| array[] int | get_delay_type_max (int delay_types, array[] int delay_types_p, array[] int delay_types_id, array[] int delay_types_groups, array[] int delay_max, array[] int delay_np_pmf_groups) |
| vector | get_delay_rev_pmf (int delay_id, int len, array[] int delay_types_p, array[] int delay_types_id, array[] int delay_types_groups, array[] int delay_max, vector delay_np_pmf, array[] int delay_np_pmf_groups, vector delay_params, array[] int delay_params_groups, array[] int delay_dist, int left_truncate, int reverse_pmf, int cumulative) |
| void | delays_lp (vector delay_params, vector delay_params_mean, vector delay_params_sd, array[] int delay_params_groups, array[] int delay_dist, array[] int weight) |
| void | delays_np_lp (vector delay_np_est_raw, vector delay_np_est_alpha) |
| vector | combine_np_pmf (vector delay_np_pmf, int delay_n_np_est, array[] int delay_np_est_groups, array[] int delay_np_est_pos, vector delay_np_est_raw) |
| vector | normal_lb_rng (vector mu, vector sigma, vector lb) |
Functions for delay distribution handling.
Functions from delays.stan for creating, parameterizing and applying delay distributions.
| vector combine_np_pmf | ( | vector | delay_np_pmf, |
| int | delay_n_np_est, | ||
| array[]int | delay_np_est_groups, | ||
| array[]int | delay_np_est_pos, | ||
| vector | delay_np_est_raw ) |
Combine fixed and estimated nonparametric delay PMFs
Returns a copy of the fixed PMF vector with the estimated entries overwritten by per-segment normalisation of the raw gamma values. Fixed entries and structural zeros are left unchanged.
| delay_np_pmf | Fixed PMF vector (concatenated ragged array). |
| delay_n_np_est | Number of estimated nonparametric delays. |
| delay_np_est_groups | Ragged-array boundaries into delay_np_est_raw (length delay_n_np_est + 1). |
| delay_np_est_pos | For each estimated element, its position within delay_np_pmf. |
| delay_np_est_raw | Raw gamma values backing each segment. |
Definition at line 206 of file delays.stan.
| void delays_lp | ( | vector | delay_params, |
| vector | delay_params_mean, | ||
| vector | delay_params_sd, | ||
| array[]int | delay_params_groups, | ||
| array[]int | delay_dist, | ||
| array[]int | weight ) |
Update log density for delay distribution priors
| delay_params | Vector of parameters for parametric delay distributions |
| delay_params_mean | Vector of prior means for delay parameters |
| delay_params_sd | Vector of prior standard deviations for delay parameters |
| delay_params_groups | Array of indices for accessing delay parameters |
| delay_dist | Array of distribution types using primarycensored convention (1: lognormal, 2: gamma, 3: weibull, 4: exponential) |
| weight | Array of weights for each delay distribution in the log density |
Definition at line 138 of file delays.stan.
| void delays_np_lp | ( | vector | delay_np_est_raw, |
| vector | delay_np_est_alpha ) |
Update log prior density for estimated nonparametric delays
Applies Gamma(alpha, 1) priors to the raw vector that backs the estimated nonparametric PMFs. Once normalised within each ragged segment, this induces a Dirichlet(alpha) prior on the segment. See https://mc-stan.org/docs/stan-users-guide/simplexes.html for the gamma-normalisation construction.
| delay_np_est_raw | Raw gamma-distributed values backing each estimated nonparametric PMF segment. |
| delay_np_est_alpha | Dirichlet concentration parameters, matched element-wise to delay_np_est_raw. |
Definition at line 180 of file delays.stan.
| vector get_delay_rev_pmf | ( | int | delay_id, |
| int | len, | ||
| array[]int | delay_types_p, | ||
| array[]int | delay_types_id, | ||
| array[]int | delay_types_groups, | ||
| array[]int | delay_max, | ||
| vector | delay_np_pmf, | ||
| array[]int | delay_np_pmf_groups, | ||
| vector | delay_params, | ||
| array[]int | delay_params_groups, | ||
| array[]int | delay_dist, | ||
| int | left_truncate, | ||
| int | reverse_pmf, | ||
| int | cumulative ) |
Get the reversed probability mass function for a delay
| delay_id | Identifier for the specific delay distribution |
| len | Length of the output PMF |
| delay_types_p | Array indicating whether each delay is parametric (1) or non-parametric (0) |
| delay_types_id | Array mapping delay types to their respective IDs |
| delay_types_groups | Array of indices defining groups of delay types |
| delay_max | Array of maximum delays for parametric distributions |
| delay_np_pmf | Vector of probability mass functions for non-parametric delays |
| delay_np_pmf_groups | Array of indices for accessing non-parametric PMFs |
| delay_params | Vector of parameters for parametric delay distributions |
| delay_params_groups | Array of indices for accessing delay parameters |
| delay_dist | Array of distribution types using primarycensored convention (1: lognormal, 2: gamma, 3: weibull, 4: exponential) |
| left_truncate | Left truncation point (0 for no truncation) |
| reverse_pmf | Whether to reverse the PMF (1) or not (0) |
| cumulative | Whether to return cumulative (1) or daily (0) values |
Definition at line 65 of file delays.stan.
References convolve_with_rev_pmf(), and discretised_pmf().

| array[] int get_delay_type_max | ( | int | delay_types, |
| array[]int | delay_types_p, | ||
| array[]int | delay_types_id, | ||
| array[]int | delay_types_groups, | ||
| array[]int | delay_max, | ||
| array[]int | delay_np_pmf_groups ) |
Delay Distribution Functions
This group of functions handles the creation, manipulation, and application of delay distributions in the model. Delay distributions represent the time between events (e.g., infection to symptom onset, symptom onset to reporting). Get the maximum delay for each delay type
| delay_types | Number of delay types |
| delay_types_p | Array indicating whether each delay is parametric (1) or non-parametric (0) |
| delay_types_id | Array mapping delay types to their respective IDs |
| delay_types_groups | Array of indices defining groups of delay types |
| delay_max | Array of maximum delays for parametric distributions |
| delay_np_pmf_groups | Array of indices for accessing non-parametric PMFs |
Definition at line 23 of file delays.stan.
| vector normal_lb_rng | ( | vector | mu, |
| vector | sigma, | ||
| vector | lb ) |
Generate random samples from a normal distribution with lower bounds
| mu | Vector of means |
| sigma | Vector of standard deviations |
| lb | Vector of lower bounds |
Definition at line 233 of file delays.stan.