Forecasting
Forecasting
MAS 640 – Time Series Analysis and Forecasting
2/7/2018
Forecasting
I Predicting future values is often the main goal of a time series
analysis
I Prediction generally a more difficult problem than estimation
I Parameters are fixed but unknown
I Future values are random, not fixed
Minimum Mean Square Error Forecasting
I Our goal is to forecast the value Yt+l using the available
history of the series Y1,Y2, …,Yt .
I We will use Minimum Mean Square Error (MMSE) Forecasting,
which minimizes
E
{
[Yt+l − Ŷt+l ]2
}
I Solution:
Ŷt+l = E (Yt+l |Y1,Y2, …,Yt)
Forecasting with Deterministic Trend Models
Yt = µt + Xt
I µt a deterministic trend
I Xt white noise with mean 0 and variance σ2
Forecasting with Deterministic Trend Models
To forecast l steps into the future. . .
Ŷt+l = E (Yt+l |Y1, …,Yt) = E (µt+l + Xt |Y1, …,Yt) = µt+l
Example – GNP
Quarterly US GNP
Time
g
n
p
1950 1960 1970 1980 1990 2000
2
0
0
0
4
0
0
0
6
0
0
0
8
0
0
0
Example – GNP
(Intercept) t t2
6462325.4823 -6680.9788 1.7271
I Forecast next quarter – Q4 2002?
I Forecast next year – Q3 2003?
I Forecast for Q1 2018?
Drawbacks
I Forecasts from deterministic trend models based only on least
squares fit, ignores potential correlation.
I Forecast for Yt+1 ignores correlation with Y1,Y2, · · · ,Yt
I Assumes fitted trend is applicable indefinitely into the future,
i.e. “forever trend”
Forecasting with ARIMA models
I Forecasting with ARIMA / time series models is no different
than forecasting with your typical regression models
I You estimated a function, simply carry that function forward
Forecasting with ARIMA models
I Yt is a function of past values of Y and/or past errors.
I When we forecast beyond Yt , we might need values that
haven’t yet been observed.
I Consider the following AR(2) model
Yt = φ1Yt−1 + φ2Yt−2 + et
Forecasting with ARIMA models
In the forecast for 2 periods ahead, the formula requires Yt+1 which
has yet to be observed. Simply plug in the forecasted value for Yt+1.
Note that the et ’s are gone, why?
I Ŷt+1 = φ1Yt + φ2Yt−1
I Ŷt+2 = φ1Yt+1 + φ2Yt
Example
I Suppose that Yt follows an AR(1) process with φ = 0.5.
I Suppose we have observed -.38, -.51, and .57 for times 1, 2,
and 3.
I What is the forecast for Y4,Y5 and Y6?
Forecasting a Series with Non-zero Mean
I Suppose now that we have an AR(1) process with a non-zero
mean, µ.
I Before we fit an AR model to the series, we would remove this
mean (either differencing or detrending)
Yt − µ = φ(Yt−1 − µ) + et
Forecasting a Series with Non-zero Mean
I Carrying this forward
Yt+1 − µ = φ(Yt − µ) + et+1
I Taking expected value (for the forecast. . . )
E (Yt+1 − µ) = E [φ(Yt − µ) + et+1]
E (Yt+1)− µ = φ(Yt − µ)
Ŷt+1 = µ+ φ(Yt − µ)
Example
I Suppose Yt follows an AR(1) with φ = .8 and µ = 10
I Suppose we have observed 9.36, 10.72, and 10.06 for times 1,
2, and 3.
I What is the forecast for Y4 and Y5?
Forecasting with MA Models
Suppose we have the following MA(1) model
Yt = θet−1 + et
I MA models have no correlation beyond lag q. What does this
imply about forecasting?
Forecasting with MA Models
I Yt+1
Yt+1 = θet + et+1
I Ŷt+1
Ŷt+1 = θet + E (et+1) = θet
Forecasting with MA Models
I Yt+2
Yt+2 = θet+1 + et+2
I Ŷt+2
Ŷt+2 = θE (et+1) + E (et+2) = 0
MA models will flatline after lag q!
Example – Forecasting an MA(2) Model
Time
y
0 10 20 30 40 50 60
−
2
−
1
0
1
2
Example – Forecasting an MA(3) Model
Time
y
0 10 20 30 40 50 60
−
1
0
1
2
R Code
1. Use arima() then predict()
m <- arima(y, order=c(0, 0, 1)) preds <- predict(m, n.ahead=10) preds$pred preds$se 2. Use sarima.for() m <- sarima.for(y, n.ahead=10, 0, 0, 1) m$pred m$se Can construct confidence intervals manually in the usual way if needed. . . Prediction ± Zα/2StdError Simulation - Final Plot Figure 1: