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

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

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

Transformations for variance stabilization

Forecasting: Principles and Practice. Rob J Hyndman. 12. Advanced methods OTexts.com/fpp/9/2/ OTexts.com/fpp/9/3/

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

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

Exponentially weighted forecasts

The log transformation produces a time series whose variance can be treated as constant over time.

STAT 436 / Lecture 16: Key

Forecasting with ARIMA models This version: 14 January 2018

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

477/577 In-class Exercise 5 : Fitting Wine Sales

Spectral Analysis. Al Nosedal University of Toronto. Winter Al Nosedal University of Toronto Spectral Analysis Winter / 71

Lecture 5: Estimation of time series

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

Stat 153 Time Series. Problem Set 4

Stat 565. Spurious Regression. Charlotte Wickham. stat565.cwick.co.nz. Feb

Minitab Project Report - Assignment 6

Problems from Chapter 3 of Shumway and Stoffer s Book

FORECASTING SUGARCANE PRODUCTION IN INDIA WITH ARIMA MODEL

Package TSPred. April 5, 2017

Univariate Time Series Analysis; ARIMA Models

AR(p) + I(d) + MA(q) = ARIMA(p, d, q)

Dynamic Time Series Regression: A Panacea for Spurious Correlations

Classical Decomposition Model Revisited: I

Two-Stage Models for Forecasting Time Series with Multiple Seasonality

Dynamic linear models (aka state-space models) 1

Time Series Analysis -- An Introduction -- AMS 586

Introduction to Regression Analysis. Dr. Devlina Chatterjee 11 th August, 2017

Time Series I Time Domain Methods

FE570 Financial Markets and Trading. Stevens Institute of Technology

Advanced Econometrics

Forecasting with R A practical workshop

Introduction to Simple Linear Regression

Lecture 6: Forecasting of time series

ARIMA Modelling and Forecasting

Circle the single best answer for each multiple choice question. Your choice should be made clearly.

Section 2 NABE ASTEF 65

Solution to Series 6

Modelling using ARMA processes

Lab: Box-Jenkins Methodology - US Wholesale Price Indicator

Short-term electricity demand forecasting in the time domain and in the frequency domain

arxiv: v1 [stat.co] 11 Dec 2012

03 Time series with trend and seasonality components. Andrius Buteikis,

Forecasting Gold Price. A Comparative Study

Booth School of Business, University of Chicago Business 41914, Spring Quarter 2017, Mr. Ruey S. Tsay Midterm

INTRODUCTION TO TIME SERIES ANALYSIS. The Simple Moving Average Model

Regression of Time Series

Time series analysis of activity and temperature data of four healthy individuals

ECON/FIN 250: Forecasting in Finance and Economics: Section 8: Forecast Examples: Part 1

Class: Dean Foster. September 30, Read sections: Examples chapter (chapter 3) Question today: Do prices go up faster than they go down?

Time-Series analysis for wind speed forecasting

Homework 5, Problem 1 Andrii Baryshpolets 6 April 2017

Econometric Forecasting Overview

Using Analysis of Time Series to Forecast numbers of The Patients with Malignant Tumors in Anbar Provinc

1. Fundamental concepts

Forecasting electricity load demand using hybrid exponential smoothing-artificial neural network model

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

A SARIMAX coupled modelling applied to individual load curves intraday forecasting

Automatic forecasting with a modified exponential smoothing state space framework

4. MA(2) +drift: y t = µ + ɛ t + θ 1 ɛ t 1 + θ 2 ɛ t 2. Mean: where θ(l) = 1 + θ 1 L + θ 2 L 2. Therefore,

over Time line for the means). Specifically, & covariances) just a fixed variance instead. PROC MIXED: to 1000 is default) list models with TYPE=VC */

STA 6857 ARIMA and SARIMA Models ( 3.8 and 3.9)

The ARIMA Procedure: The ARIMA Procedure

Forecasting Egyptian GDP Using ARIMA Models

STA 6857 ARIMA and SARIMA Models ( 3.8 and 3.9) Outline. Return Rate. US Gross National Product

TIME SERIES DATA PREDICTION OF NATURAL GAS CONSUMPTION USING ARIMA MODEL

Scenario 5: Internet Usage Solution. θ j

Non-independence due to Time Correlation (Chapter 14)

Analysis of Violent Crime in Los Angeles County

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

Forecasting: principles and practice 1

Analysis. Components of a Time Series

Lecture Notes of Bus (Spring 2017) Analysis of Financial Time Series Ruey S. Tsay

388 Index Differencing test ,232 Distributed lags , 147 arithmetic lag.

Circle a single answer for each multiple choice question. Your choice should be made clearly.

Univariate linear models

Box-Jenkins ARIMA Advanced Time Series

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

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

Eco and Bus Forecasting Fall 2016 EXERCISE 2

Prashant Pant 1, Achal Garg 2 1,2 Engineer, Keppel Offshore and Marine Engineering India Pvt. Ltd, Mumbai. IJRASET 2013: All Rights are Reserved 356

Lecture 6a: Unit Root and ARIMA Models

Suan Sunandha Rajabhat University

Empirical Approach to Modelling and Forecasting Inflation in Ghana

Subject-specific observed profiles of log(fev1) vs age First 50 subjects in Six Cities Study

Ross Bettinger, Analytical Consultant, Seattle, WA

The data was collected from the website and then converted to a time-series indexed from 1 to 86.

STAT Financial Time Series

ITSM-R Reference Manual

Tento projekt je spolufinancován Evropským sociálním fondem a Státním rozpočtem ČR InoBio CZ.1.07/2.2.00/

Solar irradiance forecasting for Chulalongkorn University location using time series models

Bristol Business School

Functional time series

Autocorrelation or Serial Correlation

Lecture 4a: ARMA Model

Booth School of Business, University of Chicago Business 41914, Spring Quarter 2013, Mr. Ruey S. Tsay. Midterm

Possibly useful formulas for this exam: b1 = Corr(X,Y) SDY / SDX. confidence interval: Estimate ± (Critical Value) (Standard Error of Estimate)

Elements of Multivariate Time Series Analysis

Univariate ARIMA Models

Transcription:

FORECASTING USING R Dynamic regression Rob Hyndman Author, forecast

Dynamic regression Regression model with ARIMA errors y t = β 0 + β 1 x 1,t + + β r x r,t + e t y t modeled as function of r explanatory variables x 1,t,...,x r,t In dynamic regression, we allow to be an ARIMA process e t In ordinary regression, we assume that is white noise e t

US personal consumption and income > autoplot(uschange[,1:2], facets = TRUE) + xlab("year") + ylab("") + ggtitle("quarterly changes in US consumption and personal income")

US personal consumption and income > ggplot(aes(x = Income, y = Consumption), data = as.data.frame(uschange)) + geom_point() + ggtitle("quarterly changes in US consumption and personal income")

Dynamic regression model for US personal consumption > fit <- auto.arima(uschange[,"consumption"], xreg = uschange[,"income"]) > fit Series: uschange[, "Consumption"] Regression with ARIMA(1,0,2) errors Coefficients: ar1 ma1 ma2 intercept origxreg 0.6191-0.5424 0.2367 0.6099 0.2492 s.e. 0.1422 0.1475 0.0685 0.0777 0.0459 sigma^2 estimated as 0.334: log likelihood=-195.22 AIC=402.44 AICc=402.82 BIC=422.99

Residuals from dynamic regression model > checkresiduals(fit) Ljung-Box test data: residuals Q* = 5.5543, df = 3, p-value = 0.1354 Model df: 5. Total lags used: 8

Forecasts from dynamic regression model > fcast <- forecast(fit, xreg = rep(0.8, 8)) > autoplot(fcast) + xlab("year") + ylab("percentage change")

FORECASTING USING R Let s practice!

FORECASTING USING R Dynamic harmonic regression

Dynamic harmonic regression Periodic seasonality can be handled using pairs of Fourier terms: ( 2πkt ) ( 2πkt ) s k (t) =sin m c k (t) =cos m m = seasonal period y t = β 0 + K k=1 [α k s k (t)+γ k c k (t)] + e t Every periodic function can be approximated by sums of sin and cos terms for large enough K α k Regression coefficients: and γ k e t can be modeled as a non-seasonal ARIMA process Assumes seasonal pattern is unchanging

Example: Australian cafe expenditure > fit <- auto.arima(cafe, xreg = fourier(cafe, K = 1), seasonal = FALSE, lambda = 0) > fit %>% forecast(xreg = fourier(cafe, K = 1, h = 24)) %>% autoplot() + ylim(1.6, 5.1)

Example: Australian cafe expenditure > fit <- auto.arima(cafe, xreg = fourier(cafe, K = 2), seasonal = FALSE, lambda = 0) > fit %>% forecast(xreg = fourier(cafe, K = 2, h = 24)) %>% autoplot() + ylim(1.6, 5.1)

Example: Australian cafe expenditure > fit <- auto.arima(cafe, xreg = fourier(cafe, K = 3), seasonal = FALSE, lambda = 0) > fit %>% forecast(xreg = fourier(cafe, K = 3, h = 24)) %>% autoplot() + ylim(1.6, 5.1)

Example: Australian cafe expenditure > fit <- auto.arima(cafe, xreg = fourier(cafe, K = 4), seasonal = FALSE, lambda = 0) > fit %>% forecast(xreg = fourier(cafe, K = 4, h = 24)) %>% autoplot() + ylim(1.6, 5.1)

Example: Australian cafe expenditure > fit <- auto.arima(cafe, xreg = fourier(cafe, K = 5), seasonal = FALSE, lambda = 0) > fit %>% forecast(xreg = fourier(cafe, K = 5, h = 24)) %>% autoplot() + ylim(1.6, 5.1)

Example: Australian cafe expenditure > fit <- auto.arima(cafe, xreg = fourier(cafe, K = 6), seasonal = FALSE, lambda = 0) > fit %>% forecast(xreg = fourier(cafe, K = 6, h = 24)) %>% autoplot() + ylim(1.6, 5.1)

Dynamic harmonic regression y t = β 0 + β 1 x t,1 + + β t,r x t,r + K k=1 [α k s k (t)+γ k c k (t)] + e t Other predictor variables can be added as well: x t,1,...,x t,r Choose K to minimize the AICc K can not be more than m/2 This is particularly useful for weekly data, daily data and sub-daily data. data

FORECASTING USING R Let s practice!

FORECASTING USING R TBATS models

TBATS model Trigonometric terms for seasonality Box-Cox transformations for heterogeneity ARMA errors for short-term dynamics Trend (possibly damped) Seasonal (including multiple and non-integer periods)

US Gasoline data > gasoline %>% tbats() %>% forecast() %>% autoplot() + xlab("year") + ylab("thousand barrels per day")

Call center data > calls %>% window(start = 20) %>% tbats() %>% forecast() %>% autoplot() + xlab("weeks") + ylab("calls")

TBATS model Trigonometric terms for seasonality Box-Cox transformations for heterogeneity ARMA errors for short-term dynamics Trend (possibly damped) Seasonal (including multiple and non-integer periods) Handles non-integer seasonality, multiple seasonal periods Entirely automated Prediction intervals often too wide Very slow on long series

FORECASTING USING R Let s practice!