Skip to content

Commit

Permalink
implement suggestions by @hsbadr
Browse files Browse the repository at this point in the history
See
#213 (comment)
#213 (comment)
#213 (comment)

For now not implementing comparison to the approximate growth rate as
this seems quite a specific use case that could also be done outside the
stan model.

Also not implementing any approximate growth rate from seeding time -
instead minimum seeding time is now set to 1, so the last seeding time
is used to calculate the first growth rate.
  • Loading branch information
sbfnk committed Oct 13, 2022
1 parent 2406f38 commit 5042d2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extract_parameter_samples <- function(stan_fit, data, reported_dates, reported_i
out$growth_rate <- extract_parameter(
"r",
samples,
reported_dates[-1]
reported_dates
)
if (data$week_effect > 1) {
out$day_of_week <- extract_parameter(
Expand Down
5 changes: 2 additions & 3 deletions inst/stan/estimate_infections.stan
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ model {
generated quantities {
int imputed_reports[ot_h];
vector[estimate_r > 0 ? 0: ot_h] R;
real r[ot_h - 1];
real r[ot_h];
vector[return_likelihood > 1 ? ot : 0] log_lik;
if (estimate_r == 0){
// sample generation time
Expand All @@ -148,8 +148,7 @@ generated quantities {
R = calculate_Rt(infections, seeding_time, gt_mean_sample, gt_sd_sample,
max_gt, rt_half_window);
}
// estimate growth from infections
r = calculate_growth(infections, seeding_time + 1);
r = calculate_growth(infections, seeding_time);
// simulate reported cases
imputed_reports = report_rng(reports, rep_phi, obs_dist);
// log likelihood of model
Expand Down
4 changes: 2 additions & 2 deletions inst/stan/simulate_infections.stan
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ generated quantities {
matrix[n, t] infections; //latent infections
matrix[n, t - seeding_time] reports; // observed cases
int imputed_reports[n, t - seeding_time];
real r[n, t - seeding_time - 1];
real r[n, t - seeding_time];
vector[seeding_time] uobs_inf;
for (i in 1:n) {
uobs_inf = generate_seed(initial_infections[i], initial_growth[i], seeding_time);
Expand All @@ -49,6 +49,6 @@ generated quantities {
}
// simulate reported cases
imputed_reports[i] = report_rng(to_vector(reports[i]), rep_phi[i], obs_dist);
r[i] = calculate_growth(to_vector(infections[i]), seeding_time + 1);
r[i] = calculate_growth(to_vector(infections[i]), seeding_time);
}
}

0 comments on commit 5042d2f

Please sign in to comment.