epinowcast
log_expected_obs_from_latent.stan File Reference

Go to the source code of this file.

Functions

array[] vector log_expected_obs_from_latent (array[] vector exp_llatent, int rd_n, vector w, array[] int v, array[] int u, int t, int g, vector latent_obs_prop)
 

Function Documentation

◆ log_expected_obs_from_latent()

array[] vector log_expected_obs_from_latent ( array[]vector  exp_llatent,
int  rd_n,
vector  w,
array[]int  v,
array[]int  u,
int  t,
int  g,
vector  latent_obs_prop 
)

Compute log of expected observations from latent values

This function calculates the expected observations in log scale based on latent expected values, weighting factors, and observational proportions. The weighting factors are derived from a sparse matrix, which is constructed using the extract_sparse_matrix and convolution_matrix R functions in epinowcast.

Parameters
exp_llatentArray of vectors of log latent expected values.
rd_nLength of the reporting delay (1 for immediate reporting).
wVector of weighting factors derived from a sparse matrix.
v,uArrays for sparse matrix representation, as obtained from extract_sparse_matrix.
tNumber of time periods.
gNumber of groups.
latent_obs_propVector of observational proportions for latent values.
Returns
An array of vectors containing log-transformed expected observed values for each group and time period.
Note
The function performs different operations based on the value of rd_n:
  1. If rd_n is 1 (immediate reporting): a. Directly adds the log latent values, log of weights, and observational proportions for each group.
  2. If rd_n > 1 (delayed reporting): a. Uses a convolution matrix constructed using convolution_matrix or otherwise, representing reporting delays. b. Prior to being used as an input this is converted to a sparse matrix format using extract_sparse_matrix. c. Applies the sparse matrix multiplication to the latent values in a sparse matrix multiplication. d. Converts the resulting values back to the log scale and adds the observational proportions for each group.

These steps account for different reporting delays and the distribution of observations over time.

See also
extract_sparse_matrix and convolution_matrix epinowcast R functions for details on sparse matrix construction and convolution matrix generation.

Definition at line 50 of file log_expected_obs_from_latent.stan.