Discussion #3
Libraries
library(rmarkdown)
library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(tseries)
library(timeSeries)
## Loading required package: timeDate
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following object is masked from 'package:timeSeries':
##
## time<-
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
library(readr)
library(ggplot2)
Data Import and Time Series Creation
setwd("~/Desktop/Grad School/Predictive")
shooting <- read.csv("shooting.csv")
shooting <- shooting[ -c(3) ]
shooting <- na.omit(shooting)
shooting.month <- ts(data = shooting$Shootings, start = 2015, end = 2021, frequency = 12)
autoplot(shooting.month)

Model 1 - SES
fc <- ses(shooting.month, h=5)
round(accuracy(fc),2)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -0.12 9.07 7.15 -19.35 45.7 1.07 0.04
autoplot(fc) +
autolayer(fitted(fc), series="Fitted")

Model 2 - Holt and Damped Trend
fc_h <- holt(shooting.month, h=30)
round(accuracy(fc_h),2)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 0 9.07 7.14 -18.63 45.49 1.07 0.04
fc_dh <- holt(shooting.month, damped=TRUE, phi = 0.8, h=30)
round(accuracy(fc_dh),2)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -0.12 9.07 7.16 -19.46 45.78 1.08 0.04
autoplot(shooting.month) +
autolayer(fc_h, series="Holt's method", PI=FALSE) +
autolayer(fc_dh, series="Damped Holt's method", PI=FALSE) +
guides(colour=guide_legend(title="Forecast"))

Model 3 - HW Seasonal Methods
fit1 <- hw(shooting.month,seasonal="additive")
round(accuracy(fit1),2)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -0.17 5.97 4.84 -12.49 30.49 0.73 0.1
fit2 <- hw(shooting.month,seasonal="multiplicative")
round(accuracy(fit2),2)
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set -0.45 6 4.87 -13.65 30.72 0.73 0.14
autoplot(shooting.month) +
autolayer(fit1, series="HW additive forecasts", PI=FALSE) +
autolayer(fit2, series="HW multiplicative forecasts", PI=FALSE) +
guides(colour=guide_legend(title="Forecast"))
