library(forecast)
## Warning: package 'forecast' was built under R version 3.5.3
library(readr)
## Warning: package 'readr' was built under R version 3.5.3
library(data.table)
## Warning: package 'data.table' was built under R version 3.5.3
library(fpp2)
## Warning: package 'fpp2' was built under R version 3.5.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.5.3
## Loading required package: fma
## Warning: package 'fma' was built under R version 3.5.3
## Loading required package: expsmooth
## Warning: package 'expsmooth' was built under R version 3.5.3
UNRATENSA <- read.csv("C:/Users/Demetri/Google Drive/Grad School/Forecasting and Predictive Analytics/UNRATENSA.csv")
unemp = ts(UNRATENSA[,2], start = c(2004, 6), end = c(2019, 6), frequency = 12)
train = window(unemp, end = c(2018, 12))
test = window(unemp, start = c(2019, 1))
arimafc <- train %>% auto.arima() %>% forecast(h=6)
etsfc <- train %>% ets() %>% forecast(h=6)
autoplot(arimafc)
autoplot(etsfc)
arimamse = mean((test-arimafc$mean)^2)
etsmse = mean((test-etsfc$mean)^2)
c(arimamse, etsmse)
## [1] 0.01969911 0.04393041
summary(arimafc)
##
## Forecast method: ARIMA(0,1,1)(0,1,1)[12]
##
## Model Information:
## Series: .
## ARIMA(0,1,1)(0,1,1)[12]
##
## Coefficients:
## ma1 sma1
## 0.1463 -0.8377
## s.e. 0.0655 0.0951
##
## sigma^2 estimated as 0.03576: log likelihood=33.72
## AIC=-61.45 AICc=-61.29 BIC=-52.18
##
## Error measures:
## ME RMSE MAE MPE MAPE
## Training set -0.00597964 0.1808117 0.1339804 -0.02638067 2.185413
## MASE ACF1
## Training set 0.1528258 0.03713663
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Jan 2019 4.377625 4.135032 4.620219 4.006611 4.748640
## Feb 2019 4.241740 3.872719 4.610761 3.677371 4.806109
## Mar 2019 3.994060 3.531998 4.456123 3.287397 4.700724
## Apr 2019 3.491407 2.952123 4.030691 2.666644 4.316170
## May 2019 3.536321 2.929565 4.143076 2.608369 4.464273
## Jun 2019 3.983130 3.315690 4.650570 2.962368 5.003891
summary(etsfc)
##
## Forecast method: ETS(M,Ad,A)
##
## Model Information:
## ETS(M,Ad,A)
##
## Call:
## ets(y = .)
##
## Smoothing parameters:
## alpha = 0.6538
## beta = 0.1762
## gamma = 1e-04
## phi = 0.9297
##
## Initial states:
## l = 5.425
## b = 0.0309
## s = -0.2411 -0.3052 0.1278 0.3642 0.4513 -0.2043
## -0.2662 -0.3131 -0.1874 0.0712 0.2928 0.2101
##
## sigma: 0.027
##
## AIC AICc BIC
## 282.7158 287.1004 339.6819
##
## Error measures:
## ME RMSE MAE MPE MAPE
## Training set -0.003573483 0.1631107 0.1262342 -0.03407441 2.048141
## MASE ACF1
## Training set 0.1439901 0.1999058
##
## Forecasts:
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## Jan 2019 4.311199 4.162051 4.460347 4.083096 4.539301
## Feb 2019 4.231540 4.040980 4.422100 3.940104 4.522976
## Mar 2019 4.002166 3.768803 4.235529 3.645269 4.359063
## Apr 2019 3.575557 3.300177 3.850938 3.154399 3.996715
## May 2019 3.645786 3.321498 3.970074 3.149831 4.141742
## Jun 2019 4.102677 3.723614 4.481740 3.522950 4.682404
. . .