For this assignment, I picked the dataset “UAVS” from https://finance.yahoo.com/quote/UAVS/history?period1=1436918400&period2=1594771200&interval=1mo&filter=history&frequency=1mo

#Reading our dataset

#Summary of our dataset

str(eagle)
## 'data.frame':    60 obs. of  7 variables:
##  $ Date     : chr  "2015-08-01" "2015-09-01" "2015-10-01" "2015-11-01" ...
##  $ Open     : num  30.75 20 12.25 13.5 9.75 ...
##  $ High     : num  30.8 21.5 24.2 14.5 11.2 ...
##  $ Low      : num  20 11 11.5 7.5 5.25 5 4.25 4.5 5.5 6.25 ...
##  $ Close    : num  22 12.25 13.5 9.25 7.5 ...
##  $ Adj.Close: num  22 12.25 13.5 9.25 7.5 ...
##  $ Volume   : int  7500 19000 20400 11000 13100 10700 24100 68000 35300 30900 ...
head(eagle)
##         Date  Open  High   Low Close Adj.Close Volume
## 1 2015-08-01 30.75 30.75 20.00 22.00     22.00   7500
## 2 2015-09-01 20.00 21.50 11.00 12.25     12.25  19000
## 3 2015-10-01 12.25 24.25 11.50 13.50     13.50  20400
## 4 2015-11-01 13.50 14.50  7.50  9.25      9.25  11000
## 5 2015-12-01  9.75 11.25  5.25  7.50      7.50  13100
## 6 2016-01-01  7.50 14.75  5.00  6.25      6.25  10700
tail(eagle)
##          Date Open High  Low Close Adj.Close    Volume
## 55 2020-02-01 0.56 0.60 0.40  0.45      0.45   2791900
## 56 2020-03-01 0.43 0.63 0.19  0.41      0.41   5216300
## 57 2020-04-01 0.41 5.15 0.30  1.45      1.45 431181100
## 58 2020-05-01 1.38 1.72 1.00  1.19      1.19 202355300
## 59 2020-06-01 1.23 1.94 1.17  1.19      1.19 168693300
## 60 2020-07-01 1.19 2.75 1.14  2.56      2.56 232223000

#Creating our time series

eagle.ts = ts(eagle$Adj.Close, frequency = 12, start = c(2015,8))
autoplot(eagle.ts) +xlab("Year") + ylab("Adjusting Closing Price in $")

##P.L.F. Additive and Multiplicative Decomposition #Additive Decomposition

eagle.ts.AD = 
  decompose(eagle.ts, type = "additive") %>%
  autoplot() + 
  xlab("Year") + ylab("Adjusting Closing Price in $")
  ggtitle("Classical Multiplicative Decomposition of Monthly Adj. Closing Price in $")
## $title
## [1] "Classical Multiplicative Decomposition of Monthly Adj. Closing Price in $"
## 
## attr(,"class")
## [1] "labels"
  plot(eagle.ts.AD)

#Multiplicative Decomposition

eagle.ts.MD = 
  decompose(eagle.ts, type = "multiplicative") %>%
  autoplot() + 
  xlab("Year") + ylab("Adjusting Closing Price in $")
  ggtitle("Classical Multiplicative Decomposition of Monthly Adj. Closing Price in $")
## $title
## [1] "Classical Multiplicative Decomposition of Monthly Adj. Closing Price in $"
## 
## attr(,"class")
## [1] "labels"
  plot(eagle.ts.MD)

#We can clearly see a decreasing trend in the price of the stock

#Spliting our time series into training and testing

train.ts = window(eagle.ts, end=c(2020,6))
test.ts = window(eagle.ts,start=c(2015,8))

##Building 3 ETS models and displaying their results #ETS Model 1

M1.ETS = ets(train.ts, model = "ZZZ")
M1.ETS
## ETS(M,N,M) 
## 
## Call:
##  ets(y = train.ts, model = "ZZZ") 
## 
##   Smoothing parameters:
##     alpha = 0.8808 
##     gamma = 1e-04 
## 
##   Initial states:
##     l = 9.3913 
##     s = 0.9916 1.0016 1.0652 1.5135 0.7237 0.7324
##            0.942 0.7105 0.9809 0.9155 1.1069 1.3163
## 
##   sigma:  0.3421
## 
##      AIC     AICc      BIC 
## 244.7954 255.9582 275.9585

#ETS Model 2

M2.ETS = ets(train.ts, model = "ANN")
M2.ETS
## ETS(A,N,N) 
## 
## Call:
##  ets(y = train.ts, model = "ANN") 
## 
##   Smoothing parameters:
##     alpha = 0.6351 
## 
##   Initial states:
##     l = 18.3607 
## 
##   sigma:  2.2771
## 
##      AIC     AICc      BIC 
## 341.6450 342.0814 347.8776

#ETS Model 3

M3.ETS = ets(train.ts, model = "MNN")
M3.ETS
## ETS(M,N,N) 
## 
## Call:
##  ets(y = train.ts, model = "MNN") 
## 
##   Smoothing parameters:
##     alpha = 0.8649 
## 
##   Initial states:
##     l = 18.3765 
## 
##   sigma:  0.4318
## 
##      AIC     AICc      BIC 
## 263.7256 264.1619 269.9582
#As our results display, it appears that the ETS Model 1 is the best model among the three because its AIC,AICc, and BIC values are lower than the other 2.

#With this in mind, Model 1 should visualy do a better forecast than the other 2; Lets find out.

#Forecast from ETS Model 1

fcast.M1.ETS = forecast(M1.ETS,h=24)
plot(fcast.M1.ETS)
lines(test.ts, col="red")  
legend("topleft",lty=1,col=c("red","blue"),c("actual values","forecast"))

#Forecast from ETS Model 2

fcast.M2.ETS = forecast(M2.ETS,h=24)
plot(fcast.M1.ETS)
lines(test.ts, col="red")  
legend("topleft",lty=1,col=c("red","blue"),c("actual values","forecast"))

fcast.M3.ETS = forecast(M3.ETS,h=24)
plot(fcast.M1.ETS)
lines(test.ts, col="red")  
legend("topleft",lty=1,col=c("red","blue"),c("actual values","forecast"))

#Visualy speaking, all graphs look the same, thus if we only had the graph, it would be difficult to say, which ETS model is the best one. Fortunately, we can check each graph accuracy to get to the bottom of it.

#If I had to bet money on which model is the best one, I would pick the ETS Model 1 because it is the one with the lowest AIC,AICc, and BIC metrics.

##Determining the best model

acc.M1 = accuracy(fcast.M1.ETS, test.ts)
acc.M2 = accuracy(fcast.M2.ETS, test.ts)
acc.M3 = accuracy(fcast.M3.ETS, test.ts)

#Accuracy of ETS Model 1

acc.M1
##                      ME     RMSE      MAE       MPE     MAPE      MASE
## Training set -0.2421216 2.506833 1.393245 -11.84607 28.60512 0.4202715
## Test set      1.3932430 1.393243 1.393243  54.42356 54.42356 0.4202710
##                    ACF1
## Training set -0.2868135
## Test set             NA

#Accuracy of ETS Model 2

acc.M2
##                      ME     RMSE      MAE       MPE     MAPE      MASE
## Training set -0.4586398 2.238220 1.294273 -15.08024 27.26387 0.3904167
## Test set      1.3848219 1.384822 1.384822  54.09460 54.09460 0.4177307
##                    ACF1
## Training set -0.1326988
## Test set             NA

#Accuracy of ETS Model 3

acc.M3
##                      ME     RMSE      MAE       MPE     MAPE      MASE
## Training set -0.3367532 2.323516 1.232600 -11.13048 23.80895 0.3718132
## Test set      1.3678025 1.367802 1.367802  53.42979 53.42979 0.4125969
##                    ACF1
## Training set -0.3515247
## Test set             NA
#In hindsight, it appears that ETS Model 3 is the most accurate model when it comes to forecasting because its MAPE value is smaller than the other 2 models. It is quit surprising to me because I thought ETS Model 1 would have the lowest MAPE since it has the lowest AIC,AICc, and BIC.
# This begs the questions, "just how good is ETS Model 3?" and "where do the AIC.AICc, and BIC metrics fit into all of this ?