EC313 Business and Financial Forecasting Lecture 3

J James Reade

20/01/2015

Introduction

\[ \newcommand{\N}[1]{\mathsf{N}\left(#1\right)} \newcommand{\E}[1]{\mathsf{E}\left(#1\right)} \newcommand{\V}[1]{\mathsf{Var}\left(#1\right)} \newcommand{\ols}[1]{\widehat{#1}} \newcommand{\cond}[1]{\left|#1\right.} \newcommand{\abs}[1]{\left|#1\right|} \]

New Course Structure (with dates)

Weekly Forecasts

UK GDP 2014Q4

library(zoo)
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(tseries)
setwd("/home/readejj/Dropbox/Teaching/Reading/ec313/2015/Lecture-3/")
ukgdp <- read.csv("QNA_CSDB_DS.csdb.csv",stringsAsFactors=F)
ukgdp.z <- zooreg(ukgdp$IHYQ,start=c(1955,2),frequency=4)
plot(ukgdp.z,main="UK Quarterly GDP since 1955",ylab="% growth QoQ",xlab="Year")
abline(0,0)

Course Outline

Last week: Mini-recap

Today

  1. Constructing forecasts submitted last week.
    • Plus some forecast errors.
  2. ARIMA Models (Ch. 8).
  3. Non-stationarity.
  4. Structural breaks.

Constructing Dave Forecast

library(gets)
library(forecast)
## Loading required package: timeDate
## This is forecast 5.6
dave <- read.csv("Dave_140115.csv",stringsAsFactors=F)
dave$david.cameron[NROW(dave)] <- NA
dave$Week <- as.Date(substr(dave$Week,1,10))
plot(dave$Week,dave$david.cameron,
     main="Google Search Popularity of David Cameron",
     ylab="Search popularity",xlab="Date",type="l")

dave.isat <- isat(dave$david.cameron,ar=1:3,sis=T)
## 
## IIS block 1 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 2 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 3 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 4 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 5 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 6 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 7 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 8 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 9 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 10 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 11 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 12 of 20...
## 
## Searching path no. 1 out of 21
## Searching path no. 2 out of 21
## Searching path no. 3 out of 21
## Searching path no. 4 out of 21
## Searching path no. 5 out of 21
## Searching path no. 6 out of 21
## Searching path no. 7 out of 21
## Searching path no. 8 out of 21
## Searching path no. 9 out of 21
## Searching path no. 10 out of 21
## Searching path no. 11 out of 21
## Searching path no. 12 out of 21
## Searching path no. 13 out of 21
## Searching path no. 14 out of 21
## Searching path no. 15 out of 21
## Searching path no. 16 out of 21
## Searching path no. 17 out of 21
## Searching path no. 18 out of 21
## Searching path no. 19 out of 21
## Searching path no. 20 out of 21
## Searching path no. 21 out of 21
## 
## IIS block 13 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 14 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 15 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 16 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 17 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 18 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 19 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## IIS block 20 of 20...
## 
## Searching path no. 1 out of 40
## Searching path no. 2 out of 40
## Searching path no. 3 out of 40
## Searching path no. 4 out of 40
## Searching path no. 5 out of 40
## Searching path no. 6 out of 40
## Searching path no. 7 out of 40
## Searching path no. 8 out of 40
## Searching path no. 9 out of 40
## Searching path no. 10 out of 40
## Searching path no. 11 out of 40
## Searching path no. 12 out of 40
## Searching path no. 13 out of 40
## Searching path no. 14 out of 40
## Searching path no. 15 out of 40
## Searching path no. 16 out of 40
## Searching path no. 17 out of 40
## Searching path no. 18 out of 40
## Searching path no. 19 out of 40
## Searching path no. 20 out of 40
## Searching path no. 21 out of 40
## Searching path no. 22 out of 40
## Searching path no. 23 out of 40
## Searching path no. 24 out of 40
## Searching path no. 25 out of 40
## Searching path no. 26 out of 40
## Searching path no. 27 out of 40
## Searching path no. 28 out of 40
## Searching path no. 29 out of 40
## Searching path no. 30 out of 40
## Searching path no. 31 out of 40
## Searching path no. 32 out of 40
## Searching path no. 33 out of 40
## Searching path no. 34 out of 40
## Searching path no. 35 out of 40
## Searching path no. 36 out of 40
## Searching path no. 37 out of 40
## Searching path no. 38 out of 40
## Searching path no. 39 out of 40
## Searching path no. 40 out of 40
## 
## GETS of union of retained IIS indicators... 
## 
## 
## SIS block 1 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 2 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 3 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 4 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 5 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 6 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 7 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 8 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 9 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 10 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 11 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 12 of 20...
## 
## Searching path no. 1 out of 25
## Searching path no. 2 out of 25
## Searching path no. 3 out of 25
## Searching path no. 4 out of 25
## Searching path no. 5 out of 25
## Searching path no. 6 out of 25
## Searching path no. 7 out of 25
## Searching path no. 8 out of 25
## Searching path no. 9 out of 25
## Searching path no. 10 out of 25
## Searching path no. 11 out of 25
## Searching path no. 12 out of 25
## Searching path no. 13 out of 25
## Searching path no. 14 out of 25
## Searching path no. 15 out of 25
## Searching path no. 16 out of 25
## Searching path no. 17 out of 25
## Searching path no. 18 out of 25
## Searching path no. 19 out of 25
## Searching path no. 20 out of 25
## Searching path no. 21 out of 25
## Searching path no. 22 out of 25
## Searching path no. 23 out of 25
## Searching path no. 24 out of 25
## Searching path no. 25 out of 25
## 
## SIS block 13 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 14 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 15 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 16 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 17 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 18 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 19 of 20...
## 
## Searching path no. 1 out of 28
## Searching path no. 2 out of 28
## Searching path no. 3 out of 28
## Searching path no. 4 out of 28
## Searching path no. 5 out of 28
## Searching path no. 6 out of 28
## Searching path no. 7 out of 28
## Searching path no. 8 out of 28
## Searching path no. 9 out of 28
## Searching path no. 10 out of 28
## Searching path no. 11 out of 28
## Searching path no. 12 out of 28
## Searching path no. 13 out of 28
## Searching path no. 14 out of 28
## Searching path no. 15 out of 28
## Searching path no. 16 out of 28
## Searching path no. 17 out of 28
## Searching path no. 18 out of 28
## Searching path no. 19 out of 28
## Searching path no. 20 out of 28
## Searching path no. 21 out of 28
## Searching path no. 22 out of 28
## Searching path no. 23 out of 28
## Searching path no. 24 out of 28
## Searching path no. 25 out of 28
## Searching path no. 26 out of 28
## Searching path no. 27 out of 28
## Searching path no. 28 out of 28
## 
## SIS block 20 of 20...
## 
## Searching path no. 1 out of 39
## Searching path no. 2 out of 39
## Searching path no. 3 out of 39
## Searching path no. 4 out of 39
## Searching path no. 5 out of 39
## Searching path no. 6 out of 39
## Searching path no. 7 out of 39
## Searching path no. 8 out of 39
## Searching path no. 9 out of 39
## Searching path no. 10 out of 39
## Searching path no. 11 out of 39
## Searching path no. 12 out of 39
## Searching path no. 13 out of 39
## Searching path no. 14 out of 39
## Searching path no. 15 out of 39
## Searching path no. 16 out of 39
## Searching path no. 17 out of 39
## Searching path no. 18 out of 39
## Searching path no. 19 out of 39
## Searching path no. 20 out of 39
## Searching path no. 21 out of 39
## Searching path no. 22 out of 39
## Searching path no. 23 out of 39
## Searching path no. 24 out of 39
## Searching path no. 25 out of 39
## Searching path no. 26 out of 39
## Searching path no. 27 out of 39
## Searching path no. 28 out of 39
## Searching path no. 29 out of 39
## Searching path no. 30 out of 39
## Searching path no. 31 out of 39
## Searching path no. 32 out of 39
## Searching path no. 33 out of 39
## Searching path no. 34 out of 39
## Searching path no. 35 out of 39
## Searching path no. 36 out of 39
## Searching path no. 37 out of 39
## Searching path no. 38 out of 39
## Searching path no. 39 out of 39
## 
## GETS of union of retained SIS indicators... 
## 
## Searching path no. 1 out of 4
## Searching path no. 2 out of 4
## Searching path no. 3 out of 4
## Searching path no. 4 out of 4
## 
## GETS of union of ALL retained indicators...
## 
## regressor-matrix is column rank deficient, so dropping 3 regressors
## 
## Searching path no. 1 out of 4
## Searching path no. 2 out of 4
## Searching path no. 3 out of 4
## Searching path no. 4 out of 4

dave.0 <- cbind(dave[4:c(NROW(dave)-1),],dave.isat$aux$mX[,grep("is",dave.isat$aux$mXnames)])
dave.1 <- data.frame("Week"=seq(from=as.Date("2015-01-11"),as.Date("2015-03-22"),by="weeks"),
                     "david.cameron"=rep(NA,11),"iis331"=rep(0,11),"iis332"=rep(0,11),
                     "iis333"=rep(0,11),"sis300"=rep(1,11),"sis327"=rep(1,11),"sis331"=rep(1,11))
dave.mod <- Arima(dave.0$david.cameron, order = c(3,0,0), xreg = dave.0[,3:8])
dave.forc <- forecast(dave.mod,h=11,xreg = dave.1[,3:8])
print(round(dave.forc$mean))
## Time Series:
## Start = 573 
## End = 583 
## Frequency = 1 
##  [1] 5 5 5 5 5 5 5 5 5 5 5
plot(dave.forc,include=50)

Constructing FTSE Forecast

ftse <- read.csv("FTSE_140115.csv",stringsAsFactors=F)
ftse <- ftse[order(as.Date(ftse$Date)),]
plot(as.Date(ftse$Date),ftse$Close,main="FTSE since 1984",ylab="FTSE",xlab="Date",type="l")

ftse.ar <- auto.arima(ftse$Close)
ftse.forc <- forecast(ftse.ar,100)
plot(ftse.forc,include=200)

Constructing Rightmove Forecast

houses <- read.csv("rightmove_140115.csv",stringsAsFactors=F)
houses$DateTime <- as.Date(substr(houses$DateTime,1,8),"%Y%m%d")
houses <- houses[order(houses$DateTime),]
plot(houses$DateTime,houses$Actual,main="Rightmove HPI",ylab="Index",xlab="Date",type="l")
lines(houses$DateTime,houses$Previous,col=2,type="l")
legend("top",lty=1,col=c(1,2),legend=c("Actual","Previous"),bty="n",ncol=2)

houses.mod <- arima(houses$Actual,order=c(1,0,0))
houses.forc <- forecast(houses.mod,h=1)
plot(houses.forc,include=50)

Forecast Errors

dave19 <- read.csv("dave_190115.csv",stringsAsFactors=F)
ftse19 <- read.csv("FTSE_190115.csv",stringsAsFactors=F)
houses19 <- read.csv("rightmove_190115.csv",stringsAsFactors=F)

Forecast Error Distributions

errors <- c(449.7,-100.3,-30.3,-170.3,-100.3,-8.3,-73.3,-199.3,-210.3,123.7,
            -5.3,-0.3,-70.3,-150.3,-161.84,-250.3,-350.3,-50.3,-120.3)
hist(errors,main="Forecast Errors for FTSE Forecasts")

Today: ARIMA (Ch. 8)

8.1 Stationarity and Differencing

Plots of Candidate Stationary Data Series

library(forecast)
library(Quandl)
## Loading required package: xts
library(quantmod)
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.
Quandl.auth("y8y3ezt48WZeqUqq1yQd")
par(mfrow=c(3,3))
nikkei <- read.csv("^nkx_d.csv",stringsAsFactors=F)
nikkei.t <- zooreg(nikkei$Close,order.by=as.Date(nikkei$Date))
plot(nikkei.t,main="(a)",ylab="Daily Closing Price of Nikkei")
plot(diff(nikkei.t,differences=1),main="(b)",ylab="Daily Difference in Nikkei")
getSymbols('TRFVOLUSM227NFWA',src='FRED',return.class="zoo")
##     As of 0.4-0, 'getSymbols' uses env=parent.frame() and
##  auto.assign=TRUE by default.
## 
##  This  behavior  will be  phased out in 0.5-0  when the call  will
##  default to use auto.assign=FALSE. getOption("getSymbols.env") and 
##  getOptions("getSymbols.auto.assign") are now checked for alternate defaults
## 
##  This message is shown once per session and may be disabled by setting 
##  options("getSymbols.warning4.0"=FALSE). See ?getSymbol for more details
## [1] "TRFVOLUSM227NFWA"
plot(TRFVOLUSM227NFWA,main="(c)",ylab="Vehicla Miles Travelled")
football <- read.csv("football.csv",stringsAsFactor=F)
football.z <- zooreg(football$x,order.by=football$Group.1)
plot(football.z,ylab="Ratio of home to away wins",main="(d)")
getSymbols('UNRATE',src='FRED',return.class="zoo")
## [1] "UNRATE"
plot(UNRATE,ylab="Unemployment Rate (in US)",main="(e)")
getSymbols('PCECC96',src='FRED')
## [1] "PCECC96"
pce.t <- ts(PCECC96,start=c(1947,1),frequency=4)
plot(window(pce.t,start=c(1960,1)),main="(f)",ylab="Personal Consumption Expenditures")
plot(diff(window(log(pce.t),start=c(1960,1)),differences=1),main="(g)",ylab="% change in Personal Consumption Expenditures")
rigs <- Quandl("BKRHUGHES/RIGS_BY_PROV_ALBERTA_LAND")
plot(rigs,type="l")
weather.data.2012 <- read.csv(url("http://www.wunderground.com/history/airport/EGLF/2012/1/1/CustomHistory.html?dayend=31&monthend=12&yearend=2012&req_city=NA&req_state=NA&req_statename=NA&format=1"),stringsAsFactors=F)
weather.data.2013 <- read.csv(url("http://www.wunderground.com/history/airport/EGLF/2013/1/1/CustomHistory.html?dayend=31&monthend=12&yearend=2013&req_city=NA&req_state=NA&req_statename=NA&format=1"),stringsAsFactors=F)
weather.data.2014 <- read.csv(url("http://www.wunderground.com/history/airport/EGLF/2014/1/1/CustomHistory.html?dayend=31&monthend=12&yearend=2014&req_city=NA&req_state=NA&req_statename=NA&format=1"),stringsAsFactors=F)
weather.data.2015 <- read.csv(url("http://www.wunderground.com/history/airport/EGLF/2015/1/1/CustomHistory.html?dayend=31&monthend=12&yearend=2015&req_city=NA&req_state=NA&req_statename=NA&format=1"),stringsAsFactors=F)
weather.data <- rbind(weather.data.2012,weather.data.2013,weather.data.2014,weather.data.2015)
weather.data$date <- as.Date(weather.data$GMT,format="%Y-%m-%d")
plot(weather.data$date,weather.data$Mean.TemperatureC,type="l",ylab="Mean Daily Temperature in Reading",xlab="Date")

8.1 Differencing

ACF of Nikkei

plot(nikkei.t,main="Nikkei")

acf(coredata(nikkei.t),main="ACF of Nikkei")

plot(diff(coredata(nikkei.t),differences=1),main="Daily Returns, Nikkei",type="l")

acf(diff(coredata(nikkei.t),differences=1),main="ACF of Daily Returns, Nikkei")

ACF of unemployment

plot(UNRATE,ylab="Unemployment Rate",xlab="Date")

acf(coredata(UNRATE))

plot(diff(UNRATE,differences=1,lag=12),main="Change in unemployment",type="l")

acf(diff(coredata(UNRATE),differences=1,lag=12),main="ACF of Daily Returns, Nikkei")

8.1 Random Walk Model

8.1 Second-Order Differencing

8.1 Seasonal Differencing

Seasonal Differencing on Vehicle Miles

plot(TRFVOLUSM227NFWA,main="Raw data")

plot(log(TRFVOLUSM227NFWA),main="Log transformation")

plot(diff(log(TRFVOLUSM227NFWA),differences=1,lag=12),main="Seasonally Differenced")

8.1 Unit Root Tests

8.1 Unit Root Testing

adf.test(nikkei.t,alternative="stationary")
## 
##  Augmented Dickey-Fuller Test
## 
## data:  nikkei.t
## Dickey-Fuller = -1.8428, Lag order = 25, p-value = 0.6451
## alternative hypothesis: stationary
kpss.test(nikkei.t)
## Warning in kpss.test(nikkei.t): p-value smaller than printed p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  nikkei.t
## KPSS Level = 34.5268, Truncation lag parameter = 30, p-value =
## 0.01
adf.test(TRFVOLUSM227NFWA,alternative="stationary")
## 
##  Augmented Dickey-Fuller Test
## 
## data:  TRFVOLUSM227NFWA
## Dickey-Fuller = -2.0629, Lag order = 8, p-value = 0.5517
## alternative hypothesis: stationary
kpss.test(TRFVOLUSM227NFWA)
## Warning in kpss.test(TRFVOLUSM227NFWA): p-value smaller than printed
## p-value
## 
##  KPSS Test for Level Stationarity
## 
## data:  TRFVOLUSM227NFWA
## KPSS Level = 8.9275, Truncation lag parameter = 5, p-value = 0.01

8.2 Backshift Notation (The Lag Operator)

8.2 Backshift Notation (The Lag Operator)

8.2 Backshift Notation (The Lag Operator)

8.3 Autoregressive Models

8.4 Moving Average Models

8.4 Moving Average Models

8.4 MA Models

e = rnorm(100)
plot(20 + e[2:100] + 0.8*e[1:99],type="l",main="MA(1)")

plot(e[3:100] - e[2:99] + 0.005*e[1:98],type="l",main="MA(2)")

8.5 Non-Seasonal ARIMA Models

8.5 Non-Seasonal ARIMA Models

8.5 ARIMA

football.auto <- auto.arima(football.z)
plot(forecast(football.auto,h=10),include=80)

8.5 Understanding ARIMA Models

8.5 ACFs and PACFs

ACF and PACF: Brent Crude Oil

boil <- Quandl("DOE/RBRTE")
plot(boil$Date,boil$Value,main="Brent Oil Price",type="l",ylab="Price ($/barrel)",xlab="Date")

acf(boil$Value,main="ACF of Brent Oil Price")

pacf(boil$Value,main="PACF of Brent Oil Price")

ACF and PACF: Copper

copper <- Quandl("OFDP/COPPER_6")
plot(copper$Date,copper$Mid,main="Copper Price",type="l",ylab="Price ($/tonne)",xlab="Date")
lines(copper$Date,copper$Bid,type="l",col=2)
lines(copper$Date,copper$Ask,type="l",col=3)

acf(copper$Mid,main="ACF of Copper Price")

pacf(copper$Mid,main="PACF of Copper Price")

ACF and PACF: Unemployment

plot(UNRATE,main="Unemployment")

acf(coredata(UNRATE))

pacf(coredata(UNRATE))

ACF and PACF: UK GDP

plot(ukgdp.z,main="UK GDP")

acf(coredata(ukgdp.z),main="ACF of UK GDP")

pacf(coredata(ukgdp.z),main="PACF of UK GDP")

8.6 Estimation and Order Selection

8.6 Estimation and Order Selection

8.7 ARIMA Modelling in R

football.arima <- Arima(football.z,order=c(0,0,3))

Modelling Procedure

Example: UK QoQ GDP Growth

ukgdp.t <- ts(ukgdp$IHYQ,start=c(1955,2),frequency=4)
tsdisplay(ukgdp.t)

ukgdp.t0 <- window(ukgdp.t,end=c(1982,2))
tsdisplay(ukgdp.t0)

ukgdp.t1 <- window(ukgdp.t,start=c(1982,3))
tsdisplay(ukgdp.t1)

ukgdp.a1 <- Arima(ukgdp.t1,order=c(1,0,0))
tsdisplay(ukgdp.a1$residuals)

summary(ukgdp.a1)
## Series: ukgdp.t1 
## ARIMA(1,0,0) with non-zero mean 
## 
## Coefficients:
##          ar1  intercept
##       0.5799     0.5786
## s.e.  0.0710     0.1112
## 
## sigma^2 estimated as 0.2875:  log likelihood=-102.84
## AIC=211.69   AICc=211.88   BIC=220.26
## 
## Training set error measures:
##                       ME      RMSE       MAE  MPE MAPE      MASE
## Training set 0.002250977 0.5361739 0.3949923 -Inf  Inf 0.8583874
##                     ACF1
## Training set -0.07141299
ukgdp.a2 <- Arima(ukgdp.t1,order=c(2,0,0))
summary(ukgdp.a2)
## Series: ukgdp.t1 
## ARIMA(2,0,0) with non-zero mean 
## 
## Coefficients:
##          ar1     ar2  intercept
##       0.5056  0.1263     0.5789
## s.e.  0.0870  0.0869     0.1252
## 
## sigma^2 estimated as 0.2828:  log likelihood=-101.8
## AIC=211.59   AICc=211.92   BIC=223.03
## 
## Training set error measures:
##                       ME      RMSE       MAE  MPE MAPE      MASE
## Training set 0.002491449 0.5317836 0.3948206 -Inf  Inf 0.8580142
##                    ACF1
## Training set 0.01698083
ukgdp.a3 <- Arima(ukgdp.t1,order=c(1,0,1))
summary(ukgdp.a3)
## Series: ukgdp.t1 
## ARIMA(1,0,1) with non-zero mean 
## 
## Coefficients:
##          ar1      ma1  intercept
##       0.6835  -0.1565     0.5791
## s.e.  0.0980   0.1271     0.1232
## 
## sigma^2 estimated as 0.2841:  log likelihood=-102.09
## AIC=212.18   AICc=212.51   BIC=223.62
## 
## Training set error measures:
##                       ME     RMSE       MAE  MPE MAPE      MASE
## Training set 0.002325168 0.533027 0.3962993 -Inf  Inf 0.8612276
##                      ACF1
## Training set -0.009506348
ukgdp.auto <- auto.arima(ukgdp.t1)
summary(ukgdp.auto)
## Series: ukgdp.t1 
## ARIMA(2,0,1)(2,0,0)[4] with non-zero mean 
## 
## Coefficients:
##          ar1     ar2     ma1     sar1     sar2  intercept
##       0.0360  0.4256  0.4910  -0.0314  -0.0995     0.5774
## s.e.  0.2671  0.1647  0.2772   0.0972   0.0953     0.1125
## 
## sigma^2 estimated as 0.2769:  log likelihood=-100.49
## AIC=214.98   AICc=215.91   BIC=235
## 
## Training set error measures:
##                       ME      RMSE       MAE  MPE MAPE      MASE
## Training set 0.002985056 0.5262004 0.3860422 -Inf  Inf 0.8389371
##                    ACF1
## Training set 0.01640524
tsdisplay(ukgdp.auto$residuals)

8.8 Forecasting

8.8 Forecasting

8.8 Forecasting

8.9 Seasonal ARIMA Modelling

Example: Japanese Exports

getSymbols('XTEXVA01JPM664N',src='FRED',return.class="zoo")
## [1] "XTEXVA01JPM664N"
exp.t <- ts(log(XTEXVA01JPM664N),start=c(1955,1),freq=12)
tsdisplay(exp.t)

exp.t.s <- diff(exp.t,differences=1,lag=12)
tsdisplay(exp.t.s)

#exp.t.s.1 <- diff(exp.t.s,differences=1)
#tsdisplay(exp.t.s.1)
exp.t.s.a1 <- Arima(exp.t,order=c(5,0,0),seasonal=c(0,1,0))
tsdisplay(exp.t.s.a1$residuals)

exp.t.auto <- auto.arima(exp.t)
## Warning in auto.arima(exp.t): Unable to fit final model using maximum
## likelihood. AIC value approximated

Export Forecasts

exp.forc <- forecast(exp.t.s.a1,h=20)
plot(exp.forc,include=100)

Concluding and Feedback