epinowcast
Loading...
Searching...
No Matches
log_expected_latent_from_r.stan File Reference

Go to the source code of this file.

Functions

vector extract_group_rates (vector r, array[] int r_g, int k, int r_t)
 
array[] vector log_expected_latent_from_r (matrix lexp_latent_int, vector r, array[] int r_g, int r_t, int r_seed, int gt_n, vector lrgt, int t, int g, vector pop, int use_pop, real pop_floor)
 

Function Documentation

◆ extract_group_rates()

vector extract_group_rates ( vector r,
array[]int r_g,
int k,
int r_t )

Extract log growth rates for a specific group

Parameters
rVector of all group growth rates concatenated.
r_gArray of indices marking the start of each group in r.
kGroup index (1-indexed).
r_tNumber of time periods.
Returns
Vector of log growth rates for group k.

Definition at line 11 of file log_expected_latent_from_r.stan.

◆ log_expected_latent_from_r()

array[] vector log_expected_latent_from_r ( matrix lexp_latent_int,
vector r,
array[]int r_g,
int r_t,
int r_seed,
int gt_n,
vector lrgt,
int t,
int g,
vector pop,
int use_pop,
real pop_floor )

Iteratively compute expected latent values using the renewal equation

This function calculates expected latent values over time for different groups using the renewal equation. It's designed to handle scenarios where the generation time is represented either as a constant (leading to exponential growth) or as a vector (requiring a dot product calculation). The function operates on the natural scale for stability and then transforms the results back to the log scale when the generation time is a vector.

Parameters
lexp_latent_intMatrix of initial log expected latent values.
rVector representing growth rate or the log of the effective reproduction number.
r_gArray of indices marking the start of each group in the rate vector.
r_tNumber of time periods for rate adjustments.
r_seedSeed time period for rate-based adjustments.
gt_nLength of the generation time vector (1 for constant generation time).
lrgtLog of the generation time vector or scalar.
tTotal number of time periods.
gNumber of groups.
popInitial susceptible population per group. Ignored when use_pop == 0.
use_popSusceptible-depletion switch (0 = off, 1 = on). When on, transmission is scaled by the remaining susceptible fraction over the whole post-seed series.
pop_floorMinimum susceptible population, floored on the transmission-rate denominator only. Matches EpiNow2's rt_opts(pop_floor). Only used when use_pop > 0.
Returns
An array of vectors of log-transformed expected latent values by group and time.
Note
For each group: when gt_n == 1 exponential growth is computed as a cumulative sum on the log scale; when gt_n > 1 the renewal equation is applied on the natural scale (more stable) and logged afterwards.

When use_pop > 0, new cases are capped by the remaining susceptibles (fmax(0, pop - cum_cases)) so depletion cannot exceed the pool, and a small 1e-8 floor keeps the subsequent log() finite near exhaustion. Groups are independent well-mixed populations with no waning or vital dynamics. Adapted from EpiNow2's generate_infections() (epiforecasts/EpiNow2, MIT licence).

Definition at line 70 of file log_expected_latent_from_r.stan.