Forecasting using R. Rob J Hyndman. 1.3 Seasonality and trends. Forecasting using R 1

Similar documents
Rob J Hyndman. Forecasting using. 3. Autocorrelation and seasonality OTexts.com/fpp/2/ OTexts.com/fpp/6/1. Forecasting using R 1

GAMINGRE 8/1/ of 7

Time Series Analysis

Determine the trend for time series data

Introduction to Forecasting

SYSTEM BRIEF DAILY SUMMARY

STATISTICAL FORECASTING and SEASONALITY (M. E. Ippolito; )

BUSI 460 Suggested Answers to Selected Review and Discussion Questions Lesson 7

SYSTEM BRIEF DAILY SUMMARY

Forecasting: principles and practice. Rob J Hyndman 3.2 Forecasting with multiple seasonality

REPORT ON LABOUR FORECASTING FOR CONSTRUCTION

Computing & Telecommunications Services Monthly Report January CaTS Help Desk. Wright State University (937)

Computing & Telecommunications Services

DAILY QUESTIONS 28 TH JUNE 18 REASONING - CALENDAR

Serie temporali: analisi e decomposizione

Technical note on seasonal adjustment for M0

Multiple Regression Analysis

Forecasting: principles and practice 1

ENGINE SERIAL NUMBERS

Euro-indicators Working Group

Annual Average NYMEX Strip Comparison 7/03/2017

Technical note on seasonal adjustment for Capital goods imports

A look into the factor model black box Publication lags and the role of hard and soft data in forecasting GDP

Time series and Forecasting

Approximating Fixed-Horizon Forecasts Using Fixed-Event Forecasts

TIGER: Tracking Indexes for the Global Economic Recovery By Eswar Prasad, Karim Foda, and Ethan Wu

Salem Economic Outlook

Lecture Prepared By: Mohammad Kamrul Arefin Lecturer, School of Business, North South University

Suan Sunandha Rajabhat University

Average 175, , , , , , ,046 YTD Total 1,098,649 1,509,593 1,868,795 1,418, ,169 1,977,225 2,065,321

Average 175, , , , , , ,940 YTD Total 944,460 1,284,944 1,635,177 1,183, ,954 1,744,134 1,565,640

Time Series and Forecasting Using R

Forecasting the Canadian Dollar Exchange Rate Wissam Saleh & Pablo Navarro

CWV Review London Weather Station Move

Forecasting using R. Rob J Hyndman. 2.3 Stationarity and differencing. Forecasting using R 1

Winter Season Resource Adequacy Analysis Status Report

Sluggish Economy Puts Pinch on Manufacturing Technology Orders

Climatography of the United States No

Jayalath Ekanayake Jonas Tappolet Harald Gall Abraham Bernstein. Time variance and defect prediction in software projects: additional figures

Forecasting. Copyright 2015 Pearson Education, Inc.

Design of a Weather-Normalization Forecasting Model

Monthly Trading Report July 2018

TIGER: Tracking Indexes for the Global Economic Recovery By Eswar Prasad and Karim Foda

Global climate predictions: forecast drift and bias adjustment issues

2016 Year-End Benchmark Oil and Gas Prices (Average of Previous 12 months First-Day-of-the Month [FDOM] Prices)

FORECASTING USING R. Dynamic regression. Rob Hyndman Author, forecast

Mr. XYZ. Stock Market Trading and Investment Astrology Report. Report Duration: 12 months. Type: Both Stocks and Option. Date: Apr 12, 2011

Multivariate Regression Model Results

EXAMINATIONS OF THE ROYAL STATISTICAL SOCIETY

Time Series and Forecasting

Short-term forecasts of GDP from dynamic factor models

In Centre, Online Classroom Live and Online Classroom Programme Prices

Table 01A. End of Period End of Period End of Period Period Average Period Average Period Average

Cost of Inflow Forecast Uncertainty for Day Ahead Hydropower Production Scheduling

Monthly Trading Report Trading Date: Dec Monthly Trading Report December 2017

NSP Electric - Minnesota Annual Report Peak Demand and Annual Electric Consumption Forecast

YEAR 10 GENERAL MATHEMATICS 2017 STRAND: BIVARIATE DATA PART II CHAPTER 12 RESIDUAL ANALYSIS, LINEARITY AND TIME SERIES

Forecasting using R. Rob J Hyndman. 2.4 Non-seasonal ARIMA models. Forecasting using R 1

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

To understand the behavior of NR prices across key markets, during , with focus on:

Time Series and Forecasting

ISO Lead Auditor Lean Six Sigma PMP Business Process Improvement Enterprise Risk Management IT Sales Training

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

peak half-hourly New South Wales

Climatography of the United States No

= observed volume on day l for bin j = base volume in jth bin, and = residual error, assumed independent with mean zero.

UNCLASSIFIED. Environment, Safety and Health (ESH) Report

Climatography of the United States No

Decision 411: Class 3

Lecture Prepared By: Mohammad Kamrul Arefin Lecturer, School of Business, North South University

Long-term Water Quality Monitoring in Estero Bay

Climatography of the United States No

Public Library Use and Economic Hard Times: Analysis of Recent Data

Variability and trends in daily minimum and maximum temperatures and in diurnal temperature range in Lithuania, Latvia and Estonia

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Forecasting: Methods and Applications

Decision 411: Class 3

Summary of Seasonal Normal Review Investigations CWV Review

Chapter 3. Regression-Based Models for Developing Commercial Demand Characteristics Investigation

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Climatography of the United States No

Nonparametric time series forecasting with dynamic updating

ISO Lead Auditor Lean Six Sigma PMP Business Process Improvement Enterprise Risk Management IT Sales Training

Transcription:

Forecasting using R Rob J Hyndman 1.3 Seasonality and trends Forecasting using R 1

Outline 1 Time series components 2 STL decomposition 3 Forecasting and decomposition 4 Lab session 5 Forecasting using R Time series components 2

Time series patterns Trend pattern exists when there is a long-term increase or decrease in the data. Seasonal pattern exists when a series is influenced by seasonal factors (e.g., the quarter of the year, the month, or day of the week). Cyclic pattern exists when data exhibit rises and falls that are not of fixed period (duration usually of at least 2 years). Forecasting using R Time series components 3

Time series components Differences between seasonal and cyclic patterns: seasonal pattern constant length; cyclic pattern variable length average length of cycle longer than length of seasonal pattern magnitude of cycle more variable than magnitude of seasonal pattern Forecasting using R Time series components 4

Time series patterns Sales of new one family houses, USA 80 Total sales 60 40 1975 1980 1985 1990 1995 Year Forecasting using R Time series components 5

Time series patterns US Treasury Bill Contracts 90 price 88 86 0 20 40 60 80 100 Day Forecasting using R Time series components 6

Time series patterns 16000 Australian monthly electricity production 12000 GWh 8000 4000 1960 1970 1980 1990 Year Forecasting using R Time series components 7

Time series patterns Daily change in Dow Jones Index 50 0 50 100 0 50 100 150 200 250 300 Day Forecasting using R Time series components 8

Time series decomposition Y t = f(s t, T t, E t ) where Y t = data at period t S t = seasonal component at period t T t = trend-cycle component at period t E t = remainder (or irregular or error) component at period t Additive decomposition: Y t = S t + T t + E t. Multiplicative decomposition: Y t = S t T t E t. Forecasting using R Time series components 9

Time series decomposition Y t = f(s t, T t, E t ) where Y t = data at period t S t = seasonal component at period t T t = trend-cycle component at period t E t = remainder (or irregular or error) component at period t Additive decomposition: Y t = S t + T t + E t. Multiplicative decomposition: Y t = S t T t E t. Forecasting using R Time series components 9

Time series decomposition Y t = f(s t, T t, E t ) where Y t = data at period t S t = seasonal component at period t T t = trend-cycle component at period t E t = remainder (or irregular or error) component at period t Additive decomposition: Y t = S t + T t + E t. Multiplicative decomposition: Y t = S t T t E t. Forecasting using R Time series components 9

Time series decomposition Additive model appropriate if magnitude of seasonal fluctuations does not vary with level. If seasonal are proportional to level of series, then multiplicative model appropriate. Multiplicative decomposition more prevalent with economic series Alternative: use a Box-Cox transformation, and then use additive decomposition. Logs turn multiplicative relationship into an additive relationship: Y t = S t T t E t log Y t = log S t + log T t + log E t. Forecasting using R Time series components 10

Euro electrical equipment Electrical equipment manufacturing (Euro area) 120 New orders index 100 80 series Data Trend 60 2000 2005 2010 Forecasting using R Time series components 11

Euro electrical equipment 120 remainder trend seasonal data 100 80 60 10 0 10 20 110 100 90 80 4 0 4 8 2000 2005 2010 Time Forecasting using R Time series components 12

Euro electrical equipment 10 Seasonal 0 10 20 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Month Forecasting using R Time series components 13

Seasonal adjustment Useful by-product of decomposition: an easy way to calculate seasonally adjusted data. Additive decomposition: seasonally adjusted data given by Y t S t = T t + E t Multiplicative decomposition: seasonally adjusted data given by Y t /S t = T t E t Forecasting using R Time series components 14

Euro electrical equipment Electrical equipment manufacturing 120 New orders index 100 80 series Data SeasAdjust 60 2000 2005 2010 Forecasting using R Time series components 15

Seasonal adjustment We use estimates of S based on past values to seasonally adjust a current value. Seasonally adjusted series reflect remainders as well as trend. Therefore they are not smooth and downturns or upturns can be misleading. It is better to use the trend-cycle component to look for turning points. Forecasting using R Time series components 16

History of time series decomposition Classical method originated in 1920s. Census II method introduced in 1957. Basis for modern X-12-ARIMA method. STL method introduced in 1983 TRAMO/SEATS introduced in 1990s. Forecasting using R Time series components 17

Outline 1 Time series components 2 STL decomposition 3 Forecasting and decomposition 4 Lab session 5 Forecasting using R STL decomposition 18

STL decomposition STL: Seasonal and Trend decomposition using Loess, Very versatile and robust. Unlike X-12-ARIMA, STL will handle any type of seasonality. Seasonal component allowed to change over time, and rate of change controlled by user. Smoothness of trend-cycle also controlled by user. Robust to outliers Not trading day or calendar adjustments. Only additive. Forecasting using R STL decomposition 19

Euro electrical equipment library(magrittr) elecequip %>% stl(s.window=5) %>% autoplot trend seasonal data 120 100 80 60 10 0 10 20 110 100 90 80 remainder 4 0 4 8 2000 2005 2010 Forecasting using R Time STL decomposition 20

Euro electrical equipment elecequip %>% stl(t.window=15, s.window='periodic', robust=true) %>% autoplot seasonal data 120 100 80 60 10 0 10 remainder trend 110 100 90 80 10 5 0 5 2000 2005 2010 Forecasting using R Time STL decomposition 21

STL decomposition in R t.window controls wiggliness of trend component. s.window controls variation on seasonal component. Forecasting using R STL decomposition 22

Outline 1 Time series components 2 STL decomposition 3 Forecasting and decomposition 4 Lab session 5 Forecasting using R Forecasting and decomposition 23

Forecasting and decomposition Forecast seasonal component by repeating the last year Forecast seasonally adjusted data using non-seasonal time series method. E.g., Holt s method next topic Random walk with drift model Combine forecasts of seasonal component with forecasts of seasonally adjusted data to get forecasts of original data. Sometimes a decomposition is useful just for understanding the data before building a separate forecasting model. Forecasting using R Forecasting and decomposition 24

Seas adj elec equipment 120 Naive forecasts of seasonally adjusted data 110 y 100 level 80 95 90 80 2000 2005 2010 New orders index Forecasting using R Forecasting and decomposition 25

Seas adj elec equipment Forecasts from STL + Random walk 120 New orders index 100 80 level 80 95 60 2000 2005 2010 Time Forecasting using R Forecasting and decomposition 26

How to do this in R fit <- stl(elecequip, t.window=15, s.window="periodic", robust=true) eeadj <- seasadj(fit) autoplot(naive(eeadj, h=24)) + ylab("new orders index") fcast <- forecast(fit, method="naive", h=24) autoplot(fcast) + ylab="new orders index") Forecasting using R Forecasting and decomposition 27

Decomposition and prediction intervals It is common to take the prediction intervals from the seasonally adjusted forecasts and modify them with the seasonal component. This ignores the uncertainty in the seasonal component estimate. It also ignores the uncertainty in the future seasonal pattern. Forecasting using R Forecasting and decomposition 28

Some more R functions fcast <- stlf(elecequip, method='naive') fcast <- stlf(elecequip, method='naive', h=36, s.window=11, robust=true) Forecasting using R Forecasting and decomposition 29

Outline 1 Time series components 2 STL decomposition 3 Forecasting and decomposition 4 Lab session 5 Forecasting using R Lab session 5 30

Lab Session 5 Forecasting using R Lab session 5 31