I choose to use the gasoline dataset in fpp2.
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
summary(gasoline)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 6.321 8.049 8.713 8.553 9.121 9.815
str(gasoline)
## Time-Series [1:1355] from 1991 to 2017: 6.62 6.43 6.58 7.22 6.88 ...
autoplot(gasoline)
gas.nn<-nnetar(gasoline,lambda=NULL)
gas.nn
## Series: gasoline
## Model: NNAR(11,1,6)[52]
## Call: nnetar(y = gasoline, lambda = NULL)
##
## Average of 20 networks, each of which is
## a 12-6-1 network with 85 weights
## options were - linear output units
##
## sigma^2 estimated as 0.05376
gas.fc<-gas.nn%>%forecast(h=24)
autoplot(gas.fc)
?gasoline
Seen as data is weekly, I will use 52 weeks to get a better forecast.
gas.fc<-gas.nn%>%forecast(h=52)
autoplot(gas.fc)
gas.fc<-gas.nn%>%forecast(h=104)
autoplot(gas.fc)
accuracy(gas.fc)
## ME RMSE MAE MPE MAPE MASE
## Training set 0.0008387389 0.2318627 0.1793097 -0.07735182 2.135956 0.6222515
## ACF1
## Training set -0.02809231
gas.arima<-auto.arima(gas)
gas.arima.fc<-forecast(gas.arima,h=104)
autoplot(gas.arima.fc)
accuracy(gas.arima.fc)
## ME RMSE MAE MPE MAPE MASE
## Training set 27.72258 1579.457 893.4503 0.2722739 3.900232 0.4789312
## ACF1
## Training set 0.002271287
autoplot(gas.arima.fc)+
autolayer(gas.fc)
gas.fc1<-gas.nn%>%forecast(h=26)
autoplot(gas.fc1)
gas.arima1<-auto.arima(gas)
gas.arima.fc1<-forecast(gas.arima1,h=26)
autoplot(gas.arima.fc1)
accuracy(gas.arima.fc1)
## ME RMSE MAE MPE MAPE MASE
## Training set 27.72258 1579.457 893.4503 0.2722739 3.900232 0.4789312
## ACF1
## Training set 0.002271287
accuracy(gas.fc1)
## ME RMSE MAE MPE MAPE MASE
## Training set 0.0008387389 0.2318627 0.1793097 -0.07735182 2.135956 0.6222515
## ACF1
## Training set -0.02809231
autoplot(gasoline)+
autolayer(gas.arima.fc1)+
autolayer(gas.fc1)
My RMSE is vastly different. WIth the Neural Net producing very small values for the performance metrics. Even though the forecasts seem to fail the eyeball test for the neural nets. I tried 26 weeks and 2 years. In both scenarios the Neural net is better, but that doesn’t make sense.