diff --git a/inst/stan/estimate_infections.stan b/inst/stan/estimate_infections.stan index 719af7f3d..3783f9298 100644 --- a/inst/stan/estimate_infections.stan +++ b/inst/stan/estimate_infections.stan @@ -156,7 +156,7 @@ model { generated quantities { array[ot_h] int imputed_reports; vector[estimate_r > 0 ? 0: ot_h] gen_R; - array[ot_h - 1] real r; + vector[ot_h - 1] r; real gt_mean; real gt_var; vector[return_likelihood ? ot : 0] log_lik; diff --git a/inst/stan/functions/generated_quantities.stan b/inst/stan/functions/generated_quantities.stan index 5b9266cb7..d418a9d7b 100644 --- a/inst/stan/functions/generated_quantities.stan +++ b/inst/stan/functions/generated_quantities.stan @@ -30,10 +30,10 @@ vector calculate_Rt(vector infections, int seeding_time, } // Calculate growth rate -array[] real calculate_growth(vector infections, int seeding_time) { +vector calculate_growth(vector infections, int seeding_time) { int t = num_elements(infections); int ot = t - seeding_time; vector[t] log_inf = log(infections); vector[ot] growth = log_inf[(seeding_time + 1):t] - log_inf[seeding_time:(t - 1)]; - return(to_array_1d(growth)); + return(growth); } diff --git a/inst/stan/simulate_infections.stan b/inst/stan/simulate_infections.stan index f2a0762b5..1f4f65cb9 100644 --- a/inst/stan/simulate_infections.stan +++ b/inst/stan/simulate_infections.stan @@ -35,7 +35,7 @@ generated quantities { matrix[n, t] infections; //latent infections matrix[n, t - seeding_time] reports; // observed cases array[n, t - seeding_time] int imputed_reports; - array[n, t - seeding_time - 1] real r; + matrix[n, t - seeding_time - 1] r; for (i in 1:n) { // generate infections from Rt trace vector[delay_type_max[gt_id] + 1] gt_rev_pmf; @@ -94,6 +94,8 @@ generated quantities { imputed_reports[i] = report_rng( to_vector(reports[i]), rep_phi[i], model_type ); - r[i] = calculate_growth(to_vector(infections[i]), seeding_time + 1); + r[i] = to_row_vector( + calculate_growth(to_vector(infections[i]), seeding_time + 1) + ); } }