Forecasting: principles and practice 1

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

Forecasting using R. Rob J Hyndman. 2.5 Seasonal ARIMA models. Forecasting using R 1

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

Chapter 12: An introduction to Time Series Analysis. Chapter 12: An introduction to Time Series Analysis

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

BCT Lecture 3. Lukas Vacha.

Forecasting: Principles and Practice. Rob J Hyndman. 1. Introduction to forecasting OTexts.org/fpp/1/ OTexts.org/fpp/2/3

Lecture 19 Box-Jenkins Seasonal Models

Lecture 5: Unit Roots, Cointegration and Error Correction Models The Spurious Regression Problem

SOME BASICS OF TIME-SERIES ANALYSIS

Transformations for variance stabilization

Testing for non-stationarity

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

Univariate, Nonstationary Processes

Firstly, the dataset is cleaned and the years and months are separated to provide better distinction (sample below).

Ch 6. Model Specification. Time Series Analysis

Modeling and forecasting global mean temperature time series

Forecasting. Simon Shaw 2005/06 Semester II

Consider the trend-cycle decomposition of a time series y t

Stochastic Analysis and Forecasts of the Patterns of Speed, Acceleration, and Levels of Material Stock Accumulation in Society

Nonstationary Time Series:

Basics: Definitions and Notation. Stationarity. A More Formal Definition

11/18/2008. So run regression in first differences to examine association. 18 November November November 2008

Lecture 6a: Unit Root and ARIMA Models

Forecasting using R. Rob J Hyndman. 3.2 Dynamic regression. Forecasting using R 1

Time Series Analysis -- An Introduction -- AMS 586

Chapter 3: Regression Methods for Trends

Estimation and application of best ARIMA model for forecasting the uranium price.

Applied Time Series Topics

Unit root problem, solution of difference equations Simple deterministic model, question of unit root

ECONOMETRIA II. CURSO 2009/2010 LAB # 3

3 Time Series Regression

Package TimeSeries.OBeu

Analysis. Components of a Time Series

Some Time-Series Models

Forecasting: principles and practice. Rob J Hyndman 1.1 Introduction to Forecasting

CHAPTER 8 MODEL DIAGNOSTICS. 8.1 Residual Analysis

Empirical Approach to Modelling and Forecasting Inflation in Ghana

Empirical Market Microstructure Analysis (EMMA)

ECON 427: ECONOMIC FORECASTING. Ch1. Getting started OTexts.org/fpp2/

Suan Sunandha Rajabhat University

SEASONAL TIME SERIES MODELS

STAT 520: Forecasting and Time Series. David B. Hitchcock University of South Carolina Department of Statistics

Economics 618B: Time Series Analysis Department of Economics State University of New York at Binghamton

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

Asitha Kodippili. Deepthika Senaratne. Department of Mathematics and Computer Science,Fayetteville State University, USA.

Estimating trends using filters

ECON/FIN 250: Forecasting in Finance and Economics: Section 7: Unit Roots & Dickey-Fuller Tests

Forecasting Bangladesh's Inflation through Econometric Models

Ch 8. MODEL DIAGNOSTICS. Time Series Analysis

1 Regression with Time Series Variables

THE SEASONAL UNIT ROOTS IN DEMOGRAPHIC TIME SERIES ANDTHE POSSIBILITIES OF ITS EXACT TESTING

Paper SA-08. Are Sales Figures in Line With Expectations? Using PROC ARIMA in SAS to Forecast Company Revenue

Time Series Modeling. Shouvik Mani April 5, /688: Practical Data Science Carnegie Mellon University

Part 1. Multiple Choice (50 questions, 1 point each) Part 2. Problems/Short Answer (10 questions, 5 points each)

MODELING INFLATION RATES IN NIGERIA: BOX-JENKINS APPROACH. I. U. Moffat and A. E. David Department of Mathematics & Statistics, University of Uyo, Uyo

Ross Bettinger, Analytical Consultant, Seattle, WA

Time Series Outlier Detection

Introductory Workshop on Time Series Analysis. Sara McLaughlin Mitchell Department of Political Science University of Iowa

Gaussian Copula Regression Application

Time Series Analysis of Monthly Rainfall data for the Gadaref rainfall station, Sudan, by Sarima Methods

Short and Long Memory Time Series Models of Relative Humidity of Jos Metropolis

Ch 5. Models for Nonstationary Time Series. Time Series Analysis

Part 1. Multiple Choice (40 questions, 1 point each) Part 2. Problems/Short Answer (10 questions, 6 points each)

Exercises - Time series analysis

FE570 Financial Markets and Trading. Stevens Institute of Technology

Time Series Analysis of United States of America Crude Oil and Petroleum Products Importations from Saudi Arabia

A SEASONAL TIME SERIES MODEL FOR NIGERIAN MONTHLY AIR TRAFFIC DATA

Time Series in R: Forecasting and Visualisation. Forecast evaluation 29 May 2017

On Consistency of Tests for Stationarity in Autoregressive and Moving Average Models of Different Orders

Response surface models for the Elliott, Rothenberg, Stock DF-GLS unit-root test

ARDL Cointegration Tests for Beginner

Time Series Methods. Sanjaya Desilva

Minitab Project Report - Practical 2. Time Series Plot of Electricity. Index

ARIMA Models. Jamie Monogan. January 16, University of Georgia. Jamie Monogan (UGA) ARIMA Models January 16, / 27

BJEST. Function: Usage:

Eksamen på Økonomistudiet 2006-II Econometrics 2 June 9, 2006

Modelling Monthly Rainfall Data of Port Harcourt, Nigeria by Seasonal Box-Jenkins Methods

Prediction of Grain Products in Turkey

A nonparametric test for seasonal unit roots

TIME SERIES ANALYSIS AND FORECASTING USING THE STATISTICAL MODEL ARIMA

Autoregressive Integrated Moving Average Model to Predict Graduate Unemployment in Indonesia

Applied Forecasting (LECTURENOTES) Prof. Rozenn Dahyot

7 Introduction to Time Series Time Series vs. Cross-Sectional Data Detrending Time Series... 15

Financial Econometrics Review Session Notes 3

TIMES SERIES INTRODUCTION INTRODUCTION. Page 1. A time series is a set of observations made sequentially through time

ANALYZING THE IMPACT OF HISTORICAL DATA LENGTH IN NON SEASONAL ARIMA MODELS FORECASTING

13. Time Series Analysis: Asymptotics Weakly Dependent and Random Walk Process. Strict Exogeneity

The ARIMA Procedure: The ARIMA Procedure

Univariate linear models

Lab: Box-Jenkins Methodology - US Wholesale Price Indicator

FinQuiz Notes

APPLIED TIME SERIES ECONOMETRICS

An Econometric Modeling for India s Imports and exports during

A Test of Forecast Consistency Using USDA Livestock Price Forecasts by Dwight R. Sanders and Mark R. Manfredo

Stationarity Revisited, With a Twist. David G. Tucek Value Economics, LLC

International Monetary Policy Spillovers

Forecasting: Methods and Applications

QMT 3001 BUSINESS FORECASTING. Exploring Data Patterns & An Introduction to Forecasting Techniques. Aysun KAPUCUGİL-İKİZ, PhD.

Chapter 2: Unit Roots

Transcription:

Forecasting: principles and practice Rob J Hyndman 2.3 Stationarity and differencing Forecasting: principles and practice 1

Outline 1 Stationarity 2 Differencing 3 Unit root tests 4 Lab session 10 5 Backshift notation Forecasting: principles and practice Stationarity 2

Stationarity Definition If {y t } is a stationary time series, then for all s, the distribution of (y t,..., y t+s ) does not depend on t. A stationary series is: roughly horizontal constant variance no patterns predictable in the long-term Forecasting: principles and practice Stationarity 3

Stationarity Definition If {y t } is a stationary time series, then for all s, the distribution of (y t,..., y t+s ) does not depend on t. A stationary series is: roughly horizontal constant variance no patterns predictable in the long-term Forecasting: principles and practice Stationarity 3

Stationary? 4000 3900 Dow Jones Index 3800 3700 3600 0 50 100 150 200 250 300 Day Forecasting: principles and practice Stationarity 4

Stationary? 50 Change in Dow Jones Index 0 50 100 0 50 100 150 200 250 300 Day Forecasting: principles and practice Stationarity 5

Stationary? 6000 Number of strikes 5000 4000 1950 1955 1960 1965 1970 1975 1980 Year Forecasting: principles and practice Stationarity 6

Stationary? Sales of new one family houses, USA 80 Total sales 60 40 1975 1980 1985 1990 1995 Year Forecasting: principles and practice Stationarity 7

Stationary? Price of a dozen eggs in 1993 dollars 300 $ 200 100 1900 1920 1940 1960 1980 Year Forecasting: principles and practice Stationarity 8

Stationary? Number of pigs slaughtered in Victoria 110 100 thousands 90 80 1990 1991 1992 1993 1994 1995 Year Forecasting: principles and practice Stationarity 9

Stationary? Annual Canadian Lynx Trappings 6000 Number trapped 4000 2000 0 1820 1840 1860 1880 1900 1920 Year Forecasting: principles and practice Stationarity 10

Stationary? Australian quarterly beer production 500 megalitres 450 400 1995 2000 2005 2010 Year Forecasting: principles and practice Stationarity 11

Stationarity Definition If {y t } is a stationary time series, then for all s, the distribution of (y t,..., y t+s ) does not depend on t. Transformations help to stabilize the variance. For ARIMA modelling, we also need to stabilize the mean. Forecasting: principles and practice Stationarity 12

Stationarity Definition If {y t } is a stationary time series, then for all s, the distribution of (y t,..., y t+s ) does not depend on t. Transformations help to stabilize the variance. For ARIMA modelling, we also need to stabilize the mean. Forecasting: principles and practice Stationarity 12

Non-stationarity in the mean Identifying non-stationary series time plot. The ACF of stationary data drops to zero relatively quickly The ACF of non-stationary data decreases slowly. For non-stationary data, the value of r 1 is often large and positive. Forecasting: principles and practice Stationarity 13

Example: Dow-Jones index 4000 3900 Dow Jones Index 3800 3700 3600 0 50 100 150 200 250 300 Day Forecasting: principles and practice Stationarity 14

Example: Dow-Jones index 1.00 Series: dj 0.75 ACF 0.50 0.25 0.00 0 5 10 15 20 25 Lag Forecasting: principles and practice Stationarity 15

Example: Dow-Jones index 50 Change in Dow Jones Index 0 50 100 0 50 100 150 200 250 300 Day Forecasting: principles and practice Stationarity 16

Example: Dow-Jones index Series: diff(dj) 0.10 0.05 ACF 0.00 0.05 0.10 0 5 10 15 20 25 Lag Forecasting: principles and practice Stationarity 17

Outline 1 Stationarity 2 Differencing 3 Unit root tests 4 Lab session 10 5 Backshift notation Forecasting: principles and practice Differencing 18

Differencing Differencing helps to stabilize the mean. The differenced series is the change between each observation in the original series: y t = y t y t 1. The differenced series will have only T 1 values since it is not possible to calculate a difference y 1 for the first observation. Forecasting: principles and practice Differencing 19

Second-order differencing Occasionally the differenced data will not appear stationary and it may be necessary to difference the data a second time: y t = y t y t 1 = (y t y t 1 ) (y t 1 y t 2 ) = y t 2y t 1 + y t 2. y t will have T 2 values. In practice, it is almost never necessary to go beyond second-order differences. Forecasting: principles and practice Differencing 20

Second-order differencing Occasionally the differenced data will not appear stationary and it may be necessary to difference the data a second time: y t = y t y t 1 = (y t y t 1 ) (y t 1 y t 2 ) = y t 2y t 1 + y t 2. y t will have T 2 values. In practice, it is almost never necessary to go beyond second-order differences. Forecasting: principles and practice Differencing 20

Second-order differencing Occasionally the differenced data will not appear stationary and it may be necessary to difference the data a second time: y t = y t y t 1 = (y t y t 1 ) (y t 1 y t 2 ) = y t 2y t 1 + y t 2. y t will have T 2 values. In practice, it is almost never necessary to go beyond second-order differences. Forecasting: principles and practice Differencing 20

Seasonal differencing A seasonal difference is the difference between an observation and the corresponding observation from the previous year. y t = y t y t m where m = number of seasons. For monthly data m = 12. For quarterly data m = 4. Forecasting: principles and practice Differencing 21

Seasonal differencing A seasonal difference is the difference between an observation and the corresponding observation from the previous year. y t = y t y t m where m = number of seasons. For monthly data m = 12. For quarterly data m = 4. Forecasting: principles and practice Differencing 21

Seasonal differencing A seasonal difference is the difference between an observation and the corresponding observation from the previous year. y t = y t y t m where m = number of seasons. For monthly data m = 12. For quarterly data m = 4. Forecasting: principles and practice Differencing 21

Electricity production usmelec %>% autoplot() 400 300. 200 1980 1990 2000 2010 Time Forecasting: principles and practice Differencing 22

Electricity production usmelec %>% log() %>% autoplot() 6.0 5.7. 5.4 5.1 1980 1990 2000 2010 Time Forecasting: principles and practice Differencing 23

Electricity production usmelec %>% log() %>% diff(lag=12) %>% autoplot() 0.1. 0.0 1980 1990 2000 2010 Time Forecasting: principles and practice Differencing 24

Electricity production usmelec %>% log() %>% diff(lag=12) %>% diff(lag=1) %>% autoplot() 0.10 0.05. 0.00 0.05 0.10 0.15 1980 1990 2000 2010 Time Forecasting: principles and practice Differencing 25

Electricity production Seasonally differenced series is closer to being stationary. Remaining non-stationarity can be removed with further first difference. If y t = y t y t 12 denotes seasonally differenced series, then twice-differenced series is y t = y t y t 1 = (y t y t 12 ) (y t 1 y t 13 ) = y t y t 1 y t 12 + y t 13. Forecasting: principles and practice Differencing 26

Seasonal differencing When both seasonal and first differences are applied... it makes no difference which is done first the result will be the same. If seasonality is strong, we recommend that seasonal differencing be done first because sometimes the resulting series will be stationary and there will be no need for further first difference. It is important that if differencing is used, the differences are interpretable. Forecasting: principles and practice Differencing 27

Seasonal differencing When both seasonal and first differences are applied... it makes no difference which is done first the result will be the same. If seasonality is strong, we recommend that seasonal differencing be done first because sometimes the resulting series will be stationary and there will be no need for further first difference. It is important that if differencing is used, the differences are interpretable. Forecasting: principles and practice Differencing 27

Seasonal differencing When both seasonal and first differences are applied... it makes no difference which is done first the result will be the same. If seasonality is strong, we recommend that seasonal differencing be done first because sometimes the resulting series will be stationary and there will be no need for further first difference. It is important that if differencing is used, the differences are interpretable. Forecasting: principles and practice Differencing 27

Interpretation of differencing first differences are the change between one observation and the next; seasonal differences are the change between one year to the next. But taking lag 3 differences for yearly data, for example, results in a model which cannot be sensibly interpreted. Forecasting: principles and practice Differencing 28

Interpretation of differencing first differences are the change between one observation and the next; seasonal differences are the change between one year to the next. But taking lag 3 differences for yearly data, for example, results in a model which cannot be sensibly interpreted. Forecasting: principles and practice Differencing 28

Outline 1 Stationarity 2 Differencing 3 Unit root tests 4 Lab session 10 5 Backshift notation Forecasting: principles and practice Unit root tests 29

Unit root tests Statistical tests to determine the required order of differencing. 1 Augmented Dickey Fuller test: null hypothesis is that the data are non-stationary and non-seasonal. 2 Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test: null hypothesis is that the data are stationary and non-seasonal. 3 Other tests available for seasonal data. Forecasting: principles and practice Unit root tests 30

Dickey-Fuller test Test for unit root Estimate regression model y t = φy t 1 + b 1 y t 1 + b 2 y t 2 + + b k y t k where y t denotes differenced series y t y t 1. Number of lagged terms, k, is usually set to be about 3. If original series, y t, needs differencing, ˆφ 0. If y t is already stationary, ˆφ < 0. In R: Use tseries::adf.test(). Forecasting: principles and practice Unit root tests 31

Dickey-Fuller test in R tseries::adf.test(x, alternative = c("stationary", "explosive"), k = trunc((length(x)-1)^(1/3))) k = T 1 1/3 Set alternative = stationary. tseries::adf.test(dj) ## ## Augmented Dickey-Fuller Test ## ## data: dj ## Dickey-Fuller = -1.9872, Lag order = 6, p-value = 0.5816 ## alternative hypothesis: stationary Forecasting: principles and practice Unit root tests 32

Dickey-Fuller test in R tseries::adf.test(x, alternative = c("stationary", "explosive"), k = trunc((length(x)-1)^(1/3))) k = T 1 1/3 Set alternative = stationary. tseries::adf.test(dj) ## ## Augmented Dickey-Fuller Test ## ## data: dj ## Dickey-Fuller = -1.9872, Lag order = 6, p-value = 0.5816 ## alternative hypothesis: stationary Forecasting: principles and practice Unit root tests 32

Dickey-Fuller test in R tseries::adf.test(x, alternative = c("stationary", "explosive"), k = trunc((length(x)-1)^(1/3))) k = T 1 1/3 Set alternative = stationary. tseries::adf.test(dj) ## ## Augmented Dickey-Fuller Test ## ## data: dj ## Dickey-Fuller = -1.9872, Lag order = 6, p-value = 0.5816 ## alternative hypothesis: stationary Forecasting: principles and practice Unit root tests 32

How many differences? ndiffs(x) nsdiffs(x) ndiffs(dj) ## [1] 1 nsdiffs(hsales) ## [1] 0 Forecasting: principles and practice Unit root tests 33

Outline 1 Stationarity 2 Differencing 3 Unit root tests 4 Lab session 10 5 Backshift notation Forecasting: principles and practice Lab session 10 34

Lab Session 10 Forecasting: principles and practice Lab session 10 35

Outline 1 Stationarity 2 Differencing 3 Unit root tests 4 Lab session 10 5 Backshift notation Forecasting: principles and practice Backshift notation 36

Backshift notation A very useful notational device is the backward shift operator, B, which is used as follows: By t = y t 1. In other words, B, operating on y t, has the effect of shifting the data back one period. Two applications of B to y t shifts the data back two periods: B(By t ) = B 2 y t = y t 2. For monthly data, if we wish to shift attention to the same month last year, then B 12 is used, and the notation is B 12 y t = y t 12. Forecasting: principles and practice Backshift notation 37

Backshift notation A very useful notational device is the backward shift operator, B, which is used as follows: By t = y t 1. In other words, B, operating on y t, has the effect of shifting the data back one period. Two applications of B to y t shifts the data back two periods: B(By t ) = B 2 y t = y t 2. For monthly data, if we wish to shift attention to the same month last year, then B 12 is used, and the notation is B 12 y t = y t 12. Forecasting: principles and practice Backshift notation 37

Backshift notation A very useful notational device is the backward shift operator, B, which is used as follows: By t = y t 1. In other words, B, operating on y t, has the effect of shifting the data back one period. Two applications of B to y t shifts the data back two periods: B(By t ) = B 2 y t = y t 2. For monthly data, if we wish to shift attention to the same month last year, then B 12 is used, and the notation is B 12 y t = y t 12. Forecasting: principles and practice Backshift notation 37

Backshift notation A very useful notational device is the backward shift operator, B, which is used as follows: By t = y t 1. In other words, B, operating on y t, has the effect of shifting the data back one period. Two applications of B to y t shifts the data back two periods: B(By t ) = B 2 y t = y t 2. For monthly data, if we wish to shift attention to the same month last year, then B 12 is used, and the notation is B 12 y t = y t 12. Forecasting: principles and practice Backshift notation 37

Backshift notation The backward shift operator is convenient for describing the process of differencing. A first difference can be written as y t = y t y t 1 = y t By t = (1 B)y t. Note that a first difference is represented by (1 B). Similarly, if second-order differences (i.e., first differences of first differences) have to be computed, then: y t = y t 2y t 1 + y t 2 = (1 B) 2 y t. Forecasting: principles and practice Backshift notation 38

Backshift notation The backward shift operator is convenient for describing the process of differencing. A first difference can be written as y t = y t y t 1 = y t By t = (1 B)y t. Note that a first difference is represented by (1 B). Similarly, if second-order differences (i.e., first differences of first differences) have to be computed, then: y t = y t 2y t 1 + y t 2 = (1 B) 2 y t. Forecasting: principles and practice Backshift notation 38

Backshift notation The backward shift operator is convenient for describing the process of differencing. A first difference can be written as y t = y t y t 1 = y t By t = (1 B)y t. Note that a first difference is represented by (1 B). Similarly, if second-order differences (i.e., first differences of first differences) have to be computed, then: y t = y t 2y t 1 + y t 2 = (1 B) 2 y t. Forecasting: principles and practice Backshift notation 38

Backshift notation The backward shift operator is convenient for describing the process of differencing. A first difference can be written as y t = y t y t 1 = y t By t = (1 B)y t. Note that a first difference is represented by (1 B). Similarly, if second-order differences (i.e., first differences of first differences) have to be computed, then: y t = y t 2y t 1 + y t 2 = (1 B) 2 y t. Forecasting: principles and practice Backshift notation 38

Backshift notation Second-order difference is denoted (1 B) 2. Second-order difference is not the same as a second difference, which would be denoted 1 B 2 ; In general, a dth-order difference can be written as (1 B) d y t. A seasonal difference followed by a first difference can be written as (1 B)(1 B m )y t. Forecasting: principles and practice Backshift notation 39

Backshift notation The backshift notation is convenient because the terms can be multiplied together to see the combined effect. (1 B)(1 B m )y t = (1 B B m + B m+1 )y t = y t y t 1 y t m + y t m 1. For monthly data, m = 12 and we obtain the same result as earlier. Forecasting: principles and practice Backshift notation 40

Backshift notation The backshift notation is convenient because the terms can be multiplied together to see the combined effect. (1 B)(1 B m )y t = (1 B B m + B m+1 )y t = y t y t 1 y t m + y t m 1. For monthly data, m = 12 and we obtain the same result as earlier. Forecasting: principles and practice Backshift notation 40