+ - 0:00:00
Notes for current slide
Notes for next slide

Forecasting and the Tidyverse

Rusershamburg - #rughh

Janko Thyson & Henning Bumann

05/16/2017

1 / 23

Let's talk about Forecasting!

  • Time Series data is everywhere! (especially in Business Settings)
  • Forecasting ≈ Zeitreihenanalyse + Invariance Hypothesis
  • Forecasting for S&OP-Planning
  • Classical Stuff:ETS, Arima, Decompositions

►► Robust, automatic forecasting is essential in practice!

2 / 23

Forecasting-Tools in R?

A great introduction

3 / 23

How do we use R in our company-job? For Prototyping. (For Small Companies, who don't yet want to buy our tool or to try new state-of-the-art-techniques)

Application: Predicting Gas Prices

4 / 23

it's a common understanding in the forecast-community, that you cannot forecast the oil-price trend.

5 / 23

Data-Exploration 1

  • Trend
  • Seasonality
Gas Prices over time
6 / 23
  • ACF und PACF erwähnen?
  • wann benötigt man Differencing?

Data-Exploration 3

8 / 23

Data-Exploration 4

9 / 23

Welcome to the tidyverse!

10 / 23
11 / 23

Nesting a dataframe*

ets.models <- ets.params %>%
# Add in the training set and the modelling function.
mutate(fn = replicate(forecast::ets, n = n()),
train = replicate(list(train), n = n())) %>%
# Create a "param" column to pass to `fn`.
mutate(params = purrr::transpose(list(
"y" = train, "model" = model, "damped" = damped
))) %>%
select(kind, desc, train, fn, params)
#> # A tibble: 2 x 5
#> kind desc train fn params
#> <chr> <chr> <list> <list> <list>
#> 1 ETS (M,N,M) <S3: xts> <fun> <list [3]>
#> 2 ETS (M,N,N) <S3: xts> <fun> <list [3]>
12 / 23

Fitting many models

forecast_all <- models_all %>%
mutate(fit = purrr::invoke_map(fn, params),
forecast = map(fit, forecast::forecast, h = h))
#> # A tibble: 6 x 8
#> kind desc model fn params train
#> <chr> <chr> <chr> <list> <list> <list>
#> 1 naive Naive default <fun> <list [2]> <NULL>
#> 2 snaive Seasonal Naive default <fun> <list [2]> <NULL>
#> 3 ETS (M,N,M) <NA> <fun> <list [3]> <S3: xts>
#> 4 ETS (M,N,N) <NA> <fun> <list [3]> <S3: xts>
#> 5 ARIMA auto.arima <NA> <fun> <list [1]> <S3: xts>
#> 6 nnetar Neuro default <fun> <list [1]> <NULL>
#> # ... with 2 more variables: fit <list>, forecast <list>
13 / 23

Model Evaluation 1👌

forecast_all %>%
mutate(test = replicate(list(test), n = n()),
glance = map2(forecast, test, broom::glance))
#> # A tibble: 6 x 8
#> kind desc is_rmse oos_rmse is_mae oos_mae is_mape
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 snaive Seasonal Naive 16.94010 19.35697 10.655327 15.10381 0.9483623
#> 2 ETS (M,N,M) 10.60398 21.10344 6.787350 17.43475 0.5934255
#> 3 nnetar Neuro 8.93484 35.58820 5.133682 29.83273 0.4562150
#> 4 ARIMA auto.arima 13.69798 58.15478 7.037829 45.87266 0.6229313
#> 5 ETS (M,N,N) 20.71179 70.56093 8.197112 57.80277 0.7243085
#> 6 naive Naive 20.71209 70.56093 8.178921 57.80277 0.7227123
#> # ... with 1 more variables: oos_mape <dbl>
14 / 23

Model Evaluation 2

15 / 23
16 / 23

Summary/ Discussion?

  • What potential does this appoach have?
  • What else could be done this way?

  • How good is R as a forecasting tool? What is good about it? Where are challenges?

17 / 23

good: super flexible, a lot of methods, tidyverse!! ;) challenges: ts-objects, runtime, learning-curve

Forecasting challenges in practice

  • many timeseries
  • intermittend demand
  • forecast value add-analysis
  • error measures ("Zerrspiegel")

  • "Once you have selected the right model, forecasting becomes easy!" (Prof. Stoffer)

18 / 23

What else is out there?

Methods

People

19 / 23

Thank you for your attention!

Slides and code can be found on github.com/henningsway/tidyforecasting.

20 / 23

Backup

21 / 23

Data Science @ Iqast

Janko Thyson

Henning Bumann

23 / 23
  • Fotos sollten einheitlicher sein

Let's talk about Forecasting!

  • Time Series data is everywhere! (especially in Business Settings)
  • Forecasting ≈ Zeitreihenanalyse + Invariance Hypothesis
  • Forecasting for S&OP-Planning
  • Classical Stuff:ETS, Arima, Decompositions

►► Robust, automatic forecasting is essential in practice!

2 / 23
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow