1 ka-fu wong university of hong kong pulling things together

57
1 Ka-fu Wong University of Hong Kong Pulling Things Together

Post on 21-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

1

Ka-fu WongUniversity of Hong Kong

Pulling Things Together

Page 2: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

2

Forecasting future values of the time series, Y.

We want to forecast YT+1,YT+2,…,YT+H based on a data sample, Y1,…,YT.

Our starting point is to assume that Yt, t = 1,…,T+H can be modeled as (i.e., there is no seasonal component):

Yt = Tt + ct

Tt is the trend component of Yt, which we assume has the form:Tt = β0 + β1t + β2t2 + … βsts

for some positive integer s. That is, we assume that the trend component of Yt can be modeled as a polynomial in t.

The deviations from trend, ct, (which we also refer to as they cyclical component of Yt) are assumed to be a zero-mean covariance stationary time series with an AR(p) representation, i.e.,

ct = φ1ct-1 + … + φpct-p + εt

where εt ~ WN(0,σ2) and the φ’s satisfy the stationarity condition.

Page 3: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

3

Remarks

Seasonal component We are assuming that Yt does not have a seasonal

component. If Yt does have a seasonal component, St, then we would have modeled Y as:

Yt = Tt + St + ct

St may be modeled as “seasonal dummy variables”.

Cyclical component In a more general model, ct may be modeled as

ARMA(p,q) instead of AR(p), as discussed earlier.

Page 4: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

4

Obtaining the point estimate

The h-step ahead forecast of Y given information available at time T, YT+h,T is:

TT+h+cT+h,T= β0+β1(T+h)+...+βs(T+h)s+ cT+h,T

where cT+h,T is the h-step ahead forecast of c implied by the AR(p) model.

In order to make these forecasts operational, we need to select s and p and then estimate the parameters, β0,β1,…,βs,φ1,…,φp in two steps. Select s (AIC, SIC,…) Estimate the β’s, which also yields estimates of c1,…,cT:

Select p, using the c-hats in place of c’s (AIC, SIC,…) Estimate the φ’s by fitting the c-hats to an AR(p) model.

sstt ttYc ˆ...ˆˆˆ 10

Page 5: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

5

Obtaining the forecast Intervals

The 95-percent forecast interval for YT+h will beYT+h,T + 2σh

Where σh is the standard error of the h-step ahead forecast. (90-percent, 99-percent and other forecast intervals can be constructed by replacing “2” with the appropriate percentile of the N(0,1) distribution).

Page 6: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

6

The calculation of σh:

If we ignore the effects that parameter uncertainty contribute to forecast errors, the only source of forecast error will be the fundamental uncertainty associated with forecasting the cyclical component of Y (resulting from our inability to forecast εT+1,..,εT+H).

In this case, the formulas we discussed earlier can be used to estimate σh.

However, by ignoring parameter uncertainty, the resulting forecast intervals will be too small (i.e., the actual “coverage” of the intervals will be less than 95-percent).

Page 7: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

7

The calculation of σh:

The forecast S.E.’s provided by EViews for yT+h,T, properly account for the fundamental uncertainty and parameter uncertainty associated with estimating the AR coefficients φ1,…,φp. So, they are more appropriate than the “simple” formulas for σh discussed earlier.

However, the EViews forecast S.E.s that are constructed through this approach only partially account for parameter uncertainty.

They do not account for the errors associated with estimating the β’s in the trend component of the model.

Page 8: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

8

A One-Step Approach to Forecasting Usingthe Trend-AR Model

Assume, for convenience that Yt = β0 + β1t + ct

ct = φct-1 + εt, εt ~ WN(0,σ2)i.e., a linear trend plus AR(1) model.

Then –1. φYt-1 = φ[β0 + β1(t-1) + ct-1]

= φβ0 + φβ1(t-1) + φct-1

2. Yt - φYt-1 = β0 + β1t + ct – [φβ0 + φβ1(t-1) + φct-1]

= [(1-φ)β0 + φβ1] + β1(1-φ)t + ct - φct-1

= 0 + 1t + εt

where 0 = (1-φ)β0 + φβ1 , 1 = β1(1-φ)

Page 9: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

9

A One-Step Approach to Forecasting Usingthe Trend-AR Model

Hence, Yt = 0 + 1t + φYt-1+ εt

Procedure: Estimate 0, 1, and φ

Forecast YT+1,…,YT+H

YT+1 = 0 + 1(T+1) + φYT + εT+1

YT+1,T = 0 + 1(T+1) + φYT

YT+2 = 0 + 1(T+2) + φYT+1+ εT+2

YT+2,T = 0 + 1(T+2) + φYT+1,T

… YT+H,T = 0 + 1(T+H) + φYT+H-1,T

Page 10: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

10

In EViews

After running the regression of Y on 1,t, and Y(-1), select “Forecast” from the regression output window.

Note that the forecast standard errors that EViews computes will account for the parameter uncertainty regarding 0, 1, and φ (or, equivalently, β0, β1, and φ) rather than simply φ. Important: Your series t must include values for T+1,

…,T+H for this to work.

Page 11: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

11

The more general trend+ AR model.

Yt = β0 + β1t + … + βsts + ct

ct = φ1ct-1 + … + φpct-p + εt

implies Yt =0 +1t+…+sts + φ1Yt-1 +…+ φpYt-p + εt

where the ’s are functions of the β’s and φ’s.

Given s and p –1. Fit this model by OLS to estimate the ’s and φ’s.2. Generate YT+h,T recursively according to

YT+h,T =0 +1(T+h)+…+s(T+h)s + φ1YT+h-1,T +…+ φpYT+h-p,T

where YT+h-s,T = YT+h-s if T+h-s < T.

Page 12: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

12

In EViews

After running the regression of Y on 1, t, and Y(-1),…,Y(-p), select “Forecast” from the regression output window.

Note that the forecast standard errors that EViews will compute will account for the parameter uncertainty regarding ’s and φ’s (or, equivalently, β’s, and φ) rather than simply φ’s.

Important: Your series t must include values for T+1,…,T+H for this to work.

How to select s and p? The same way as before (AIC, SIC…)

Page 13: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

13

Full model

Page 14: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

14

Forecast

Forecast when the parameters have to be estimated:

Forecast when the parameters are known:

Page 15: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

15

Example: Forecasting Liquor Sales1. Plot the data

Observation #1: Seasonal pattern.

Observation #2: an upward time trend, slightly nonlinear.

Observation #3: Variance increasing over time.

Page 16: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

16

2. Transform the data so that the variance appear stabilized.Use Log(x) in this case.

Page 17: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

17

3. Estimate a simple model

Page 18: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

18

Check the residuals

Page 19: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

19

Check Autocorrelations

Page 20: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

20

Check the partial autocorrelations

Page 21: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

21

4. Revise the model

Page 22: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

22

Check the residuals

Page 23: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

23

Check the autocorrelations

Page 24: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

24

Check the partial autocorrelations

Page 25: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

25

5. Revise the model again

Page 26: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

26

Check the residuals

Page 27: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

27

Check the autocorrelations

Page 28: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

28

Check the partial autocorrelations

Page 29: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

29

Check the Ljung-BoxReject the null that the residuals are white noise

Page 30: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

30

Check distribution of residuals (normal?)

Page 31: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

31

6. 12-month-ahead forecast

Page 32: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

32

12-month-ahead forecast with realization

Page 33: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

33

60-month-ahead forecast

Page 34: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

34

60-month-ahead forecast

Page 35: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

35

Transform the forecast back exp(x)

Page 36: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

36

Assessing Model Stability Using Recursive Estimation and Recursive Residuals

Forecast: If the model’s parameters are different during the forecast period than they were during the sample period, then the model we estimated will not be very useful , regardless of how well it was estimated.

Model: If the model’s parameters were unstable over the sample period, then model was not even a good representation of how the series evolved over the sample period.

Page 37: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

37

Are the parameters constant over the sample?

Consider the model of Y that combines the trend and AR(p) components into the following form:

Yt =β0+ β1t + β2t2 +…+βsts +φ1Yt-1+…+φpYt-p+εt

where the ε’s are WN(0,σ2). We will propose using results from applying the recursive

estimation method to evaluate parameter stability over the sample period t = 1,…,T.

Fit the model (by OLS) for t = p+1,…,T*, using increasing number of observations in each estimation.

Regression Data used

1 t= p+1, …, 2p+s+1

2 t = p+1,…, 2p+s+2

3 t = p+1,…, 2p+s+3

… …

T-2p-s t = p+1,…,T

Page 38: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

38

Recursive estimation

The recursive estimation yield parameter estimates for each T*:

and for i = 1,..,s, j = 1,…,p and T* = 2p+s+1,…,T.

If the model is stable over time then what we should find is that as T* increases the recursive parameter estimates should stabilize at some level.

A model parameter is unstable if it does not appear to stabilize as T* increases or if there appears to be a sharp break in the behavior of the sequence before and after some T*.

*,ˆTi *,ˆ Tj

Page 39: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

39

Example: when parameters are stable

Data plot Plot of recursive parameter estimates

Page 40: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

40

Example: when there is a break in parameters

Data plot Plot of recursive parameter estimates

Page 41: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

41

Recursive Residuals and the CUSUM Test

The CUSUM (“cumulative sum”) test is often used to test the null hypothesis of model stability, based on the residuals from the recursive estimates. The CUSUM statistic is calculated for each t. Under the

null hypothesis of stability, the statistic follows the CUSUM distribution.

If the calculated CUSUM statistics appear to be too large to have been drawn from the CUSUM distribution, we reject the null hypothesis (of model stability).

Page 42: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

42

CUSUM

Let et+1,t denote the one-step-ahead forecast error associated with forecasting Yt+1 based on the model fit for over the sample period ending in period t. These are called the recursive residuals.

et+1,t = Yt+1 – Yt+1,t

where the t subscripts on the estimated parameters refers to the fact that they were estimated based on a sample whose last observation was in period t.

]ˆ...ˆ)1(ˆ...)1(ˆˆ[ 1,,1,,1,01 pttptts

tsttt YYttY

t t+1

t+1 t+2

Page 43: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

43

CUSUM

Let σ1,t denote the standard error of the one-step ahead forecast of Y formed at time t, i.e,

σ1,t = sqrt(var(et+1,t))

Define the standardized recursive residuals, wt+1,t, according to

wt+1,t = et+1,t/σ1,t

Fact: Under our maintained assumptions, including model homogeneity,

wt+1,t ~ i.i.d. N(0,1).

Note that there will be a set of standardized recursive residuals for each sample.

Page 44: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

44

CUSUM

The CUSUM (cumulative sum) statistics are defined according to:

for t = k,k+1,…,T-1, where k = 2p+s+1 is the minimum sample size for which we can fit the model.

Under the null hypothesis, the CUSUMt statistic is drawn from a CUSUM(t-k) distribution. The CUSUM(t-k) distribution is a symmetric distribution centered at 0. Its dispersion increases as t-k increases.

We reject the null hypothesis at the 5% significance level if CUSUMt is below the 2.5-percentile or above the 97.5-percentile of the CUSUM(t-k) distribution.

t

kiiit wCUSUM ,1

Page 45: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

45

Example: when parameters are stable

Page 46: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

46

Example: when there is a break in parameters

Page 47: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

47

Accounting for a structural break

Suppose it is known that there is a structural break in the trend of a series in 1998 – due to Asian Financial Crisis.

Page 48: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

48

Structural Breaks in the Trend

Suppose that the trend in yt can be modeled asTt = 0,t + 1,tt

where0,t = 0,1 if t < T0 (T0 <T)

= 0,2 if t > T0

and1,t = 1,1 if t < T0

= 1,2 if t > T0

In this case, TT+h = 0,2 + 1,2(T+h)

Problem – How to estimate 0,2 and 1,2? A bad approach – Regress yt on 1,t for t=1,…,T

Yt = 0,2 + 1,2t + t

Page 49: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

49

Better approaches –

Regress yt on 1,t for t = T0+1,…,T

Problems with this approach – Not an ideal approach if you want to force either the

intercept or slope coefficient to be fixed over the full sample, t = 1,…,T, allowing only one of the coefficients to change at T0.

Does not allow you to test whether the intercept and/slope changed at T0.

Does not provide us with estimated deviations from trend for t = 1,…,T0, which we will want to use to estimate the seasonal and cyclical components of the series to help us forecast those components of the series.

Page 50: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

50

Better approaches

Introduce dummy variables into the regression to jointly estimate 0,1, 0,2, 1,1, 1,2

Let Dt = 0 if t = 1,…,T0

= 1 if t > T0

Run the regression over the full sampleyt = 0 + 1Dt + 2t + 3(Dtt) + t , t = 1,…,T.

Then

Suppose we want to allow 0 to change at T0 but we want to force 1 to remain fixed (i.e., a shift in the intercept of the trend line) – Run the regression of yt on 1, Dt and t to estimate 0, 1, and 2 ( = 1).

322,121,1102,001,0 ˆˆˆ,ˆˆ,ˆˆˆ,ˆˆ

Page 51: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

51

Remarks

This approach extends to higher order polynomials in a straightforward way, allowing one or more parameters to change at one or more points in time.

This approach can be extended to allow for breaks at unknown time(s).

Page 52: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

52

The Liquor sales example againRecursive residuals

Page 53: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

53

Look at the parameter estimates from recursive regressions

Page 54: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

54

Look at the parameter estimates from recursive regressions

Page 55: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

55

Look at the parameter estimates from recursive regressions

Page 56: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

56

Check Cusum

Page 57: 1 Ka-fu Wong University of Hong Kong Pulling Things Together

57

End