Automatic Forecasting with R

Slides:



Advertisements
Similar presentations
Slide 1 DSCI 5340: Predictive Modeling and Business Forecasting Spring 2013 – Dr. Nick Evangelopoulos Lecture 7: Box-Jenkins Models – Part II (Ch. 9) Material.
Advertisements

Time Series Analysis Materials for this lecture Lecture 5 Lags.XLS Lecture 5 Stationarity.XLS Read Chapter 15 pages Read Chapter 16 Section 15.
Time Series Building 1. Model Identification
Time Series Analysis using SAS prepared by John Fahey (former Load Forecaster at NSPI) and Voytek Grus (former Sales and Revenue Forecaster at BC Gas Inc.)
1 Time Series Forecasting: The Case for the Single Source of Error State Space Model J. Keith Ord, Georgetown University Ralph D. Snyder, Monash University.
13 Introduction toTime-Series Analysis. What is in this Chapter? This chapter discusses –the basic time-series models: autoregressive (AR) and moving.
Moving Averages Ft(1) is average of last m observations
Forecasting JY Le Boudec 1. Contents 1.What is forecasting ? 2.Linear Regression 3.Avoiding Overfitting 4.Differencing 5.ARMA models 6.Sparse ARMA models.
Modeling Cycles By ARMA
Time Series Model Estimation Materials for this lecture Read Chapter 15 pages 30 to 37 Lecture 7 Time Series.XLS Lecture 7 Vector Autoregression.XLS.
1 Spreadsheet Modeling & Decision Analysis: A Practical Introduction to Management Science, 3e by Cliff Ragsdale.
Forecasting.
Session 10a. Decision Models -- Prof. Juran2 Overview Forecasting Methods Exponential Smoothing –Simple –Trend (Holt’s Method) –Seasonality (Winters’
Chapter 3 Forecasting McGraw-Hill/Irwin
CHAPTER 4 MOVING AVERAGES AND SMOOTHING METHODS (Page 107)
ARIMA Forecasting Lecture 7 and 8 - March 14-16, 2011
Forecasting McGraw-Hill/Irwin Copyright © 2012 by The McGraw-Hill Companies, Inc. All rights reserved.
Statistical Forecasting Models
Forecasting Purpose is to forecast, not to explain the historical pattern Models for forecasting may not make sense as a description for ”physical” beaviour.
Demand Planning: Forecasting and Demand Management
1 BABS 502 Moving Averages, Decomposition and Exponential Smoothing Revised March 11, 2011.
Winter’s Exponential smoothing
STAT 497 LECTURE NOTES 7 FORECASTING.
Demand Management and Forecasting
Time-Series Analysis and Forecasting – Part V To read at home.
1 Spreadsheet Modeling & Decision Analysis: A Practical Introduction to Management Science, 3e by Cliff Ragsdale.
Intervention models Something’s happened around t = 200.
1 Appendix B: A Primer of Time Series Forecasting Models B.1 A Primer of Time Series Forecasting Models.
Copyright © 2011 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Time Series Forecasting Chapter 16.
Time series data: each case represents a point in time. Each cell gives a value for each variable for each time period. Stationarity: Data are stationary.
Forecasting Models Decomposition and Exponential Smoothing.
Applied Forecasting ST3010 Michaelmas term 2015 Prof. Rozenn Dahyot Room 128 Lloyd Institute School of Computer Science and Statistics Trinity College.
PowerPoint presentation to accompany Chopra and Meindl Supply Chain Management, 5e 1-1 Copyright ©2013 Pearson Education, Inc. publishing as Prentice Hall.
Time Series Analysis and Forecasting
Forecasting February 26, Laws of Forecasting Three Laws of Forecasting –Forecasts are always wrong! –Detailed forecasts are worse than aggregate.
It’s About Time Mark Otto U. S. Fish and Wildlife Service.
Time-Series Forecasting Overview Moving Averages Exponential Smoothing Seasonality.
John G. Zhang, Ph.D. Harper College
Time Series Basics (2) Fin250f: Lecture 3.2 Fall 2005 Reading: Taylor, chapter , 3.9(skip 3.6.1)
Big Data at Home Depot KSU – Big Data Survey Course Steve Einbender Advanced Analytics Architect.
Lecture 12 Time Series Model Estimation
Time Series Analysis Lecture 11
Forecasting (prediction) limits Example Linear deterministic trend estimated by least-squares Note! The average of the numbers 1, 2, …, t is.
Forecasting Parameters of a firm (input, output and products)
1 BABS 502 Moving Averages, Decomposition and Exponential Smoothing Revised March 14, 2010.
The Box-Jenkins (ARIMA) Methodology
Seasonal ARIMA FPP Chapter 8.
CHAPTER 12 FORECASTING. THE CONCEPTS A prediction of future events used for planning purpose Supply chain success, resources planning, scheduling, capacity.
Times Series Forecasting and Index Numbers Chapter 16 Copyright © 2014 by The McGraw-Hill Companies, Inc. All rights reserved.McGraw-Hill/Irwin.
Managerial Decision Modeling 6 th edition Cliff T. Ragsdale.
Demand Management and Forecasting Chapter 11 Portions Copyright © 2010 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin.
Time series /Applied Forecasting 7005 Hilary term 2016 Prof. Rozenn Dahyot Room 128 Lloyd Institute School of Computer Science and Statistics Trinity College.
Lecture 12 Time Series Model Estimation Materials for lecture 12 Read Chapter 15 pages 30 to 37 Lecture 12 Time Series.XLSX Lecture 12 Vector Autoregression.XLSX.
Chapter 11 – With Woodruff Modications Demand Management and Forecasting Copyright © 2010 by The McGraw-Hill Companies, Inc. All rights reserved.McGraw-Hill/Irwin.
Predicting Future. Two Approaches to Predition n Extrapolation: Use past experiences for predicting future. One looks for patterns over time. n Predictive.
Welcome to MM305 Unit 5 Seminar Dr. Bob Forecasting.
Copyright © 2013, SAS Institute Inc. All rights reserved. SAS SOLUTION DE JOUR: SAS OTTAWA PLATFORM USER SOCIETY INTRODUCTION TO SAS FORECAST SERVER 26.
Energy Consumption Forecast Using JMP® Pro 11 Time Series Analysis
Supply Chain Management for Non Supply Chain Management Professionals
Lecture 12 Time Series Model Estimation
Forecasting Approaches to Forecasting:
Lecture 8 ARIMA Forecasting II
Forecasting.
Forecasting Time Series in R
Forecasting Methods ISAT /10/2018.
Stock Prediction with ARIMA
Forecasting - Introduction
Demand Management and Forecasting
Time Series Forecasting with SAS Forecast Server at NPPC
Presentation transcript:

Automatic Forecasting with R Andy Fisher andy@dfanalytics.com 12/31/2018 DF Analytics, Inc.

Agenda Forecasting in Supply Chain Management The R forecast package Additional considerations 12/31/2018 DF Analytics, Inc.

My Relevant Background Role in Professional Services at the SAS Institute as an Analytical Consultant focused on the implementation of SAS Forecast Server Role at Cisco Systems, first managing the application of SAS Forecast Server in supply chain consensus demand planning process, then as S&OP Manager, translating supply chain strategies into financial trade-offs 12/31/2018 DF Analytics, Inc.

Automatic Forecasting Explained Automatic forecasting relies on a computer to fit a proper set of models to every series and the computer picks the best one based on some sort of statistical test. Proper set of models is important. Proper is dependent on the demand patterns or time series properties An improper set of models can lead to lower forecast performance An improper statistic for model selection can lead to lower forecast performance Automatic forecasting is used in situations with more series than forecast analysts can typically handle Such as supply chain management 12/31/2018 DF Analytics, Inc.

Example: Forecast System in Supply Chain Planning Demand History Forecast System Demand Planning System Inventory Optimization Product level demand history provides input to forecasting system Statistical forecasting system provides baseline expectation of future demand Demand Planners demand plan with Stat forecast as baseline Expected sales not included in forecast are added by Demand Planners Once demand plan is finalized, component orders are determined through inventory optimization system In Supply Chain Management, a good forecast improves delivery times and reduces inventory holding cost 12/31/2018 DF Analytics, Inc.

Time Series Forecasting in R stats Relevant time series fitting functions in the Stats package arima: fit an ARIMA model to a univariate time series HoltWinters: computes Holt-Winters filtering of time series StructTS: fit a structural model for a time series by maximum likelihood lm: used to fit linear regression models Relevant forecasting functions in the Stats package predict.Arima: forecasts from models fitted by arima predict.HoltWinters: forecasts from models fitted by HoltWinters predict.StructTS: forecast from models fitted by StructTS predict.lm: predicted values based on linear object model 12/31/2018 DF Analytics, Inc.

Time Series Forecasting in forecast Package The R forecast package, authored by Rob Hyndman http://robjhyndman.com/software/forecast/ http://cran.r-project.org/web/packages/forecast/forecast.pdf Relevant fitting functions Arima: Fit ARIMA model to univariate time series (largely wrapper for stats package arima) auto.arima: Fit best ARIMA model to univariate time series ets: exponential smoothing state space model Croston: Forecasts for intermittent demand using Croston’s method Relevant forecasting functions forecast.Arima: Returns forecasts and other information for Arima and auto.arima fitted models forecast.ets: Returns forecasts and other information for univariate ets models forecast.StructTS: Returns forecasts and other information for univariate structural time series models 12/31/2018 DF Analytics, Inc.

auto.arima and ets Approach Automatically determine differencing needed for stationarity Then automatically estimate models using different AR and MA terms Forecast model is selected by AIC ets Based on the idea that exponential smoothing methods are optimal forecasts from innovations state space models The triplet (E,T,S) refers to 3 components: error, trend, seasonality ETS(M,Md,M) refers to a model with multiplicative errors, damped multiplicative trend, multiplicative seasonality Forecast model is selected by applying all relevant models, optimizing parameters, and selecting the best model by AIC auto.arima and ets algorithms explained in detail at: http://robjhyndman.com/papers/forecastpackage.pdf 12/31/2018 DF Analytics, Inc.

forecast Package auto.arima # load forecast package library(forecast) # forecast package ARIMA Inflationmodauto <- auto.arima(Inflationts) # view Inflationmodauto Inflationmodauto Series: Inflationts ARIMA(0,1,0) sigma^2 estimated as 3.188: log likelihood=-61.96 AIC=125.92 AICc=126.05 BIC=127.35 # forecast Inflationmodauto Inflationfcstauto <- forecast.Arima(Inflationmodauto, h=30) # view Inflationfcstauto Inflationfcstauto Point Forecast Lo 80 Hi 80 Lo 95 Hi 95 2012 2.565 0.2767618 4.853238 -0.9345584 6.064558 2013 2.565 -0.6710575 5.801058 -2.3841229 7.514123 2014 2.565 -1.3983449 6.528345 -3.4964129 8.626413 2015 2.565 -2.0114764 7.141476 -4.4341167 9.564117 12/31/2018 DF Analytics, Inc.

forecast Package ets Exponential Smoothing # load forecast package library(forecast) # forecast package ets Inflationets <- ets(Inflationts) # view Inflationets Inflationets ETS(M,Md,N) Call: ets(y = Inflationts) Smoothing parameters: alpha = 0.0051 beta = 0.0051 phi = 0.8762 Initial states: l = 14.2541 b = 0.7511 sigma: 0.4079 AIC AICc BIC 132.0158 134.3235 139.3445 # forecast ets forecastets <- forecast(Inflationets, h=30) 12/31/2018 DF Analytics, Inc.

auto.arima and ets Forecasts 12/31/2018 DF Analytics, Inc.

Other Relevant Features in forecast Package forecast package arima and exponential smoothing models can be manually specified, as well as automatically selected Accuracy: returns a set of accuracy summary measures of forecast accuracy ACF: auto-correlation function estimation seasonaldummy: returns matrices of seasonal dummies 12/31/2018 DF Analytics, Inc.

Additional Considerations Forecast package does not do automatic ARIMAX/transfer function specification This means lags for independent variables will need to be determined by hand See the ARIMAX model muddle, Rob Hyndman http://robjhyndman.com/researchtips/arimax/ Database for storage (RODBC, RMySQL, etc.) will be useful Some series perform better using hierarchical forecasting. Try hts package. For more flexible management of time series data, try zoo or xts package. 12/31/2018 DF Analytics, Inc.

Useful Resources An R Time Series Tutorial, R.H Shumway and D.S. Stoffer http://www.stat.pitt.edu/stoffer/tsa2/R_time_series_quick_fix.htm A Little Book of R for Time Series, Avril Coghlan http://a-little-book-of-r-for-time-series.readthedocs.org/en/latest/index.html R Data Import/Export, R Development Core Team http://cran.r-project.org/doc/manuals/R-data.pdf CRAN Task View: Time Series Analysis http://cran.r-project.org/web/views/TimeSeries.html CRAN Task View: Econometrics http://cran.r-project.org/web/views/Econometrics.html 12/31/2018 DF Analytics, Inc.