Time Series Notes9
Time Series Notes9
FORECASTING
1
2
3
Innovations/Forecasting of MA(q)
4
5
6
7
MA estimation using Innovations?
8
Time Series Objective
Assumption:
9
Prior to Forecasting
• Model identification
• Parameter estimation
• Model adequacy
10
Forecasting basics
• We observe values 𝑋1 = 𝑥1 , 𝑋2 = 𝑥2 , … , 𝑋𝑛 = 𝑥𝑛 .
• We need to forecast the future values: 𝑋𝑛+ℎ .
11
12
Forecasting AR(1): 𝑋𝑡 = 𝜙1 𝑋𝑡−1 + 𝑍𝑡
13
Prediction Error for AR(1)
Consider the differences:
14
Then the prediction error is the Variance (shocks are uncorrelated!)
15
Forecasting AR(p)
𝑋𝑡 = 𝜙1 𝑋𝑡−1 + ⋯ + 𝜙𝑝 𝑋𝑡−𝑝 + 𝑍𝑡
16
Forecasting MA(q)
𝑋𝑡 = 𝑍𝑡 + 𝜃1 𝑍𝑡−1 + ⋯ + 𝜃𝑞 𝑍𝑡−𝑞 , 𝑛>𝑞
17
Forecasting Recap so far…
18
Forecast of a transformed series
19
A few properties
20
The Devil is in Details
21
Example 1: Forecasting transformed and differenced data from “extra lab”
> y <- scan(“extralab.txt") # Load data set from extralab, 150 data points
> ts.plot(y)
# The data has a trend and an increasing variance, therefore requires transformation (first) and then
differencing. To choose parameter λ of the Box-Cox transformation, use:
> require(MASS)
> bcTransform <- boxcox(y ~ as.numeric(1:length(y))) #plots the graph
> bcTransform$x[which(bcTransform$y == max(bcTransform$y))] # gives the value of λ
[1] 0.5050505
#Chose λ=1/2 that is try square root transformation
Original data y 22
Example 1: Forecasting transformed and differenced data from lab 5
> y.tr <- sqrt(y) # square root transformation
> ts.plot(y.tr)
# The transformed data still has a trend , therefore difference at lag1 to remove trend:
> y.tr.diff1 <- diff(y.tr)
> ts.plot(y.tr.diff1)
23
Example 1: Forecasting transformed and differenced data from extralab
# Check acf/pacf
> acf(y.tr.diff1)
> pacf(y.tr.diff1)
24
Example 1: Forecasting transformed and differenced data from extralab
# Find suitable ar(p) model using ar()
> ar(y.tr.diff1, method="yule-walker")
#this produced an output:
Call:
ar(x = y.tr.diff1, method = "yule-walker")
Coefficients:
1 2 3 4 5 6
-0.2466 -0.1354 -0.2251 -0.1949 -0.2368 -0.1583
> fit = arima(y.tr, order = c(6, 1, 0), method = "ML“, xreg=1 : length(y.tr))
> U.tr= pred.tr$pred + 2*pred.tr$se # upper bound for the C.I. for transformed data
> L.tr= pred.tr$pred - 2*pred.tr$se # lower bound
26
Example 1: Forecasting transformed and differenced data from extralab
# RETURN TO ORIGINAL DATA
# get predictions and s.e.'s of transformed time series
> pred.orig <- pred$pred^2 # back-transform to get predictions of original time series
> U= U.tr^2 # bounds of the confidence intervals
> L=L.tr^2
27
Example 1: Forecasting transformed and differenced data from extralab
# FORECASTS OF THE ORIGINAL DATA
28
Example 2: use of diagnostic checking to correct originally picked model
SARIMA (0,1,2) × (2,1,2)4 (p=0, q=2, P=2, Q=2, s=4): AICc = 7.112 Min
SARIMA (2,1,0) × (2,1,2)4 (p=2, q=0, P=2, Q=2, s=4): AICc = 7.117
SARIMA (2,1,2) × (2,1,2)4 (p=2, q=2, P=2, Q=2, s=4): AICc = 7.149
29
Example 2: use of diagnostic checking to correct originally picked model
Work with SARIMA (0,1,2) × (2,1,2)4 (p=0, q=2, P=2, Q=2, s=4): AICc = 7.112 Min
Final model:
Based on confidence intervals for coefficients ar(1), ar(2) and ar(3) we might
assume that these coefficients are zero. Set ar(j)=0, j=1,2,3
Final model:
32