get_seasonality: Function to compute the estimated seasonal time series...

Description Usage Arguments Value Examples

View source: R/get_seasonality.R

Description

get_seasonality computes the seasonal component in the observation equation of the program narrative.

Usage

1
get_seasonality(states, harmonics = 4, crime_types = c("burglary", "robbery"))

Arguments

states

A three dimensional array of sampled states such as that given by get_states.

harmonics

An integer in 1 to 6 specifiying the number of harmonics to model seasonality. Must be consistent with specification in run_mcmc().

crime_types

Character vector specifying the types of crimes to include in the analysis. The function requires at least two crime types.

Value

Returns a list with two objects: seasonal_effects and crime_types. seasonal_effects 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 crime type. 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 smoothmeans output as well as making sure that the order of crime types is consistent between other functions.

Examples

1
2
3
4
5
6
 ## Not run: 
 cov_samples <- run_mcmc(data = chicago, chains = 2, adapt_delta = 0.8)
 state_samples <- get_states(mcmc_samples = cov_samples$samples, data = chicago)
 seasonality <- get_seasonality(states = state_samples$state_samples)
 
## End(Not run)

nategarton13/CrimeDLM.RPackage documentation built on Aug. 8, 2020, 7:49 p.m.