** This week I chose to create ARIMA and ETS model comparisons using the qcement dataset found in the fpp2 package.This dataset includes total quarterly production of Portland cement in Australia (in millions of tonnes) from 1956:Q1 to 2014:Q1.**

library(fpp2)
## Loading required package: ggplot2
## Loading required package: forecast
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## Loading required package: fma
## Loading required package: expsmooth
library(forecast)
library(ggplot2)
DATA
str(qcement)
##  Time-Series [1:233] from 1956 to 2014: 0.465 0.532 0.561 0.57 0.529 0.604 0.603 0.582 0.554 0.62 ...
head(qcement)
##       Qtr1  Qtr2  Qtr3  Qtr4
## 1956 0.465 0.532 0.561 0.570
## 1957 0.529 0.604
tail(qcement)
##       Qtr1  Qtr2  Qtr3  Qtr4
## 2012                   2.503
## 2013 2.049 2.528 2.637 2.565
## 2014 2.229
summary(qcement)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.465   1.101   1.450   1.482   1.861   2.637
Splitting Data set
cement <- window(qcement,start=1998)
train <- window(cement,end = c(2007,4))
Auto-ARIMA Model 
Model1 <- auto.arima(train)
Model1
## Series: train 
## ARIMA(1,0,0)(0,1,1)[4] 
## 
## Coefficients:
##          ar1     sma1
##       0.8859  -0.8000
## s.e.  0.2201   0.4038
## 
## sigma^2 estimated as 0.01727:  log likelihood=20.89
## AIC=-35.79   AICc=-35.04   BIC=-31.04
checkresiduals(Model1)

## 
##  Ljung-Box test
## 
## data:  Residuals from ARIMA(1,0,0)(0,1,1)[4]
## Q* = 8.4029, df = 6, p-value = 0.21
## 
## Model df: 2.   Total lags used: 8
ETS MODEL (using auto-selection)
Model2 <-ets(train,model = "ZZZ")
summary(Model2) #A.N.A model was chosen 
## ETS(A,N,A) 
## 
## Call:
##  ets(y = train, model = "ZZZ") 
## 
##   Smoothing parameters:
##     alpha = 0.7281 
##     gamma = 1e-04 
## 
##   Initial states:
##     l = 1.8651 
##     s = 0.0378 0.0862 0.0494 -0.1734
## 
##   sigma:  0.1212
## 
##        AIC       AICc        BIC 
## -13.771023 -10.271023  -1.948867 
## 
## Training set error measures:
##                      ME      RMSE        MAE       MPE     MAPE      MASE
## Training set 0.02160159 0.1117403 0.08655878 0.8235465 4.268454 0.5821252
##                     ACF1
## Training set -0.02449955
checkresiduals(Model2)

## 
##  Ljung-Box test
## 
## data:  Residuals from ETS(A,N,A)
## Q* = 7.5076, df = 3, p-value = 0.05736
## 
## Model df: 6.   Total lags used: 9
autoplot(Model2)

Forecasting and Model accuracy
Model1.acc <- Model1 %>% forecast(h=4*(2013-2007)+1)
accuracy(Model1.acc)
##                      ME      RMSE        MAE       MPE     MAPE      MASE
## Training set 0.02329166 0.1211599 0.08869697 0.8941718 4.314886 0.5965049
##                    ACF1
## Training set -0.1862252
Model2.acc <- Model2 %>% forecast(h=4*(2013-2007)+1)
accuracy(Model2.acc)
##                      ME      RMSE        MAE       MPE     MAPE      MASE
## Training set 0.02160159 0.1117403 0.08655878 0.8235465 4.268454 0.5821252
##                     ACF1
## Training set -0.02449955
As we can see, the ARIMA model seems to be a much better model than the ETS model generated.The ETS model seems to have better forecasting accuracy-explained by the ME and RSME.
Forecasting 6 months out, using the A.N.A model selected
Model2.fc6 <- forecast(Model2,h=6)
accuracy(Model2.fc6,cement)
##                       ME      RMSE        MAE        MPE     MAPE      MASE
## Training set  0.02160159 0.1117403 0.08655878  0.8235465 4.268454 0.5821252
## Test set     -0.16538511 0.2311786 0.18069573 -7.8718129 8.461851 1.2152151
##                     ACF1 Theil's U
## Training set -0.02449955        NA
## Test set      0.52623851 0.9101994
plot(Model2.fc6)