1 of 40

Forecasting with

Time Series and R

Jake Lyman

Thursday, March 12, 2020

2 of 40

About me

  • Just like you, I LOVE what data can do
  • Degree in Economics and Analytics
  • From Southern Utah and grateful for the outdoors

Contact info

  • Slack: Jake Lyman
  • Linkedin: linkedin.com/in/jacobwlyman

3 of 40

What to expect?

  • Overview/Review of forecasting and Time Series principles
  • How to approach a time series problem
  • How to apply the BSTS package in R, along with an example of a current use-case
  • Q&A

4 of 40

Time Series / Forecasting Principles

5 of 40

Is there seasonality?

6 of 40

7 of 40

1

3

2

8 of 40

9 of 40

Two free resources I would highly recommend:

  • Forecasting:

Principles and Practice

  • Introductory Econometrics:

A Modern Approach

10 of 40

How to approach a time series problem?

11 of 40

Steps

  1. Conceptualize what the actual problem is that you are solving
  2. Visualize and question your data
  3. Establish a validation process
  4. Build/iterate model(s)
  5. Evaluate results
  6. Make final predictions

12 of 40

13 of 40

14 of 40

15 of 40

16 of 40

17 of 40

18 of 40

How can I apply a BSTS model?

19 of 40

Bayesian Structural Time Series

  • Structural time series models are set up in terms of components, such as trends, seasons, cycles, and explanatory variables. They can be used not only for forecasting but also for providing a description of the main features of the series of data.

  • The bsts package is a tool for fitting “Bayesian structural time series” models. The package uses Bayesian posterior sampling, while the underlying backbone of bsts is structural time series.

  • The bsts package uses Markov Chain Monte Carlo (MCMC) simulation to sample from the posterior distribution of a time series model when making predictions. Model averaging is then used to combine these simulation results to come to the average predicted value of each prediction.

20 of 40

Bayesian Structural Time Series

  • The bsts package is flexible and efficient enough that it can be used without having to deeply dive into the underlying Bayesian computation.

  • With the bsts package, users can choose their model structure based on whether short or long term predictions are needed, whether the data contains seasonal effects, and whether and how regressors are to be included.

  • Users can assemble these structural components like Legos to build a model that addresses their use-case. Once these components are connected, the algorithm is generated automatically, allowing the quick prototyping of various iterations.

21 of 40

Bayesian Structural Time Series

Trend

  • AddLocalLevel()
  • AddLocalLinearTrend()
  • AddsemiLocalLinearTrend()
  • AddAr()
  • AddAutoAr()
  • AddStudentLocalLinearTrend()
  • AddGeneralizedLocalLinearTrend()

Seasonality

  • AddTrig()
  • AddSeasonal()
  • AddNamedHolidays()
  • AddFixedDateHoliday()
  • AddNthWeekdayInMonthHoliday()
  • AddLastWeekdayInMonthHoliday()

Regressors

22 of 40

23 of 40

24 of 40

25 of 40

Mean

26 of 40

27 of 40

28 of 40

29 of 40

30 of 40

31 of 40

32 of 40

33 of 40

34 of 40

35 of 40

36 of 40

Resources

37 of 40

Q & A

38 of 40

Contact info

  • Slack: Jake Lyman
  • Linkedin: linkedin.com/in/jacobwlyman

39 of 40

THANK YOU

40 of 40