21 int n = num_elements(x);
25 return append_row(x, rep_vector(x[n], t - n));
43 if (num_elements(noise) == 0) {
44 return rep_vector(0, t);
49 return hold_forward(append_row(0, cumulative_sum(noise)), t);
61 return append_row(0, cumulative_sum(bp_effects));
82 int stationary,
int n_centre) {
86 c -= sum(gp[1:n_centre]) / n_centre;
88 if (num_elements(bp) > 1) {
89 c -= sum(bp[bps[1:n_centre]]) / n_centre;
113vector
update_Rt(
int t, real R0, vector noise, array[]
int bps,
114 vector bp_effects,
int stationary,
int n_centre) {
115 int bp_n = num_elements(bp_effects);
122 vector[bp_n + 1] log_R_bp = c + bp;
123 if (num_elements(noise) == 0) {
125 vector[bp_n + 1] R_bp = exp(log_R_bp);
128 return exp(log_R_bp[bps] + gp);
146void rt_lp(array[] real initial_infections_scale, vector bp_effects,
147 array[] real bp_sd,
int bp_n, array[]
int cases,
148 real initial_infections_guess) {
151 bp_sd[1] ~ normal(0, 0.1);
152 bp_effects ~ normal(0, bp_sd[1]);
154 initial_infections_scale ~ normal(initial_infections_guess, 2);
182real
R_to_r(real R, vector gt_rev_pmf, data real abs_tol);
vector bp_log_levels(vector bp_effects)
Uncentred log Rt level of each breakpoint segment.
vector gp_log_path(vector noise, int t, int stationary)
Uncentred Gaussian process contribution to log Rt.
vector hold_forward(vector x, int t)
Extend a vector to length t by repeating its last value.
vector update_Rt(int t, real R0, vector noise, array[] int bps, vector bp_effects, int stationary, int n_centre)
Update a vector of effective reproduction numbers (Rt) based on an intercept, breakpoints (i....
void rt_lp(array[] real initial_infections_scale, vector bp_effects, array[] real bp_sd, int bp_n, array[] int cases, real initial_infections_guess)
real R_to_r(real R, vector gt_rev_pmf, data real abs_tol)
real centred_log_intercept(real R0, vector gp, vector bp, array[] int bps, int stationary, int n_centre)
Log Rt intercept that centres the paths over the centring window.