Description Usage Arguments Value Examples
get_states
uses the dlm
package to sample the latent states via the
forward filtering-backward sampling algorithm as described in the research narrative.
The same arguments should be supplied for parameters shared by get_states
and run_mcmc
.
1 2 3 4 5 6 7 8 | get_states(
mcmc_samples,
data,
harmonics = 4,
crime_types = c("burglary", "robbery"),
initial_year = 2012,
final_year = 2016
)
|
mcmc_samples |
A list of parameter samples with the same names and classes as those produced by |
data |
The full Chicago crime dataset as given by |
harmonics |
An integer in 1 to 6 specifiying the number of harmonics to model seasonality.
Must be consistent with specification in |
crime_types |
Character vector specifying the types of crimes to include in the analysis. The function requires at least two crime types. |
initial_year |
Integer in 2007 to 2015 specifying the first year in the analysis. |
final_year |
Integer in 2008 to 2016 specifying the last year in the analysis. |
Returns a list with two objects: state_samples and crime_types.
state_samples is a three dimensional array where dimension one corresponds to the sample/iteration,
dimension two corresponds to the number of time points, and dimension three corresponds to the parameter.
Parameters are in the following order: μ_1,μ_2,...,β_1, β_2,.... The ordering of a given set of parameters,
say μ, is the ordering of the types of crimes specified by the crime_types
argument.
After β parameters, the remainder are needed for the construction of seasonal effects.
crime_types returns the crime_types argument specified in the function. This serves as a reminder of
the ordering of crime types, which is important for interpreting the state_samples output
as well as making sure that the order of crime types is consistent between other functions.
1 2 3 4 5 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.