epinowcast
Loading...
Searching...
No Matches
expected_obs_from.stan
Go to the documentation of this file.
1
33 int i, array[] vector imp_obs,
34 array[,] int rdlurd, vector srdlh,
35 matrix refp_lh, array[] int dpmfs, int ref_p,
36 int rep_h, int ref_as_p, int g, int t, int l,
37 vector refnp_lh, int ref_np, int p,
38 int rep_agg_p,
39 array[,,] int rep_agg_n_selected,
40 array[,,,] int rep_agg_selected_idx
41) {
42 // Combine logit hazards from reference and reporting time effects
43 vector[l] lh;
44 profile("model_likelihood_hazard_allocations") {
46 i, rdlurd, srdlh, refp_lh, dpmfs, ref_p, rep_h, g, t, l, refnp_lh, ref_np, p
47 );
48 }
49 // Extract precomputed selected indices for this group/time
50 array[l] int n_sel;
51 array[l, l] int sel_idx;
52 if (rep_agg_p == 1) {
53 n_sel = rep_agg_n_selected[g, t, 1:l];
54 sel_idx = rep_agg_selected_idx[g, t, 1:l, 1:l];
55 }
56 // Combine expected final obs and time effects to get expected obs
57 return expected_obs(imp_obs[g][t], lh, l, ref_as_p, rep_agg_p, n_sel, sel_idx);
58}
59
88 int start, int end, array[] vector imp_obs,
89 array[,] int rdlurd, vector srdlh,
90 matrix refp_lh, array[] int dpmfs,
91 int ref_p, int rep_h, int ref_as_p,
92 array[] int sl, array[] int csl,
93 array[] int sg, array[] int st, int n,
94 vector refnp_lh, int ref_np, array[] int sdmax,
95 array[] int csdmax, int rep_agg_p,
96 array[,,] int rep_agg_n_selected,
97 array[,,,] int rep_agg_selected_idx
98) {
99 vector[n] log_exp_obs;
100 int ssnap = 1;
101 int esnap = 0;
102 int l;
103
104 for (i in start:end) {
105 l = sl[i];
106 profile("expected_obs_from_index") {
107 if (l) {
108 esnap += l;
109 log_exp_obs[ssnap:esnap] = expected_obs_from_index(
110 i, imp_obs, rdlurd, srdlh, refp_lh, dpmfs, ref_p, rep_h, ref_as_p,
111 sg[i], st[i], l, refnp_lh, ref_np, csdmax[i] - sdmax[i] + 1,
112 rep_agg_p, rep_agg_n_selected, rep_agg_selected_idx
113 );
114 ssnap += l;
115 }
116 }
117 }
118 return(log_exp_obs);
119}
vector combine_logit_hazards(int i, array[,] int rdlurd, vector srdlh, matrix refp_lh, array[] int dpmfs, int ref_p, int rep_h, int g, int t, int l, vector refnp_lh, int refnp_p, int p)
vector expected_obs(real tar_obs, vector lh, int l, int ref_as_p, int rep_agg_p, array[] int n_selected, array[,] int selected_idx)
vector expected_obs_from_index(int i, array[] vector imp_obs, array[,] int rdlurd, vector srdlh, matrix refp_lh, array[] int dpmfs, int ref_p, int rep_h, int ref_as_p, int g, int t, int l, vector refnp_lh, int ref_np, int p, int rep_agg_p, array[,,] int rep_agg_n_selected, array[,,,] int rep_agg_selected_idx)
vector expected_obs_from_snaps(int start, int end, array[] vector imp_obs, array[,] int rdlurd, vector srdlh, matrix refp_lh, array[] int dpmfs, int ref_p, int rep_h, int ref_as_p, array[] int sl, array[] int csl, array[] int sg, array[] int st, int n, vector refnp_lh, int ref_np, array[] int sdmax, array[] int csdmax, int rep_agg_p, array[,,] int rep_agg_n_selected, array[,,,] int rep_agg_selected_idx)