EpiNow2 Stan Functions

Functions for modeling the observation process. More...

Collaboration diagram for Observation Model:

Functions

vector day_of_week_effect (vector reports, array[] int day_of_week, vector effect)
 
vector scale_obs (vector reports, real frac_obs)
 
vector truncate_obs (vector reports, vector trunc_rev_cmf, int reconstruct)
 
void truncation_lp (array[] real truncation_mean, array[] real truncation_sd, array[] real trunc_mean_mean, array[] real trunc_mean_sd, array[] real trunc_sd_mean, array[] real trunc_sd_sd)
 
void report_lp (array[] int cases, array[] int case_times, vector reports, real dispersion, int model_type, real weight)
 
vector accumulate_reports (vector reports, array[] int accumulate)
 
vector report_log_lik (array[] int cases, vector reports, real dispersion, int model_type, real weight)
 
array[] int report_rng (vector reports, real dispersion, int model_type)
 

Description

Functions for modeling the observation process.

This group contains functions related to how infections or reports are observed, including day-of-week effects, reporting delays, and various likelihood models.

Function Documentation

◆ accumulate_reports()

vector accumulate_reports ( vector reports,
array[]int accumulate )

Accumulate reports according to a binary flag at each time point

This function accumulates reports according to a binary flag at each time point.

Parameters
reportsVector of expected reports.
accumulateArray of integers indicating, for each time point, whether to accumulate or not.
Returns
A vector of accumulated reports.

Definition at line 161 of file observation_model.stan.

◆ day_of_week_effect()

vector day_of_week_effect ( vector reports,
array[]int day_of_week,
vector effect )

Apply day of the week effect to reports

This function applies a day of the week effect to a vector of reports.

Parameters
reportsVector of reports to be adjusted.
day_of_weekArray of integers representing the day of the week for each report.
effectVector of day of week effects.
Returns
A vector of reports adjusted for day of the week effects.

Definition at line 15 of file observation_model.stan.

◆ report_log_lik()

vector report_log_lik ( array[]int cases,
vector reports,
real dispersion,
int model_type,
real weight )

Calculate log likelihood for reported cases

This function calculates the log likelihood for reported cases based on the specified model type.

Parameters
casesArray of integer observed cases.
reportsVector of expected reports.
dispersionArray of real values for reporting overdispersion.
model_typeInteger indicating the model type (0 for Poisson, >0 for Negative Binomial).
weightReal value for weighting the log likelihood contribution.
Returns
A vector of log likelihoods for each time point.

Definition at line 189 of file observation_model.stan.

◆ report_lp()

void report_lp ( array[]int cases,
array[]int case_times,
vector reports,
real dispersion,
int model_type,
real weight )

Update log density for reported cases

This function updates the log density for reported cases based on the specified model type.

Parameters
casesArray of integer observed cases.
case_timesArray of integer time indices for observed cases.
reportsVector of expected reports.
dispersionReal values for reporting overdispersion.
model_typeInteger indicating the model type (0 for Poisson, >0 for Negative Binomial).
weightReal value for weighting the log density contribution.

Definition at line 125 of file observation_model.stan.

◆ report_rng()

array[] int report_rng ( vector reports,
real dispersion,
int model_type )

Generate random samples of reported cases

This function generates random samples of reported cases based on the specified model type.

Parameters
reportsVector of expected reports.
dispersionReal value for reporting overdispersion.
model_typeInteger indicating the model type (0 for Poisson, >0 for Negative Binomial).
Returns
An array of integer sampled reports.

Definition at line 257 of file observation_model.stan.

References neg_binomial_2_safe_rng().

Here is the call graph for this function:

◆ scale_obs()

vector scale_obs ( vector reports,
real frac_obs )

Scale observations by fraction reported

This function scales a vector of reports by a fraction observed.

Parameters
reportsVector of reports to be scaled.
frac_obsReal value representing the fraction observed.
Returns
A vector of scaled reports.

Definition at line 34 of file observation_model.stan.

◆ truncate_obs()

vector truncate_obs ( vector reports,
vector trunc_rev_cmf,
int reconstruct )

Truncate observed data by a truncation distribution

This function truncates a vector of reports based on a truncation distribution.

Parameters
reportsVector of reports to be truncated.
trunc_rev_cmfVector representing the reverse cumulative mass function of the truncation distribution.
reconstructInteger flag indicating whether to reconstruct (1) or truncate (0) the data.
Returns
A vector of truncated reports.

Definition at line 57 of file observation_model.stan.

◆ truncation_lp()

void truncation_lp ( array[]real truncation_mean,
array[]real truncation_sd,
array[]real trunc_mean_mean,
array[]real trunc_mean_sd,
array[]real trunc_sd_mean,
array[]real trunc_sd_sd )

Update log density for truncation distribution priors

This function updates the log density for truncation distribution priors.

Parameters
truncation_meanArray of real values for truncation mean.
truncation_sdArray of real values for truncation standard deviation.
trunc_mean_meanArray of real values for mean of truncation mean prior.
trunc_mean_sdArray of real values for standard deviation of truncation mean prior.
trunc_sd_meanArray of real values for mean of truncation standard deviation prior.
trunc_sd_sdArray of real values for standard deviation of truncation standard deviation prior.

Definition at line 93 of file observation_model.stan.