Go to Data Market (https://datamarket.com/data/list/?q=cat:ecc%20provider:tsdl (Links to an external site.)Links to an external site.) Pick a time series of interest to you. Build an auto.arima model as well as an ETS model. Which performed better? Now hold out 6 months of data for a test set and try to forecast using the ETS and the auto.arima. Which performs better on the hold-out set?
For the weeks discussion I choose do research Monthly Australian imports from Japan, calculated in thousands of dollars, from July 1965 to October 1993.
library(forecast)
## Warning: package 'forecast' was built under R version 3.4.2
## Warning in as.POSIXlt.POSIXct(Sys.time()): unknown timezone 'zone/tz/2018c.
## 1.0/zoneinfo/America/New_York'
library(xts)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(tseries)
library(readr)
imports <- read_csv("~/Desktop/imports.csv")
## Parsed with column specification:
## cols(
## Month = col_character(),
## `Monthly Australian imports from Japan: thousands of dollars. (Jul 65 from Oct 93)` = col_integer()
## )
Seems to be an upward trend with seasonality.
myts=ts(imports$`Monthly Australian imports from Japan: thousands of dollars. (Jul 65 from Oct 93)`,frequency=12,start=c(1965,7))
plot(myts, ylab="Imports (thousands of $)",main="Monthly Australian imports from Japan")
plot(decompose(myts))
train=imports[1:334,]
test=imports[335:340,]
imports.train=ts(train$`Monthly Australian imports from Japan: thousands of dollars. (Jul 65 from Oct 93)`,frequency=12,start=c(1965,7))
imports.test=ts(test$`Monthly Australian imports from Japan: thousands of dollars. (Jul 65 from Oct 93)`,frequency=12,start=c(1993,5))
For my ETS model I used a multiplicative Holt-Winters’ method with multiplicative errors.
fit1<-auto.arima(imports.train)
fit1
## Series: imports.train
## ARIMA(0,1,1)(0,0,1)[12] with drift
##
## Coefficients:
## ma1 sma1 drift
## -0.7021 0.4830 3048.450
## s.e. 0.0368 0.0538 1409.692
##
## sigma^2 estimated as 3.45e+09: log likelihood=-4129.53
## AIC=8267.07 AICc=8267.19 BIC=8282.3
fit2<-ets(imports.train, model="MAM")
fit2
## ETS(M,A,M)
##
## Call:
## ets(y = imports.train, model = "MAM")
##
## Smoothing parameters:
## alpha = 0.3231
## beta = 0.0061
## gamma = 1e-04
##
## Initial states:
## l = 22815.682
## b = 175.2428
## s=0.9791 0.9818 0.9201 0.9982 0.9188 1.0229
## 0.8857 1.0758 1.1094 0.9798 1.0703 1.058
##
## sigma: 0.1274
##
## AIC AICc BIC
## 8703.053 8704.989 8767.842
f.arima=forecast(fit1, h=6)
plot(f.arima, xlab= "Time", ylab= "Monthly Australian imports from Japan: thousands of dollars")
f.ets=forecast(fit2, h=6)
plot(f.ets, xlab= "Time", ylab= "Monthly Australian imports from Japan: thousands of dollars")
accuracy(f.ets, imports.test)
## ME RMSE MAE MPE MAPE MASE
## Training set 2850.611 55430.17 30936.30 0.06815244 9.441822 0.535346
## Test set -63085.106 102369.75 83945.57 -7.01738046 8.949804 1.452660
## ACF1 Theil's U
## Training set -0.08835074 NA
## Test set -0.32118180 0.4224622
accuracy(f.arima, imports.test)
## ME RMSE MAE MPE MAPE MASE
## Training set 55.04526 58382.98 35446.62 -6.5765860 13.987461 0.613396
## Test set 4518.56275 73583.88 67252.68 -0.3449261 6.922693 1.163793
## ACF1 Theil's U
## Training set -0.0373629 NA
## Test set -0.2720323 0.3623368
It looks that the ARIMA(0,1,1)(0,0,1)[12] with drift model is better than the ETS Holt-Winters’ method. It proved to more accurate in predicting Australian imports from Japan based on having lower bias and variance statistics.