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

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

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

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

STAT 436 / Lecture 16: Key

Transformations for variance stabilization

FE570 Financial Markets and Trading. Stevens Institute of Technology

Dynamic Time Series Regression: A Panacea for Spurious Correlations

Time Series I Time Domain Methods

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

FORECASTING SUGARCANE PRODUCTION IN INDIA WITH ARIMA MODEL

Lab: Box-Jenkins Methodology - US Wholesale Price Indicator

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

TIME SERIES ANALYSIS AND FORECASTING USING THE STATISTICAL MODEL ARIMA

Lecture 5: Estimation of time series

Design of Time Series Model for Road Accident Fatal Death in Tamilnadu

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

Minitab Project Report - Assignment 6

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

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

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

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

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

Homework 4. 1 Data analysis problems

Empirical Market Microstructure Analysis (EMMA)

The ARIMA Procedure: The ARIMA Procedure

INTRODUCTION TO TIME SERIES ANALYSIS. The Simple Moving Average Model

Some Time-Series Models

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

Time Series Analysis -- An Introduction -- AMS 586

Modeling and forecasting global mean temperature time series

Financial Time Series Analysis: Part II

Advanced Econometrics

Univariate Time Series Analysis; ARIMA Models

Suan Sunandha Rajabhat University

Exercises - Time series analysis

Autoregressive Integrated Moving Average Model to Predict Graduate Unemployment in Indonesia

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

UNIVARIATE TIME SERIES ANALYSIS BRIEFING 1970

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

EXAMINATIONS OF THE ROYAL STATISTICAL SOCIETY

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

Forecasting Seasonal Time Series 1. Introduction. Philip Hans Franses Econometric Institute Erasmus University Rotterdam

Lecture 6a: Unit Root and ARIMA Models

Sugarcane Productivity in Bihar- A Forecast through ARIMA Model

The Problem. Regression With Correlated Errors. Generalized Least Squares. Correlated Errors. Consider the typical regression model.

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

5 Autoregressive-Moving-Average Modeling

Reliability and Risk Analysis. Time Series, Types of Trend Functions and Estimates of Trends

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

STA 6857 ARIMA and SARIMA Models ( 3.8 and 3.9)

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

Forecasting: principles and practice 1

Exponentially weighted forecasts

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

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

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

Forecasting Area, Production and Yield of Cotton in India using ARIMA Model

Time Series Outlier Detection

Seasonal Autoregressive Integrated Moving Average Model for Precipitation Time Series

Univariate ARIMA Models

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

FIN822 project 2 Project 2 contains part I and part II. (Due on November 10, 2008)

Ch 8. MODEL DIAGNOSTICS. Time Series Analysis

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

Classical Decomposition Model Revisited: I

Lecture 19 Box-Jenkins Seasonal Models

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

ITSM-R Reference Manual

Chapter 3: Regression Methods for Trends

STAT Financial Time Series

Analysis. Components of a Time Series

FinQuiz Notes

Applied Time Series Topics

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

Forecasting with ARIMA models This version: 14 January 2018

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

A SARIMAX coupled modelling applied to individual load curves intraday forecasting

ARIMA Modelling and Forecasting

Topic 4 Unit Roots. Gerald P. Dwyer. February Clemson University

Forecasting. Simon Shaw 2005/06 Semester II

Testing for non-stationarity

Evaluation of Some Techniques for Forecasting of Electricity Demand in Sri Lanka

Module 3. Descriptive Time Series Statistics and Introduction to Time Series Models

Ch3. TRENDS. Time Series Analysis

THE ROYAL STATISTICAL SOCIETY 2009 EXAMINATIONS SOLUTIONS GRADUATE DIPLOMA MODULAR FORMAT MODULE 3 STOCHASTIC PROCESSES AND TIME SERIES

A test for improved forecasting performance at higher lead times

Multivariate Time Series Analysis and Its Applications [Tsay (2005), chapter 8]

Estadística Oficial. Transfer Function Model Identication

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

Econometrics I: Univariate Time Series Econometrics (1)

Empirical Approach to Modelling and Forecasting Inflation in Ghana

MCMC analysis of classical time series algorithms.

at least 50 and preferably 100 observations should be available to build a proper model

New York University Department of Economics. Applied Statistics and Econometrics G Spring 2013

CHAPTER 8 MODEL DIAGNOSTICS. 8.1 Residual Analysis

arxiv: v1 [stat.co] 11 Dec 2012

COMPUTER SESSION 3: ESTIMATION AND FORECASTING.

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

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MAS451/MTH451 Time Series Analysis TIME ALLOWED: 2 HOURS

Transcription:

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

Outline 1 Regression with ARIMA errors 2 Stochastic and deterministic trends 3 Periodic seasonality 4 Lab session 14 5 Dynamic regression models Forecasting using R Regression with ARIMA errors 2

Regression with ARIMA errors Regression models y t = β 0 + β 1 x 1,t + + β k x k,t + e t, y t modeled as function of k explanatory variables x 1,t,..., x k,t. In regression, we assume that e t was WN. Now we want to allow e t to be autocorrelated. Example: ARIMA(1,1,1) errors y t = β 0 + β 1 x 1,t + + β k x k,t + n t, (1 φ 1 B)(1 B)n t = (1 + θ 1 B)e t, where e t is white noise. Forecasting using R Regression with ARIMA errors 3

Regression with ARIMA errors Regression models y t = β 0 + β 1 x 1,t + + β k x k,t + e t, y t modeled as function of k explanatory variables x 1,t,..., x k,t. In regression, we assume that e t was WN. Now we want to allow e t to be autocorrelated. Example: ARIMA(1,1,1) errors y t = β 0 + β 1 x 1,t + + β k x k,t + n t, (1 φ 1 B)(1 B)n t = (1 + θ 1 B)e t, where e t is white noise. Forecasting using R Regression with ARIMA errors 3

Residuals and errors Example: N t = ARIMA(1,1,1) y t = β 0 + β 1 x 1,t + + β k x k,t + n t, (1 φ 1 B)(1 B)n t = (1 + θ 1 B)e t, Be careful in distinguishing n t from e t. Only the errors n t are assumed to be white noise. In ordinary regression, n t is assumed to be white noise and so n t = e t. Forecasting using R Regression with ARIMA errors 4

Residuals and errors Example: N t = ARIMA(1,1,1) y t = β 0 + β 1 x 1,t + + β k x k,t + n t, (1 φ 1 B)(1 B)n t = (1 + θ 1 B)e t, Be careful in distinguishing n t from e t. Only the errors n t are assumed to be white noise. In ordinary regression, n t is assumed to be white noise and so n t = e t. Forecasting using R Regression with ARIMA errors 4

Estimation If we minimize n 2 t (by using ordinary regression): 1 Estimated coefficients ˆβ 0,..., ˆβ k are no longer optimal as some information ignored; 2 Statistical tests associated with the model (e.g., t-tests on the coefficients) are incorrect. 3 p-values for coefficients usually too small ( spurious regression ). 4 AIC of fitted models misleading. Minimizing e 2 t avoids these problems. Maximizing likelihood is similar to minimizing e 2 t. Forecasting using R Regression with ARIMA errors 5

Estimation If we minimize n 2 t (by using ordinary regression): 1 Estimated coefficients ˆβ 0,..., ˆβ k are no longer optimal as some information ignored; 2 Statistical tests associated with the model (e.g., t-tests on the coefficients) are incorrect. 3 p-values for coefficients usually too small ( spurious regression ). 4 AIC of fitted models misleading. Minimizing e 2 t avoids these problems. Maximizing likelihood is similar to minimizing e 2 t. Forecasting using R Regression with ARIMA errors 5

Stationarity Regression with ARMA errors y t = β 0 + β 1 x 1,t + + β k x k,t + n t, where n t is an ARMA process. All variables in the model must be stationary. If we estimate the model while any of these are non-stationary, the estimated coefficients can be incorrect. Difference variables until all stationary. If necessary, apply same differencing to all variables. Forecasting using R Regression with ARIMA errors 6

Stationarity Model with ARIMA(1,1,1) errors y t = β 0 + β 1 x 1,t + + β k x k,t + n t, (1 φ 1 B)(1 B)n t = (1 + θ 1 B)e t, Equivalent to model with ARIMA(1,0,1) errors y t = β 1 x 1,t + + β k x k,t + n t, (1 φ 1 B)n t = (1 + θ 1 B)e t, where y t = y t y t 1, x t,i = x t,i x t 1,i and n t = n t n t 1. Forecasting using R Regression with ARIMA errors 7

Stationarity Model with ARIMA(1,1,1) errors y t = β 0 + β 1 x 1,t + + β k x k,t + n t, (1 φ 1 B)(1 B)n t = (1 + θ 1 B)e t, Equivalent to model with ARIMA(1,0,1) errors y t = β 1 x 1,t + + β k x k,t + n t, (1 φ 1 B)n t = (1 + θ 1 B)e t, where y t = y t y t 1, x t,i = x t,i x t 1,i and n t = n t n t 1. Forecasting using R Regression with ARIMA errors 7

Regression with ARIMA errors Any regression with an ARIMA error can be rewritten as a regression with an ARMA error by differencing all variables with the same differencing operator as in the ARIMA model. Original data y t = β 0 + β 1 x 1,t + + β k x k,t + n t where φ(b)(1 B) d N t = θ(b)e t After differencing all variables y t = β 1 x 1,t + + β k x k,t + n t. where and φ(b)n t = θ(b)e t y t = (1 B) d y t Forecasting using R Regression with ARIMA errors 8

Regression with ARIMA errors Any regression with an ARIMA error can be rewritten as a regression with an ARMA error by differencing all variables with the same differencing operator as in the ARIMA model. Original data y t = β 0 + β 1 x 1,t + + β k x k,t + n t where φ(b)(1 B) d N t = θ(b)e t After differencing all variables y t = β 1 x 1,t + + β k x k,t + n t. where and φ(b)n t = θ(b)e t y t = (1 B) d y t Forecasting using R Regression with ARIMA errors 8

Regression with ARIMA errors Any regression with an ARIMA error can be rewritten as a regression with an ARMA error by differencing all variables with the same differencing operator as in the ARIMA model. Original data y t = β 0 + β 1 x 1,t + + β k x k,t + n t where φ(b)(1 B) d N t = θ(b)e t After differencing all variables y t = β 1 x 1,t + + β k x k,t + n t. where and φ(b)n t = θ(b)e t y t = (1 B) d y t Forecasting using R Regression with ARIMA errors 8

Model selection Check that all variables are stationary. If not, apply differencing. Where appropriate, use the same differencing for all variables to preserve interpretability. Fit regression model with automatically selected ARIMA errors. Check that e t series looks like white noise. Selecting predictors AICc can be calculated for final model. Repeat procedure for all subsets of predictors to be considered, and select model with lowest AIC value. Forecasting using R Regression with ARIMA errors 9

US personal consumption & income 2 Quarterly changes in US consumption and personal income 1 0 1 2 2.5 0.0 consumption income 2.5 1970 1980 1990 2000 2010 Year Forecasting using R Regression with ARIMA errors 10

US personal consumption & income Quarterly changes in US consumption and personal income 2 1 consumption 0 1 2 2.5 0.0 2.5 income Forecasting using R Regression with ARIMA errors 11

US Personal Consumption and income No need for transformations or further differencing. Increase in income does not necessarily translate into instant increase in consumption (e.g., after the loss of a job, it may take a few months for expenses to be reduced to allow for the new circumstances). We will ignore this for now. Forecasting using R Regression with ARIMA errors 12

US personal consumption & income (fit <- auto.arima(usconsumption[,1], xreg=usconsumption[,2])) ## Series: usconsumption[, 1] ## ARIMA(1,0,2) with non-zero mean ## ## Coefficients: ## ar1 ma1 ma2 intercept usconsumption[, 2] ## 0.6516-0.5440 0.2187 0.5750 0.2420 ## s.e. 0.1468 0.1576 0.0790 0.0951 0.0513 ## ## sigma^2 estimated as 0.3502: log likelihood=-144.27 ## AIC=300.54 AICc=301.08 BIC=319.14 Forecasting using R Regression with ARIMA errors 13

US personal consumption & income ggtsdisplay(arima.errors(fit), main="arima errors") 1 0 ARIMA errors x 1 2 1970 1980 1990 2000 2010 Time ACF 0.2 0.0 PACF 0.2 0.0 0.2 0.2 4 8 12 16 20 4 8 12 16 20 Lag Lag Forecasting using R Regression with ARIMA errors 14

US personal consumption & income ggtsdisplay(residuals(fit), main="arima residuals") x 1 0 1 2 ARIMA residuals 1970 1980 1990 2000 2010 Time 0.1 0.1 ACF 0.0 PACF 0.0 0.1 0.1 4 8 12 16 20 4 8 12 16 20 Lag Lag Forecasting using R Regression with ARIMA errors 15

US Personal Consumption and Income A Ljung-Box test shows the residuals are uncorrelated. Box.test(residuals(fit), fitdf=5, lag=10, type="ljung") ## ## Box-Ljung test ## ## data: residuals(fit) ## X-squared = 4.5948, df = 5, p-value = 0.4673 Forecasting using R Regression with ARIMA errors 16

US Personal Consumption and Income fcast <- forecast(fit, xreg=rep(mean(usconsumption[,2]),8), h=8) autoplot(fcast) + xlab("year") + ylab("percentage change") + ggtitle("forecasts from regression with ARIMA(1,0,2) errors" Forecasts from regression with ARIMA(1,0,2) errors 2 Percentage change 1 0 1 level 80 95 2 1970 1980 1990 2000 2010 Year Forecasting using R Regression with ARIMA errors 17

Forecasting To forecast a regression model with ARIMA errors, we need to forecast the regression part of the model and the ARIMA part of the model and combine the results. Some explanatory variable are known into the future (e.g., time, dummies). Separate forecasting models may be needed for other explanatory variables. Forecasting using R Regression with ARIMA errors 18

Outline 1 Regression with ARIMA errors 2 Stochastic and deterministic trends 3 Periodic seasonality 4 Lab session 14 5 Dynamic regression models Forecasting using R Stochastic and deterministic trends 19

Stochastic & deterministic trends Deterministic trend y t = β 0 + β 1 t + n t where n t is ARMA process. Stochastic trend y t = β 0 + β 1 t + n t where n t is ARIMA process with d 1. Difference both sides until n t is stationary: y t = β 1 + n t where n t is ARMA process. Forecasting using R Stochastic and deterministic trends 20

Stochastic & deterministic trends Deterministic trend y t = β 0 + β 1 t + n t where n t is ARMA process. Stochastic trend y t = β 0 + β 1 t + n t where n t is ARIMA process with d 1. Difference both sides until n t is stationary: y t = β 1 + n t where n t is ARMA process. Forecasting using R Stochastic and deterministic trends 20

Stochastic & deterministic trends Deterministic trend y t = β 0 + β 1 t + n t where n t is ARMA process. Stochastic trend y t = β 0 + β 1 t + n t where n t is ARIMA process with d 1. Difference both sides until n t is stationary: y t = β 1 + n t where n t is ARMA process. Forecasting using R Stochastic and deterministic trends 20

International visitors Total annual international visitors to Australia 5 millions of people 4 3 2 1 1980 1985 1990 1995 2000 2005 2010 Year Forecasting using R Stochastic and deterministic trends 21

International visitors Deterministic trend (fit1 <- auto.arima(austa, d=0, xreg=1:length(austa))) ## Series: austa ## ARIMA(2,0,0) with non-zero mean ## ## Coefficients: ## ar1 ar2 intercept 1:length(austa) ## 1.0371-0.3379 0.4173 0.1715 ## s.e. 0.1675 0.1797 0.1866 0.0102 ## ## sigma^2 estimated as 0.02854: log likelihood=12.7 ## AIC=-15.4 AICc=-13 BIC=-8.23 y t = 0.4173 + 0.1715t + n t n t = 1.0371n t 1 0.3379n t 2 + e t e t NID(0, 0.02854). Forecasting using R Stochastic and deterministic trends 22

International visitors Deterministic trend (fit1 <- auto.arima(austa, d=0, xreg=1:length(austa))) ## Series: austa ## ARIMA(2,0,0) with non-zero mean ## ## Coefficients: ## ar1 ar2 intercept 1:length(austa) ## 1.0371-0.3379 0.4173 0.1715 ## s.e. 0.1675 0.1797 0.1866 0.0102 ## ## sigma^2 estimated as 0.02854: log likelihood=12.7 ## AIC=-15.4 AICc=-13 BIC=-8.23 y t = 0.4173 + 0.1715t + n t n t = 1.0371n t 1 0.3379n t 2 + e t e t NID(0, 0.02854). Forecasting using R Stochastic and deterministic trends 22

Forecasting using R y t y t 1 = 0.1538 + e t y t = y 0 + 0.1538t + n t n t = n t 1 + e t e NID(0, 0.03132). Stochastic and deterministic trends 23 International visitors Stochastic trend (fit2 <- auto.arima(austa,d=1)) ## Series: austa ## ARIMA(0,1,0) with drift ## ## Coefficients: ## drift ## 0.1537 ## s.e. 0.0323 ## ## sigma^2 estimated as 0.03241: log likelihood=9.38 ## AIC=-14.76 AICc=-14.32 BIC=-11.96

Forecasting using R y t y t 1 = 0.1538 + e t y t = y 0 + 0.1538t + n t n t = n t 1 + e t e NID(0, 0.03132). Stochastic and deterministic trends 23 International visitors Stochastic trend (fit2 <- auto.arima(austa,d=1)) ## Series: austa ## ARIMA(0,1,0) with drift ## ## Coefficients: ## drift ## 0.1537 ## s.e. 0.0323 ## ## sigma^2 estimated as 0.03241: log likelihood=9.38 ## AIC=-14.76 AICc=-14.32 BIC=-11.96

International visitors 8 Forecasts from linear trend with AR(2) error 6 4 2 level 80 95 8 1980 1990 2000 2010 2020 Year Forecasts from ARIMA(0,1,0) with drift 6 4 2 level 80 95 1980 1990 2000 2010 2020 Year Forecasting using R Stochastic and deterministic trends 24

Forecasting with trend Point forecasts are almost identical, but prediction intervals differ. Stochastic trends have much wider prediction intervals because the errors are non-stationary. Be careful of forecasting with deterministic trends too far ahead. Forecasting using R Stochastic and deterministic trends 25

Outline 1 Regression with ARIMA errors 2 Stochastic and deterministic trends 3 Periodic seasonality 4 Lab session 14 5 Dynamic regression models Forecasting using R Periodic seasonality 26

Fourier terms for seasonality Periodic seasonality can be handled using pairs of Fourier terms: ( 2πkt s k (t) = sin m ) ( 2πkt c k (t) = cos m y t = K [α k s k (t) + β k c k (t)] + n t k=1 n t is non-seasonal ARIMA process. Every periodic function can be approximated by sums of sin and cos terms for large enough K. Choose K by minimizing AICc. ) Forecasting using R Periodic seasonality 27

US Accidental Deaths fit <- auto.arima(usaccdeaths, xreg=fourier(usaccdeaths, 5), seasonal=false) fc <- forecast(fit, xreg=fourier(usaccdeaths, 5, 24)) Forecasting using R Periodic seasonality 28

US Accidental Deaths autoplot(fc) Forecasts from ARIMA(0,1,1) 12000 y 10000 level 80 95 8000 1973 1975 1977 1979 1981 Forecasting using R Time Periodic seasonality 29

Outline 1 Regression with ARIMA errors 2 Stochastic and deterministic trends 3 Periodic seasonality 4 Lab session 14 5 Dynamic regression models Forecasting using R Lab session 14 30

Lab Session 14 Forecasting using R Lab session 14 31

Outline 1 Regression with ARIMA errors 2 Stochastic and deterministic trends 3 Periodic seasonality 4 Lab session 14 5 Dynamic regression models Forecasting using R Dynamic regression models 32

Dynamic regression models Sometimes a change in x t does not affect y t instantaneously y t = sales, x t = advertising. y t = stream flow, x t = rainfall. y t = size of herd, x t = breeding stock. These are dynamic systems with input (x t ) and output (y t ). x t is often a leading indicator. There can be multiple predictors. Forecasting using R Dynamic regression models 33

Dynamic regression models Sometimes a change in x t does not affect y t instantaneously y t = sales, x t = advertising. y t = stream flow, x t = rainfall. y t = size of herd, x t = breeding stock. These are dynamic systems with input (x t ) and output (y t ). x t is often a leading indicator. There can be multiple predictors. Forecasting using R Dynamic regression models 33

Dynamic regression models Sometimes a change in x t does not affect y t instantaneously y t = sales, x t = advertising. y t = stream flow, x t = rainfall. y t = size of herd, x t = breeding stock. These are dynamic systems with input (x t ) and output (y t ). x t is often a leading indicator. There can be multiple predictors. Forecasting using R Dynamic regression models 33

Lagged explanatory variables The model include present and past values of predictor: x t, x t 1, x t 2,.... y t = a + ν 0 x t + ν 1 x t 1 + + ν k x t k + n t where n t is an ARIMA process. Rewrite model as y t = a + (ν 0 + ν 1 B + ν 2 B 2 + + ν k B k )x t + n t = a + ν(b)x t + n t. ν(b) is called a transfer function since it describes how change in x t is transferred to y t. x can influence y, but y is not allowed to influence x. Forecasting using R Dynamic regression models 34

Lagged explanatory variables The model include present and past values of predictor: x t, x t 1, x t 2,.... y t = a + ν 0 x t + ν 1 x t 1 + + ν k x t k + n t where n t is an ARIMA process. Rewrite model as y t = a + (ν 0 + ν 1 B + ν 2 B 2 + + ν k B k )x t + n t = a + ν(b)x t + n t. ν(b) is called a transfer function since it describes how change in x t is transferred to y t. x can influence y, but y is not allowed to influence x. Forecasting using R Dynamic regression models 34

Lagged explanatory variables The model include present and past values of predictor: x t, x t 1, x t 2,.... y t = a + ν 0 x t + ν 1 x t 1 + + ν k x t k + n t where n t is an ARIMA process. Rewrite model as y t = a + (ν 0 + ν 1 B + ν 2 B 2 + + ν k B k )x t + n t = a + ν(b)x t + n t. ν(b) is called a transfer function since it describes how change in x t is transferred to y t. x can influence y, but y is not allowed to influence x. Forecasting using R Dynamic regression models 34

Example: Insurance quotes and TV adverts 18 16 Insurance advertising and quotations 14 12 10 8 11 10 9 8 7 Quotes TV.advert 6 2002 2003 2004 2005 Year Forecasting using R Dynamic regression models 35

Example: Insurance quotes and TV adverts Advert <- cbind(insurance[,2], c(na,insurance[1:39,2])) colnames(advert) <- paste("adlag",0:1,sep="") (fit <- auto.arima(insurance[,1], xreg=advert, d=0)) ## Series: insurance[, 1] ## ARIMA(3,0,0) with non-zero mean ## ## Coefficients: ## ar1 ar2 ar3 intercept AdLag0 AdLag1 ## 1.4117-0.9317 0.3591 2.0393 1.2564 0.1625 ## s.e. 0.1698 0.2545 0.1592 0.9931 0.0667 0.0591 ## ## sigma^2 estimated as 0.2165: log likelihood=-23.89 ## AIC=61.78 AICc=65.28 BIC=73.6 y t = 2.05 + 1.26x t + 0.16x t 1 + n t n t = 1.41n t 1 093n t 2 + 0.36n t 3 Forecasting using R Dynamic regression models 36

Example: Insurance quotes and TV adverts Advert <- cbind(insurance[,2], c(na,insurance[1:39,2])) colnames(advert) <- paste("adlag",0:1,sep="") (fit <- auto.arima(insurance[,1], xreg=advert, d=0)) ## Series: insurance[, 1] ## ARIMA(3,0,0) with non-zero mean ## ## Coefficients: ## ar1 ar2 ar3 intercept AdLag0 AdLag1 ## 1.4117-0.9317 0.3591 2.0393 1.2564 0.1625 ## s.e. 0.1698 0.2545 0.1592 0.9931 0.0667 0.0591 ## ## sigma^2 estimated as 0.2165: log likelihood=-23.89 ## AIC=61.78 AICc=65.28 BIC=73.6 y t = 2.05 + 1.26x t + 0.16x t 1 + n t n t = 1.41n t 1 093n t 2 + 0.36n t 3 Forecasting using R Dynamic regression models 36

Example: Insurance quotes and TV adverts fc <- forecast(fit, h=20, xreg=cbind(c(advert[40,1],rep(10,19)), rep(10,20))) autoplot(fc) 18 Forecasts from ARIMA(3,0,0) with non zero mean 16 y 14 12 level 80 95 10 8 2002 2003 2004 2005 2006 2007 Time Forecasting using R Dynamic regression models 37

Example: Insurance quotes and TV adverts fc <- forecast(fit, h=20, xreg=cbind(c(advert[40,1],rep(8,19)), rep(8,20))) autoplot(fc) 18 Forecasts from ARIMA(3,0,0) with non zero mean 16 y 14 12 level 80 95 10 8 2002 2003 2004 2005 2006 2007 Time Forecasting using R Dynamic regression models 38

Example: Insurance quotes and TV adverts fc <- forecast(fit, h=20, xreg=cbind(c(advert[40,1],rep(6,19)), rep(6,20))) autoplot(fc) 18 Forecasts from ARIMA(3,0,0) with non zero mean 16 y 14 12 level 80 95 10 8 2002 2003 2004 2005 2006 2007 Time Forecasting using R Dynamic regression models 39

Dynamic regression models y t = a + ν(b)x t + n t where n t is an ARMA process. So φ(b)n t = θ(b)e t or n t = θ(b) φ(b) e t = ψ(b)e t. y t = a + ν(b)x t + ψ(b)e t ARMA models are rational approximations to general transfer functions of e t. We can also replace ν(b) by a rational approximation. There is no R package for forecasting using a general transfer function approach. Forecasting using R Dynamic regression models 40

Dynamic regression models y t = a + ν(b)x t + n t where n t is an ARMA process. So φ(b)n t = θ(b)e t or n t = θ(b) φ(b) e t = ψ(b)e t. y t = a + ν(b)x t + ψ(b)e t ARMA models are rational approximations to general transfer functions of e t. We can also replace ν(b) by a rational approximation. There is no R package for forecasting using a general transfer function approach. Forecasting using R Dynamic regression models 40

Dynamic regression models y t = a + ν(b)x t + n t where n t is an ARMA process. So φ(b)n t = θ(b)e t or n t = θ(b) φ(b) e t = ψ(b)e t. y t = a + ν(b)x t + ψ(b)e t ARMA models are rational approximations to general transfer functions of e t. We can also replace ν(b) by a rational approximation. There is no R package for forecasting using a general transfer function approach. Forecasting using R Dynamic regression models 40