Description Usage Arguments Value Examples
run_mcmc
uses Stan to run a Hamiltonian Monte Carlo algorithm to sample the observation
and latent state covariance parameters in the dynamic linear model specificied in the research narrative.
The full chicago crime dataset must be passed to the data
argument. Other parameter arguments dictate
the subset of the data on which the analysis is performed as well as details of the MCMC to be passed to rstan::sampling
.
1 2 3 4 5 6 7 8 9 10 11 |
data |
The full Chicago crime dataset as given by |
harmonics |
An integer in 1 to 6 specifiying the number of harmonics to model seasonality. |
chains |
An integer specifying the number of MCMC chains for Stan to run. |
iter |
An integer specifying the total number of samples for each chain, including warmup. |
warmup |
An integer specifying the number of burn-in samples in Stan. |
adapt_delta |
See Stan language manual at http://mc-stan.org/users/documentation/. |
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 of three objects: samples, summary, and crime_types. summary gives a summary of the
samples. 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 covariance matrix output
as well as making sure that the order of crime types is consistent between other functions.
samples is itself a list where each element is either a two or three dimensional array
containing all of the samples of a given parameter. The first dimension of the array always
corresponds to the sample/iteration. Parameter names work as follows:
omega_evo
corresponds to evolution correlation matrices,
omega_error
corresponds to error correlation matrices,
sigma_evo
corresponds to a vector of evolution standard deviations,
sigma_error
corresponds to a vector of the error standard deviations,
sigma_evo_mat
corresponds to evolution covariance matrices,
sigma_error_mat
corresponds to error covariance matrices.
See Stan documentation for lp__
.
1 2 3 4 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.