epinowcast
expected_obs_from.stan
Go to the documentation of this file.
1
46vector expected_obs_from_index(int i, array[] vector imp_obs,
47 array[,] int rdlurd, vector srdlh,
48 matrix refp_lh, array[] int dpmfs, int ref_p,
49 int rep_h, int ref_as_p, int g, int t, int l,
50 vector refnp_lh, int ref_np, int p) {
51 vector[l] lh;
52 vector[l] log_exp_obs;
53 profile("model_likelihood_hazard_allocations") {
55 i, rdlurd, srdlh, refp_lh, dpmfs, ref_p, rep_h, g, t, l, refnp_lh, ref_np,
56 p
57 );
58 }
59 // Find final observed/imputed expected observation
60 // combine expected final obs and time effects to get expected obs
61 profile("model_likelihood_expected_obs") {
62 int agg_probs = 0;
63 matrix[1, 1] agg_indicator;
64 agg_indicator[1, 1] = 0;
65 log_exp_obs = expected_obs(imp_obs[g][t], lh, l, ref_as_p, agg_probs, agg_indicator);
66 }
67 return(log_exp_obs);
68}
69
117vector expected_obs_from_snaps(int start, int end, array[] vector imp_obs,
118 array[,] int rdlurd, vector srdlh,
119 matrix refp_lh, array[] int dpmfs,
120 int ref_p, int rep_h, int ref_as_p,
121 array[] int sl, array[] int csl,
122 array[] int sg, array[] int st, int n,
123 vector refnp_lh, int ref_np, array[] int sdmax,
124 array[] int csdmax) {
125 vector[n] log_exp_obs;
126 int ssnap = 1;
127 int esnap = 0;
128 int g;
129 int t;
130 int l;
131 int p;
132
133 for (i in start:end) {
134 profile("allocations") {
135 g = sg[i];
136 t = st[i];
137 l = sl[i];
138 p = csdmax[i] - sdmax[i] + 1;
139 }
140 // combine expected final obs and time effects to get expected obs
141 profile("expected_obs_from_index") {
142 if (l) {
143 esnap += l;
144 log_exp_obs[ssnap:esnap] = expected_obs_from_index(
145 i, imp_obs, rdlurd, srdlh, refp_lh, dpmfs, ref_p, rep_h, ref_as_p, g, t,
146 l, refnp_lh, ref_np, p
147 );
148 ssnap += l;
149 }
150 }
151 }
152 return(log_exp_obs);
153}
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 agg_probs, matrix agg_indicator)
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)
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)