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 vector[l] lh;
43 vector[l] log_exp_obs;
44 profile("model_likelihood_hazard_allocations") {
46 i, rdlurd, srdlh, refp_lh, dpmfs, ref_p, rep_h, g, t, l, refnp_lh, ref_np,
47 p
48 );
49 }
50 // Extract the precomputed selected indices for this group/time
51 array[l] int n_sel;
52 array[l, l] int sel_idx;
53 if (rep_agg_p == 1) {
54 n_sel = rep_agg_n_selected[g, t, 1:l];
55 sel_idx = rep_agg_selected_idx[g, t, 1:l, 1:l];
56 }
57 // Find final observed/imputed expected observation
58 // combine expected final obs and time effects to get expected obs
59 profile("model_likelihood_expected_obs") {
60 log_exp_obs = expected_obs(
61 imp_obs[g][t], lh, l, ref_as_p, rep_agg_p, n_sel, sel_idx
62 );
63 }
64 return(log_exp_obs);
65}
66
95 int start, int end, array[] vector imp_obs,
96 array[,] int rdlurd, vector srdlh,
97 matrix refp_lh, array[] int dpmfs,
98 int ref_p, int rep_h, int ref_as_p,
99 array[] int sl, array[] int csl,
100 array[] int sg, array[] int st, int n,
101 vector refnp_lh, int ref_np, array[] int sdmax,
102 array[] int csdmax, int rep_agg_p,
103 array[,,] int rep_agg_n_selected,
104 array[,,,] int rep_agg_selected_idx
105) {
106 vector[n] log_exp_obs;
107 int ssnap = 1;
108 int esnap = 0;
109 int g;
110 int t;
111 int l;
112 int p;
113
114 for (i in start:end) {
115 profile("allocations") {
116 g = sg[i];
117 t = st[i];
118 l = sl[i];
119 p = csdmax[i] - sdmax[i] + 1;
120 }
121 // combine expected final obs and time effects to get expected obs
122 profile("expected_obs_from_index") {
123 if (l) {
124 esnap += l;
125 log_exp_obs[ssnap:esnap] = expected_obs_from_index(
126 i, imp_obs, rdlurd, srdlh, refp_lh, dpmfs, ref_p, rep_h, ref_as_p, g, t,
127 l, refnp_lh, ref_np, p, rep_agg_p, rep_agg_n_selected,
128 rep_agg_selected_idx
129 );
130 ssnap += l;
131 }
132 }
133 }
134 return(log_exp_obs);
135}
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)