This function takes a model fit with fit_seir() and converts the posterior distribution into priors that can be fed into a second model. This allows splitting a time series into multiple blocks.

post2prior(obj, iter = seq_len(100), time_slice = max(proj$time))

Arguments

obj

A model fit with fit_seir().

iter

Iterations to use went creating projections to extract the state posterior.

time_slice

When to take the state priors at. Defaults to the end of the fit.

Examples

# See the vignette 'Fitting case data in multiple blocks' # for a complete example cases <- c( 0, 0, 1, 3, 1, 8, 0, 6, 5, 0, 7, 7, 18, 9, 22, 38, 53, 45, 40, 77, 76, 48, 67, 78, 42, 66, 67, 92, 16, 70, 43, 53, 55, 53, 29, 26, 37, 25, 45, 34, 40, 35 ) s1 <- c(rep(0.1, 13), rep(0.2, length(cases) - 13)) m <- fit_seir( cases, iter = 200, fit_type = "optimizing", samp_frac_fixed = s1 )
#> Finding the MAP estimate.
post2prior(m, iter = seq_len(10)) # just 10 for example speed
#> $R0 #> [1] 1.21978417 0.08001301 #> #> $i0 #> [1] 7.64153273 0.08844256 #> #> $e #> [1] 0.82600448 0.04157469 #> #> $phi #> [1] 1.9357203 0.3255403 #> #> $f #> [1] 0.19456721 0.08779538 #> #> $start_decline #> [1] 0.0 0.1 #> #> $end_decline #> [1] 0.0 0.1 #> #> $state_0 #> E1_frac E2_frac I_frac Q_num R_num E1d_frac #> 0.6602933 0.1150118 0.2890190 15.1256445 163.2298501 0.6125361 #> E2d_frac Id_frac Qd_num Rd_num #> 0.1066115 0.2673027 66.2332312 711.7988096 #>