post2prior: Extract new priors from a previous fit

Description Usage Arguments Examples

View source: R/post2prior.R

Description

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.

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# 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
)
post2prior(m, iter = seq_len(10)) # just 10 for example speed

seananderson/covidseir documentation built on June 3, 2021, 6:49 a.m.