# Exploring forecast

Let’s examine some of the functions inside for forecast

Michael DeWitt https://michaeldewittjr.com
07-07-2018

Time series forecasting is interesting. I want to write more, but not right now. I’m just going to lay out a few functions for explanation later.

``````
library(fpp2)
library(purrr)
library(dplyr)``````

I am going to test a few different methods:

• Mean forecasting

• Random Walk (last value is forecast with an addition)

• Seasonal Naive (last seasons value is next guess)

• Naive (Previous value is forecast)

``````
beer2 <- window(ausbeer, start= 1992, end = c(2007,4))

beer_fit1 <- meanf(beer2, h=10)
beer_fit2 <- rwf(beer2, h=10)
beer_fit3 <- snaive(beer2, h=10)
beer_fit4 <- naive(beer2, h=10)``````

Let’s see how we did on the forecast.

``````
beer3 <- window(ausbeer, start =2008)

models <- list(mean_forecast = beer_fit1, rand_walk = beer_fit2, seasonal_naive = beer_fit3,
naive = beer_fit4)
map(models, accuracy, beer3)``````
``````
\$mean_forecast
ME     RMSE      MAE        MPE     MAPE     MASE
Training set   0.000 43.62858 35.23438 -0.9365102 7.886776 2.463942
Test set     -13.775 38.44724 34.82500 -3.9698659 8.283390 2.435315
ACF1 Theil's U
Training set -0.10915105        NA
Test set     -0.06905715  0.801254

\$rand_walk
ME     RMSE      MAE         MPE     MAPE
Training set   0.4761905 65.31511 54.73016  -0.9162496 12.16415
Test set     -51.4000000 62.69290 57.40000 -12.9549160 14.18442
MASE        ACF1 Theil's U
Training set 3.827284 -0.24098292        NA
Test set     4.013986 -0.06905715  1.254009

\$seasonal_naive
ME     RMSE  MAE        MPE     MAPE      MASE
Training set -2.133333 16.78193 14.3 -0.5537713 3.313685 1.0000000
Test set      5.200000 14.31084 13.4  1.1475536 3.168503 0.9370629
ACF1 Theil's U
Training set -0.2876333        NA
Test set      0.1318407  0.298728

\$naive
ME     RMSE      MAE         MPE     MAPE
Training set   0.4761905 65.31511 54.73016  -0.9162496 12.16415
Test set     -51.4000000 62.69290 57.40000 -12.9549160 14.18442
MASE        ACF1 Theil's U
Training set 3.827284 -0.24098292        NA
Test set     4.013986 -0.06905715  1.254009``````

Seasonal Naive looks like it won!

### Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

### Citation

`DeWitt (2018, July 7). Michael DeWitt: Exploring forecast. Retrieved from https://michaeldewittjr.com/dewitt_blog/posts/2018-07-08-exploring-forecast/`
```@misc{dewitt2018exploring,