ts_forecast: Time Series Forecast for Daily Crime Data

Description Usage Arguments Value Author(s) Examples

View source: R/ts_forecast.R

Description

This function transforms traditional crime data into a time series and forecasts future incident counts based on the input data over a specified duration. The forecast is computed using simple exponential smoothing with additive errors. Returned is a plot of the time series, trend, and the upper and lower prediction limits for the forecast.

Usage

1
ts_forecast(data, start, duration = NULL)

Arguments

data

Data frame of crime or RMS data. See provided Chicago Data Portal example for reference

start

Start date for the time series being analyzed. The format is as follows: c('year', 'month', 'day'). See example below for reference.

duration

Number of days for the forecast. If NULL, the default duration for the forecast is 365 days.

Value

Returns a plot of the time series entered (black), a forecast over the specified duration (blue), the exponentially smoothed trend for both the input data (red) and forecast (orange), and the upper and lower bounds for the prediction interval (grey).

Author(s)

Jamie Spaulding, Keith Morris

Examples

1
2
3
#Using provided dataset from Chicago Data Portal:
data(crimes)
ts_forecast(crimes, start = c(2017, 1, 1))

Example output

Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 

rcrimeanalysis documentation built on July 8, 2020, 7:34 p.m.