In this discussion, we will be looking at the Boston Warrant Arrests from last week and forecasts using GARCH model. GARCH model is best for looking at volatilities in financial data. Due to having less data, it is difficult for the GARCH model to predict by looking at volatility.

crime <- read.csv("crimeinboston.csv") 
arrests=crime[crime$OFFENSE_CODE_GROUP  == "Warrant Arrests",]
arrests=arrests[,c(3,8)]
arrests$OCCURRED_ON_DATE=as.Date(arrests$OCCURRED_ON_DATE)
arrests=arrests %>% count(arrests$OCCURRED_ON_DATE)
data <- as.xts(arrests[,2],order.by=as.Date(arrests[,1]))
arrests <- apply.monthly(data,sum)
names(arrests)[1] <- "Car_Accidents"
n<-dim(arrests)[1]
arrests<-arrests[2:(n-1),]

Warrests <- ts(arrests[,1], start = c(2015,07), frequency = 12)

The time series shows a increase in 2016 May and decrease from 2017 Jun to 2018 July.

autoplot(Warrests)+ 
  ggtitle("Warrant Arrests in Boston") +
  xlab("Dates") +
  ylab("Arrests")

acf(Warrests)

ndiffs(Warrests)
## [1] 1

Looking at the ACF we should take the difference

fitSES=ses(Warrests)
fitETS <- ets(Warrests)
fitARIMA <- auto.arima(Warrests)


fcstses <- forecast(fitSES, h = 6)
fcstETS <- forecast(fitETS, h = 6)
fcstARIMA <- forecast(fitARIMA, h = 6)
autoplot(fitSES)

autoplot(fcstETS)

autoplot(fcstARIMA)

I recreated the different models from previous discussions.

fitGARCH <- garchFit( data = Warrests,cond.dist = 'norm')
## 
## Series Initialization:
##  ARMA Model:                arma
##  Formula Mean:              ~ arma(0, 0)
##  GARCH Model:               garch
##  Formula Variance:          ~ garch(1, 1)
##  ARMA Order:                0 0
##  Max ARMA Order:            0
##  GARCH Order:               1 1
##  Max GARCH Order:           1
##  Maximum Order:             1
##  Conditional Dist:          norm
##  h.start:                   2
##  llh.start:                 1
##  Length of Series:          38
##  Recursion Init:            mci
##  Series Scale:              54.30678
## 
## Parameter Initialization:
##  Initial Parameters:          $params
##  Limits of Transformations:   $U, $V
##  Which Parameters are Fixed?  $includes
##  Parameter Matrix:
##                       U         V   params includes
##     mu     -40.22469179  40.22469 4.022469     TRUE
##     omega    0.00000100 100.00000 0.100000     TRUE
##     alpha1   0.00000001   1.00000 0.100000     TRUE
##     gamma1  -0.99999999   1.00000 0.100000    FALSE
##     beta1    0.00000001   1.00000 0.800000     TRUE
##     delta    0.00000000   2.00000 2.000000    FALSE
##     skew     0.10000000  10.00000 1.000000    FALSE
##     shape    1.00000000  10.00000 4.000000    FALSE
##  Index List of Parameters to be Optimized:
##     mu  omega alpha1  beta1 
##      1      2      3      5 
##  Persistence:                  0.9 
## 
## 
## --- START OF TRACE ---
## Selected Algorithm: nlminb 
## 
## R coded nlminb Solver: 
## 
##   0:     52.411109:  4.02247 0.100000 0.100000 0.800000
##   1:     52.280868:  4.06359 0.112111 0.118158 0.809960
##   2:     52.177638:  4.11531 0.0957684 0.124365 0.795498
##   3:     52.086978:  4.07770 0.0920877 0.148309 0.793083
##   4:     52.056410:  4.08274 0.0690393 0.183802 0.762623
##   5:     51.959305:  4.14907 0.0913415 0.217994 0.734660
##   6:     51.815754:  4.00373 0.104897 0.226060 0.700513
##   7:     51.697722:  4.05028 0.114393 0.251588 0.657564
##   8:     50.787518:  3.86674 0.319019 0.456511 0.188504
##   9:     50.376941:  3.91867 0.296816 0.901481 1.00000e-08
##  10:     50.301185:  3.96077 0.291990 0.898501 0.0360181
##  11:     49.692762:  3.86837 0.166471 0.932415 0.110795
##  12:     49.615174:  3.78201 0.160860 0.932796 0.113887
##  13:     49.521652:  3.81976 0.144408 0.938030 0.124655
##  14:     49.466988:  3.75634 0.112412 0.950705 0.148645
##  15:     49.442447:  3.83056 0.109736 0.953009 0.153052
##  16:     49.410878:  3.79664 0.100421 0.962046 0.164574
##  17:     49.408184:  3.80458 0.107778 0.962335 0.164947
##  18:     49.407214:  3.79446 0.106806 0.962340 0.164291
##  19:     49.406825:  3.79869 0.104677 0.963251 0.165400
##  20:     49.406503:  3.79975 0.106774 0.963626 0.163642
##  21:     49.406356:  3.79911 0.106466 0.962772 0.162671
##  22:     49.406290:  3.79786 0.106274 0.964054 0.162555
##  23:     49.406071:  3.79815 0.106188 0.967001 0.161286
##  24:     49.405829:  3.79918 0.106216 0.975084 0.159132
##  25:     49.405828:  3.79924 0.106240 0.975194 0.159154
##  26:     49.405828:  3.79924 0.106242 0.975194 0.159154
## 
## Final Estimate of the Negative LLH:
##  LLH:  201.2025    norm LLH:  5.294803 
##          mu       omega      alpha1       beta1 
## 206.3246895 313.3313489   0.9751937   0.1591545 
## 
## R-optimhess Difference Approximated Hessian Matrix:
##                   mu         omega        alpha1        beta1
## mu     -2.002073e-02  1.011283e-05   0.042939773   0.01328390
## omega   1.011283e-05 -3.062786e-05  -0.007652295  -0.02588192
## alpha1  4.293977e-02 -7.652295e-03 -11.882545271 -22.17270037
## beta1   1.328390e-02 -2.588192e-02 -22.172700367 -93.56097055
## attr(,"time")
## Time difference of 0.006392956 secs
## 
## --- END OF TRACE ---
## 
## 
## Time to Estimate Parameters:
##  Time difference of 0.03473091 secs
## Warning: Using formula(x) is deprecated when x is a character vector of length > 1.
##   Consider formula(paste(x, collapse = " ")) instead.
summary(fitGARCH)
## 
## Title:
##  GARCH Modelling 
## 
## Call:
##  garchFit(data = Warrests, cond.dist = "norm") 
## 
## Mean and Variance Equation:
##  data ~ garch(1, 1)
## <environment: 0x7fc0de4f8f10>
##  [data = Warrests]
## 
## Conditional Distribution:
##  norm 
## 
## Coefficient(s):
##        mu      omega     alpha1      beta1  
## 206.32469  313.33135    0.97519    0.15915  
## 
## Std. Errors:
##  based on Hessian 
## 
## Error Analysis:
##         Estimate  Std. Error  t value Pr(>|t|)    
## mu      206.3247      7.1103   29.018   <2e-16 ***
## omega   313.3313    207.9736    1.507   0.1319    
## alpha1    0.9752      0.3937    2.477   0.0132 *  
## beta1     0.1592      0.1462    1.088   0.2764    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Log Likelihood:
##  -201.2025    normalized:  -5.294803 
## 
## Description:
##  Wed Nov 25 22:28:31 2020 by user:  
## 
## 
## Standardised Residuals Tests:
##                                 Statistic p-Value     
##  Jarque-Bera Test   R    Chi^2  1.28726   0.5253819   
##  Shapiro-Wilk Test  R    W      0.962455  0.2279497   
##  Ljung-Box Test     R    Q(10)  49.65527  3.088306e-07
##  Ljung-Box Test     R    Q(15)  68.57874  7.991746e-09
##  Ljung-Box Test     R    Q(20)  111.2634  1.154632e-14
##  Ljung-Box Test     R^2  Q(10)  8.198077  0.6094959   
##  Ljung-Box Test     R^2  Q(15)  14.69119  0.4738815   
##  Ljung-Box Test     R^2  Q(20)  19.82084  0.4691862   
##  LM Arch Test       R    TR^2   13.07824  0.3633798   
## 
## Information Criterion Statistics:
##      AIC      BIC      SIC     HQIC 
## 10.80013 10.97251 10.78066 10.86146
fcstGARCH = predict(fitGARCH, n.ahead=6, plot=TRUE)

kable(cbind(ses =fcstses$mean, ets = fcstETS$mean,arima = fcstARIMA$mean,garch = fcstGARCH$meanForecast))
ses ets arima garch
147.5337 148.5345 109.65877 206.3247
147.5337 148.5345 103.60435 206.3247
147.5337 148.5345 69.36961 206.3247
147.5337 148.5345 63.72173 206.3247
147.5337 148.5345 91.15429 206.3247
147.5337 148.5345 27.37388 206.3247

GARCH model predicts the same crime rate at 206, ARIMA is predicting lower and lower crime rate, the other models predicts a much lower crime rate at 146 - 148. ARIMA model looks like having the best prediction results.