0% found this document useful (0 votes)
41 views

Time Series Notes9

1) Diagnostic checking of residuals from an initially selected ARIMA model revealed the residuals followed an AR(2) or MA(2) process. Testing additional models found a SARIMA(0,1,2)x(2,1,2)4 model had the lowest AICc. 2) Standard errors of coefficients from the initially selected SARIMA(4,1,0)x(0,1,1)12 model suggested setting AR(1), AR(2), and AR(3) coefficients to zero, lowering the AICc further. 3) Forecasting a transformed and differenced time series involved fitting an ARIMA model, forecasting the

Uploaded by

Sam Skywalker
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Time Series Notes9

1) Diagnostic checking of residuals from an initially selected ARIMA model revealed the residuals followed an AR(2) or MA(2) process. Testing additional models found a SARIMA(0,1,2)x(2,1,2)4 model had the lowest AICc. 2) Standard errors of coefficients from the initially selected SARIMA(4,1,0)x(0,1,1)12 model suggested setting AR(1), AR(2), and AR(3) coefficients to zero, lowering the AICc further. 3) Forecasting a transformed and differenced time series involved fitting an ARIMA model, forecasting the

Uploaded by

Sam Skywalker
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

NOTES - 9

FORECASTING

1
2
3
Innovations/Forecasting of MA(q)

4
5
6
7
MA estimation using Innovations?

8
Time Series Objective

To predict future observations, using past data. One would


like to predict future interest rates, future sales, earnings,
unemployment rate etc.

Assumption:

Future behaves as a past, i.e. It is described by the same


model. Hence you should check your model frequently.

9
Prior to Forecasting
• Model identification
• Parameter estimation
• Model adequacy

Hence the model should be complete with all


the parameters estimated.

10
Forecasting basics
• We observe values 𝑋1 = 𝑥1 , 𝑋2 = 𝑥2 , … , 𝑋𝑛 = 𝑥𝑛 .
• We need to forecast the future values: 𝑋𝑛+ℎ .

ℎ is called as the “lead time”

• When ℎ = 1, we get a one-step ahead predictor


𝑋෠𝑛+1 .

11
12
Forecasting AR(1): 𝑋𝑡 = 𝜙1 𝑋𝑡−1 + 𝑍𝑡

For a stationary AR(1) model with a large lead time h, the


best forecast will eventually converge to 0 = mean of the
process.

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 + ⋯ + 𝜃𝑞 𝑍𝑡−𝑞 , 𝑛>𝑞

Apply Innovation Algorithm

One step ahead predictor:

17
Forecasting Recap so far…

18
Forecast of a transformed series

19
A few properties

• Often, 𝑌𝑡 is approximately Normal

• Hence, 𝑉𝑡 is approximately Lognormal

• The log transformation preserves the median

• Thus, 𝑉෠𝑛 (𝑙) minimizes the mean absolute forecast


error

20
The Devil is in Details

1. Forecasting for data that was transformed and differenced


2. Using diagnostic checking to improve model
3. Using standard error of the coefficients to improve model

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)

Transformed data y.tr Transformed and differenced data y.tr.diff1

23
Example 1: Forecasting transformed and differenced data from extralab
# Check acf/pacf
> acf(y.tr.diff1)
> pacf(y.tr.diff1)

From PACF: suspect AR(5) or AR(6)

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

Order selected 6 sigma^2 estimated as 1.066


# Fit AR(6) model to transformed, differenced data set using ML estimation

> fit = arima(y.tr, order = c(6, 1, 0), method = "ML“, xreg=1 : length(y.tr))

# middle element of 'order' is 1 because we are differencing y.tr once to get a


stationary time series. Note that we fit transformed dataset into ARIMA.
NOTE: THIS EXAMPLE IS TO ILLUSTRATE FORECASTING FOR TRANSFORMED AND
DIFFERENCED DATA. WE MOVE TO FORECASTING SKIPPING MANY STEPS.
25
Example 1: Forecasting transformed and differenced data from extralab
# Forecast next 10 observations of transformed time series

>pred.tr <- predict(fit, n.ahead = 10, newxreg=(length(y.tr)+1) : length(y.tr)+10))

> 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

> ts.plot(y.tr, xlim=c(1,length(y.tr)+10), ylim = c(0,max(U.tr))) #plot y.tr and forecast


> lines(U.tr, col="blue", lty="dashed")
> lines(L.tr, col="blue", lty="dashed")
> points((length(y.tr)+1):(length(y.tr)+10), pred.tr$pred, col="red")

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

# Plot forecasts with original data


> ts.plot(y, xlim=c(1,length(y)+10), ylim = c(0,max(U)))
> lines(U, col="blue", lty="dashed")
> lines(L, col="blue", lty="dashed")
> points((length(y)+1):(length(y)+10), pred.orig, col="red")

27
Example 1: Forecasting transformed and differenced data from extralab
# FORECASTS OF THE ORIGINAL DATA

# to plot the last 10 values plus forecast:


> ts.plot(y, xlim=c(length(y)-10,length(y)+10), ylim = c(0,max(U)))
> points((length(y)+1):(length(y)+10),pred.orig, col="red")
> lines((length(y)+1):(length(y)+10),U, lty=2, col="blue")
> lines((length(y)+1):(length(y)+10),L, lty=2, col="blue")

28
Example 2: use of diagnostic checking to correct originally picked model

Based on preliminary estimation, MLE, and minimum AICC, model chosen:


Model 5: SARIMA (0,1,0) × (2,1,2)4 (p=q=0, P=2, Q=2, s=4) (AICc=7.143)

Diagnostic checking produced the following graphs for ACF/PACF of residuals:

The ACF/PACF of residuals suggest that residuals follow AR(2), MA(2) or


ARMA(2,2). Thus, the following models were tested:

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

diagnostic checking passed. In particular,

Final model:

… improve further? eliminate θ1 ?...


30
Example 3: use of standard errors of the ML estimates of model parameters
to improve the originally picked model
Based on preliminary estimation, MLE, and minimum AICC, model chosen:
Model : SARIMA (4,1,0) × (0,1,1)12 (p=4, q=0, P=0, Q=1, s=12) (AICc= - 533.02)

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

Setting coefficients to zero lowered AICc to -538.1


31
Example 3: use of standard errors of the ML estimates of model parameters
to improve the originally picked model
Based on preliminary estimation, MLE, and minimum AICC, model chosen:
Model : SARIMA (4,1,0) × (0,1,1)12 (p=4, q=0, P=0, Q=1, s=12) (AICc= - 533.02)

Based on confidence intervals , set ar(j), j=1,2,3, to zero:

fit <-arima(tranformeddatasetname, order=c(4,1,0),


seasonal=list(order=c(0,1,1), period=12),
fixed=c(0,0,0, NA,NA))

Final model:

32

You might also like