bayesian_filter: Project infection in a single county using a Bayesian filter

Description Usage Arguments Details Value

View source: R/bayes-filter.R

Description

This function runs a single county one week forward in time from a distribution of model states. For each starting state it produces one sample from the posterior PDF of beta values and importation values for the next week. The result is a distribution of one-week beta values and importation values, along with a new distribution of states at the end of the week.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
bayesian_filter(
  initstates,
  locality,
  tinit,
  tfin,
  obsdata = NULL,
  hospdata = NULL,
  nsamp = 1000,
  prior = bayes_filter_default_prior
)

Arguments

initstates

Matrix of initial states and parameter samples (see details).

tinit

Time corresponding to the initial states.

tfin

End time for the forecast.

obsdata

Observed number of tests and number of positive tests by county. (See details)

hospdata

Observed UVA hospitalizations by week. This should be pre-filtered to the locality being run.

nsamp

Number of Monte Carlo Samples to run for each state. The final set of parameters from the Monte Carlo will be used to generate the finals state.

prior

Prior PDF function. It should take a vector of five parameters: start and end beta values, start and end importation values, and size of time step.

Details

The initial states should be a matrix with samples in rows and variables in columns. The variables should be the state variables of the infection equations (S, E, I, Is, and R), plus the beta and import_cases parameters.

The observed data should be the first element of the list returned by get_obsdata, filtered to the locality being analyzed. If omitted, we will fetch the data and filter it; however, if this function will be called consecutively for several weeks, running, it will save some time to do the filtering once and pass the table in.

Value

A table of parameter values and final states corresponding to each initial state. This output is suitable to feed back into the function as initstates for a subsequent week.


rplzzz/CovMitigation documentation built on June 7, 2021, 8:48 a.m.