![]() |
EpiNow2 Stan Functions
|
Functions for modeling the observation process. More...

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) |
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.
| 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.
| reports | Vector of expected reports. |
| accumulate | Array of integers indicating, for each time point, whether to accumulate or not. |
Definition at line 161 of file observation_model.stan.
| 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.
| reports | Vector of reports to be adjusted. |
| day_of_week | Array of integers representing the day of the week for each report. |
| effect | Vector of day of week effects. |
Definition at line 15 of file observation_model.stan.
| 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.
| cases | Array of integer observed cases. |
| reports | Vector of expected reports. |
| dispersion | Array of real values for reporting overdispersion. |
| model_type | Integer indicating the model type (0 for Poisson, >0 for Negative Binomial). |
| weight | Real value for weighting the log likelihood contribution. |
Definition at line 189 of file observation_model.stan.
| 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.
| cases | Array of integer observed cases. |
| case_times | Array of integer time indices for observed cases. |
| reports | Vector of expected reports. |
| dispersion | Real values for reporting overdispersion. |
| model_type | Integer indicating the model type (0 for Poisson, >0 for Negative Binomial). |
| weight | Real value for weighting the log density contribution. |
Definition at line 125 of file observation_model.stan.
| 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.
| reports | Vector of expected reports. |
| dispersion | Real value for reporting overdispersion. |
| model_type | Integer indicating the model type (0 for Poisson, >0 for Negative Binomial). |
Definition at line 257 of file observation_model.stan.
References neg_binomial_2_safe_rng().

| vector scale_obs | ( | vector | reports, |
| real | frac_obs ) |
Scale observations by fraction reported
This function scales a vector of reports by a fraction observed.
| reports | Vector of reports to be scaled. |
| frac_obs | Real value representing the fraction observed. |
Definition at line 34 of file observation_model.stan.
| 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.
| reports | Vector of reports to be truncated. |
| trunc_rev_cmf | Vector representing the reverse cumulative mass function of the truncation distribution. |
| reconstruct | Integer flag indicating whether to reconstruct (1) or truncate (0) the data. |
Definition at line 57 of file observation_model.stan.
| 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.
| truncation_mean | Array of real values for truncation mean. |
| truncation_sd | Array of real values for truncation standard deviation. |
| trunc_mean_mean | Array of real values for mean of truncation mean prior. |
| trunc_mean_sd | Array of real values for standard deviation of truncation mean prior. |
| trunc_sd_mean | Array of real values for mean of truncation standard deviation prior. |
| trunc_sd_sd | Array of real values for standard deviation of truncation standard deviation prior. |
Definition at line 93 of file observation_model.stan.