Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature expectation reporting #154

Merged
merged 12 commits into from
Sep 1, 2022
Prev Previous commit
Next Next commit
add skipping for latent model
  • Loading branch information
seabbs committed Aug 5, 2022
commit 86dabd31099e267ce0139fbe6a0f295a2ac76963
7 changes: 4 additions & 3 deletions R/model-modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,11 @@ enw_expectation <- function(r = ~ rw(day, by = .group), generation_time = 1,
# Observation indicator variables
obs_list <- list(
lrd_n = length(latent_reporting_delay),
lrlrd = log(rev(latent_reporting_delay)),
obs = 0
lrlrd = log(rev(latent_reporting_delay))
)
obs_list$obs <- ifelse(
sum(latent_reporting_delay) == 1 && obs_list$lrd_n == 1, 0, 1
)

# Observation formula
obs_form <- enw_formula(osbervation, data$metareference[[1]], sparse = FALSE)
obs_data <- enw_formula_as_data_list(
Expand Down
19 changes: 12 additions & 7 deletions inst/stan/epinowcast.stan
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ transformed parameters{
// Expectation model
vector[expr_t] r; // Log growth rate of observations
array[g] vector[expr_ft] exp_latent_lobs; // Expected final observations
vector[expo_fnindex] expo_modifier; // Reporting modifier
vector[expo_obs ? expo_fnindex : 0] expo_modifier; // Reporting modifier
array[g] vector[t] exp_lobs; // Expected final observations
// Reference model
vector[refp_fnrow] refp_mean;
Expand All @@ -195,12 +195,17 @@ transformed parameters{
);
// Get reporting modifiers and map latent expected observations to expected
// observations
expo_modifier = combine_effects(
0, expo_beta, expo_fdesign, expo_beta_sd, expo_rdesign, 1
);
exp_lobs = log_expected_obs_from_latent_obs(
exp_latent_lobs, expo_lrd_n, expo_lrlrd, t, g, expo_modifier
);
if (expo_obs) {
expo_modifier = combine_effects(
0, expo_beta, expo_fdesign, expo_beta_sd, expo_rdesign, 1
);
exp_lobs = log_expected_obs_from_latent_obs(
exp_latent_lobs, expo_lrd_n, expo_lrlrd, t, g, expo_modifier
);
}else{
exp_lobs = exp_latent_lobs;
}

}

// Reference model
Expand Down