Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

33
Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index Data set: Swedish Consumer Price Index” sparetime

description

Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index Data set: Swedish Consumer Price Index”. sparetime. - PowerPoint PPT Presentation

Transcript of Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Page 1: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Tutorial for solution of Assignment week 40

“Forecasting monthly values of Consumer Price Index

Data set: Swedish Consumer Price Index”

sparetime

Page 2: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“Construct a time series graph for the monthly values of Consumer Price Index (Konsumentprisindex (KPI) in Swedish) for spare time occupation, amusement and culture (fritid, nöje och kultur in Swedish) (in file ‘sparetime.txt’).”

CPI(

gro

up))

YearMonth

1998199519921989198619831980janjanjanjanjanjanjan

200

180

160

140

120

100

Time Series Plot of CPI(group))

Page 3: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“Then estimate the autocorrelations and display them in a graph.”

Lag

Auto

corr

ela

tion

5550454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

Autocorrelation Function for CPI(group))(with 5% significance limits for the autocorrelations)

“Is there any obvious upward or downward trend?”

Yes, upward, but turning at the endCPI(

gro

up))

YearMonth

1998199519921989198619831980janjanjanjanjanjanjan

200

180

160

140

120

100

Time Series Plot of CPI(group))

Page 4: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“Are there any signs of long-time oscillations in the time series?

CPI(

gro

up))

YearMonth

1998199519921989198619831980janjanjanjanjanjanjan

200

180

160

140

120

100

Time Series Plot of CPI(group))

Are there any signs of seasonal variation in the series?”

No!

Not visible!

Page 5: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“Do the autocorrelations cancel out quickly?”

Lag

Auto

corr

ela

tion

5550454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

Autocorrelation Function for CPI(group))(with 5% significance limits for the autocorrelations)

No!

“Judge upon the need for differentiation according to

ut = yt - yt-1

or

vt = yt - yt-12

to get a time series that is suitable for forecasting with ARMA-models. Construct new graphs for the series obtained by differentiation and estimate the autocorrelations for these series.”

Page 6: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index
Page 7: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

ut = yt – yt - 1

u

YearMonth

1998199519921989198619831980janjanjanjanjanjanjan

3

2

1

0

-1

-2

Time Series Plot of u

Lag

Auto

corr

ela

tion

5550454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

Autocorrelation Function for u(with 5% significance limits for the autocorrelations)

Diffuse pattern!

Not convincingly stationary!

Page 8: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

vt = yt – yt - 12

v

YearMonth

1998199519921989198619831980janjanjanjanjanjanjan

15

10

5

0

-5

Time Series Plot of v

Lag

Auto

corr

ela

tion

50454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

Autocorrelation Function for v(with 5% significance limits for the autocorrelations)

Definitely non-stationary!

Page 9: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“E.2. Fitting different ARMA-models

Try different combinations of ARMA-models and differentiation to forecast the Consumer Price Index. Which model seems to give the best forecasts in this case.”

From E.1.: Seems to be best to use first-order non-seasonal differences

Chosen “design”:

AR(1), AR(2)

MA(1), MA(2)

ARMA(1,1), ARMA(2,1), ARMA(1,2), ARMA(2,2)

Page 10: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Fixed to 1 in all models!

Altered from model to model

Page 11: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

AR(1):

AR(2):

Type Coef SE Coef T P

AR 1 0.1170 0.0671 1.75 0.082

Constant 0.38522 0.04779 8.06 0.000

MS = 0.512 DF = 222

Modified Box-Pierce (Ljung-Box) Chi-Squ

Lag 12 24 36 48

P-Value 0.000 0.000 0.000 0.000

Type Coef SE Coef T P

AR 1 0.0770 0.0648 1.19 0.236

AR 2 0.3012 0.0655 4.60 0.000

Constant 0.27053 0.04576 5.91 0.000

MS = 0.469 DF = 221

Modified Box-Pierce (Ljung-Box) Chi-Squ

Lag 12 24 36 48

P-Value 0.007 0.003 0.001 0.003

2 months forecasts:

Forecast Lower Upper

195.472 194.070 196.875

195.925 193.823 198.027

2 months forecasts:

Forecast Lower Upper

194.962 193.620 196.305

195.720 193.747 197.693

Page 12: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

MA(1):

MA(2):

Type Coef SE Coef T P

MA 1 -0.0741 0.0675 -1.10 0.273

Constant 0.43605 0.05146 8.47 0.000

MS = 0.514 DF = 222

Modified Box-Pierce (Ljung-Box) Chi-Squ

Lag 12 24 36 48

P-Value 0.000 0.000 0.000 0.000

Type Coef SE Coef T P

MA 1 -0.0592 0.0668 -0.89 0.376

MA 2 -0.2533 0.0670 -3.78 0.000

Constant 0.43664 0.06071 7.19 0.000

MS = 0.479 DF = 221

Modified Box-Pierce (Ljung-Box) Chi-Squ

Lag 12 24 36 48

P-Value 0.000 0.000 0.000 0.000

2 months forecasts:

Forecast Lower Upper

195.430 194.024 196.835

195.866 193.803 197.929

2 months forecasts:

Forecast Lower Upper

195.146 193.789 196.503

196.032 194.056 198.009

Page 13: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

ARMA(1,1):

ARMA(2,1):

* WARNING * Back forecasts not dying out rapidly

Type Coef SE Coef T P

AR 1 1.0186 0.0238 42.85 0.000

MA 1 0.9769 0.0006 1560.10 0.000

Constant -0.0117678 -0.0013602 8.65 0.000

MS = 0.458 DF = 221

Modified Box-Pierce (Ljung-Box) Chi-Squ

Lag 12 24 36 48

P-Value 0.000 0.000 0.000 0.000

Type Coef SE Coef T P

AR 1 0.3311 0.2045 1.62 0.107

AR 2 0.2711 0.0764 3.55 0.000

MA 1 0.2821 0.2129 1.33 0.186

Constant 0.17191 0.03287 5.23 0.000

MS = 0.469 DF = 220

Modified Box-Pierce (Ljung-Box) Chi-Squ

Lag 12 24 36 48

P-Value 0.004 0.001 0.000 0.001

2 months forecasts:

Forecast Lower Upper

194.516 193.190 195.843

194.114 192.199 196.029

2 months forecasts:

Forecast Lower Upper

194.746 193.403 196.088

195.300 193.355 197.246

Page 14: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

ARMA(1,2):

ARMA(2,2):

Type Coef SE Coef T P

AR 1 0.6136 0.1635 3.75 0.000

MA 1 0.5577 0.1679 3.32 0.001

MA 2 -0.2202 0.0763 -2.89 0.004

Constant 0.16753 0.03043 5.51 0.000

MS = 0.472 DF = 220

Modified Box-Pierce (Ljung-Box) Chi-Squ

Lag 12 24 36 48

P-Value 0.002 0.001 0.000 0.000

* ERROR * Model cannot be estimated with these data.

2 months forecasts:

Forecast Lower Upper

194.728 193.382 196.075

195.214 193.256 197.173

Page 15: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

None of the models are satisfactory in goodness-of-fit and prediction intervals are quite similar (slightly more narrow for the more complex models).

Maybe second-order non-seasonal differences would work?

wt = ut – ut – 1 = (yt – yt – 1) – (yt – 1 – yt – 2) = yt – 2yt – 1 + yt – 2

Page 16: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

w

YearMonth

1998199519921989198619831980janjanjanjanjanjanjan

4

3

2

1

0

-1

-2

-3

Time Series Plot of w

Lag

Auto

corr

ela

tion

5550454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

Autocorrelation Function for w(with 5% significance limits for the autocorrelations)

Clear seasonal correlation and close to non-stationary

Page 17: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

How about first order seasonal differences on the first-order non-seasonal differences?

zt = ut – ut – 12 = (yt – yt – 1) – (yt – 12 – yt – 13)

Page 18: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

z

YearMonth

1998199519921989198619831980janjanjanjanjanjanjan

2

1

0

-1

-2

Time Series Plot of z

Lag

Auto

corr

ela

tion

50454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

Autocorrelation Function for z(with 5% significance limits for the autocorrelations)

Much more a stationary look!

Page 19: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Lag

Auto

corr

ela

tion

50454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

Autocorrelation Function for z(with 5% significance limits for the autocorrelations)

Lag

Part

ial A

uto

corr

ela

tion

50454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

Partial Autocorrelation Function for z(with 5% significance limits for the partial autocorrelations)

Tricky to identify the correct model.

Clearly a seasonal model must be used, most probably with at least one MA –term

Non-seasonal part more difficult. ARMA(1,1) ?

Page 20: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Try ARIMA(1,1,1,0,1,1)12

Page 21: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Type Coef SE Coef T P

AR 1 -0.6368 1.2524 -0.51 0.612

MA 1 -0.6085 1.2902 -0.47 0.638

SMA 12 0.8961 0.0484 18.51 0.000

Constant -0.07528 0.01129 -6.67 0.000

Differencing: 1 regular, 1 seasonal of order 12

Number of observations: Original series 225, after differencing 212

Residuals: SS = 77.9325 (backforecasts excluded)

MS = 0.3747 DF = 208

Modified Box-Pierce (Ljung-Box) Chi-Square statistic

Lag 12 24 36 48

Chi-Square 12.9 22.8 28.9 36.0

DF 8 20 32 44

P-Value 0.115 0.300 0.626 0.800

2 months forecasts:

Forecast Lower Upper

194.971 193.771 196.171

195.580 193.907 197.253

Page 22: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Compare with ARIMA(0,1,0,0,1,1)12

Type Coef SE Coef T P

SMA 12 0.9039 0.0472 19.15 0.000

Constant -0.045964 0.006893 -6.67 0.000

Differencing: 1 regular, 1 seasonal of order 12

Number of observations: Original series 225, after differencing 212

Residuals: SS = 78.0539 (backforecasts excluded)

MS = 0.3717 DF = 210

Modified Box-Pierce (Ljung-Box) Chi-Square statistic

Lag 12 24 36 48

Chi-Square 12.5 21.8 28.0 34.8

DF 10 22 34 46

P-Value 0.254 0.475 0.757 0.887

Slightly smaller MS!

2 months forecasts:

Forecast Lower Upper

194.987 193.792 196.182

195.587 193.897 197.277

Page 23: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“E.3. Residual analysis

Construct a graph for the residuals (the one-step-ahead prediction errors) and examine visually if there is any pattern in the residuals indicating that the selected forecasting model is not optimal.”

Residual plots for

ARIMA(1,1,1,0,0,0)

ARIMA(1,1,1,0,1,1)12

ARIMA(0,1,0,0,1,1)12

Page 24: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

ARIMA(1,1,1,0,0,0):

Lag

Auto

corr

ela

tion

5550454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

ACF of Residuals for CPI(group))(with 5% significance limits for the autocorrelations)

Lag

Part

ial A

uto

corr

ela

tion

5550454035302520151051

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

PACF of Residuals for CPI(group))(with 5% significance limits for the partial autocorrelations)

Residual

Perc

ent

210-1-2

99.9

99

90

50

10

1

0.1

Fitted Value

Resi

dual

200175150125100

2

1

0

-1

-2

Residual

Fre

quency

1.81.20.60.0-0.6-1.2

30

20

10

0

Observation Order

Resi

dual

220200180160140120100806040201

2

1

0

-1

-2

Normal Probability Plot of the Residuals Residuals Versus the Fitted Values

Histogram of the Residuals Residuals Versus the Order of the Data

Residual Plots for CPI(group))

Non-satisfactory

Page 25: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

ARIMA(1,1,1,0,1,1)12

Lag

Auto

corr

ela

tion

4842363024181261

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

ACF of Residuals for CPI(group))(with 5% significance limits for the autocorrelations)

Lag

Part

ial A

uto

corr

ela

tion

4842363024181261

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

PACF of Residuals for CPI(group))(with 5% significance limits for the partial autocorrelations)

Residual

Perc

ent

210-1-2

99.9

99

90

50

10

1

0.1

Fitted Value

Resi

dual

200175150125100

1

0

-1

-2

ResidualFre

quency

1.20.60.0-0.6-1.2

30

20

10

0

Observation Order

Resi

dual

220200180160140120100806040201

1

0

-1

-2

Normal Probability Plot of the Residuals Residuals Versus the Fitted Values

Histogram of the Residuals Residuals Versus the Order of the Data

Residual Plots for CPI(group))

Satisfactory!

Page 26: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

ARIMA(0,1,0,0,1,1)12

Lag

Auto

corr

ela

tion

4842363024181261

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

ACF of Residuals for CPI(group))(with 5% significance limits for the autocorrelations)

Lag

Part

ial A

uto

corr

ela

tion

4842363024181261

1.0

0.8

0.6

0.4

0.2

0.0

-0.2

-0.4

-0.6

-0.8

-1.0

PACF of Residuals for CPI(group))(with 5% significance limits for the partial autocorrelations)

Residual

Perc

ent

210-1-2

99.9

99

90

50

10

1

0.1

Fitted Value

Resi

dual

200175150125100

2

1

0

-1

-2

ResidualFre

quency

1.20.60.0-0.6-1.2

40

30

20

10

0

Observation Order

Resi

dual

220200180160140120100806040201

2

1

0

-1

-2

Normal Probability Plot of the Residuals Residuals Versus the Fitted Values

Histogram of the Residuals Residuals Versus the Order of the Data

Residual Plots for CPI(group))

Satisfactory!

Page 27: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“F. ARMA-models and exponential smoothing

Data set: The Dollar-Danish Crowns Exchange rates

Consider the time series of monthly exchange rates US$/DKK.”

Page 28: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“At first, calculate forecasts by using exponential smoothing and note the prediction formula.”

Exch

ange r

ate

YearMonth

19981997199619951994199319921991janjanjanjanjanjanjanjan

10

8

6

4

2

0

Time Series Plot of Exchange rate

Exch

ange r

ate

YearMonth

19981997199619951994199319921991janjanjanjanjanjanjanjan

7.0

6.5

6.0

5.5

Time Series Plot of Exchange rate

Change scale so that y-axis starts at 0 (and ends at 10)

Single exponential smoothing will probably work well.

Optimize

Page 29: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Calculate forecasts for 6 months (an arbitrarily chosen value)

Page 30: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Index

Exch

ange r

ate

1009080706050403020101

7.0

6.5

6.0

5.5

Alpha 0.995540Smoothing Constant

MAPE 2.41996MAD 0.14983MSD 0.03784

Accuracy Measures

ActualFitsForecasts95.0% PI

Variable

Single Exponential Smoothing Plot for Exchange rate

Prediction formula:

1

1

0045.09955.0

TT

TTTT

y

yy

Forecasts

Period Forecast Lower Upper

96 6.31118 5.94410 6.67825

97 6.31118 5.94410 6.67825

98 6.31118 5.94410 6.67825

99 6.31118 5.94410 6.67825

100 6.31118 5.94410 6.67825

101 6.31118 5.94410 6.67825

Page 31: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“Then calculate forecasts by fitting a MA(1)-model to first differences of the original series (i.e. you must differentiate the series once).”

Page 32: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

Time

Exch

ange r

ate

1009080706050403020101

7.5

7.0

6.5

6.0

5.5

Time Series Plot for Exchange rate(with forecasts and their 95% confidence limits)

Forecasts from period 95

95 Percent

Limits

Period Forecast Lower Upper

96 6.31652 5.92916 6.70387

97 6.32189 5.77550 6.86828

98 6.32726 5.65864 6.99587

99 6.33263 5.56091 7.10434

100 6.33800 5.47542 7.20057

101 6.34336 5.39862 7.28811

“How does the prediction formula look like in this case?”

Final Estimates of Parameters

Type Coef SE Coef

MA 1 0.0052 0.1043

Constant 0.00537 0.02027

Page 33: Tutorial for solution of Assignment week 40 “Forecasting monthly values of Consumer Price Index

“How do the forecasts differ between the two different methods of forecasting?”

Forecasts

Period Forecast Lower Upper

96 6.31118 5.94410 6.67825

97 6.31118 5.94410 6.67825

98 6.31118 5.94410 6.67825

99 6.31118 5.94410 6.67825

100 6.31118 5.94410 6.67825

101 6.31118 5.94410 6.67825

Forecasts from period 95

95 Percent

Limits

Period Forecast Lower Upper

96 6.31652 5.92916 6.70387

97 6.32189 5.77550 6.86828

98 6.32726 5.65864 6.99587

99 6.33263 5.56091 7.10434

100 6.33800 5.47542 7.20057

101 6.34336 5.39862 7.28811

SES ARIMA(0,1,1)

Index

Exch

ange r

ate

1009080706050403020101

7.0

6.5

6.0

5.5

Alpha 0.995540Smoothing Constant

MAPE 2.41996MAD 0.14983MSD 0.03784

Accuracy Measures

ActualFitsForecasts95.0% PI

Variable

Single Exponential Smoothing Plot for Exchange rate

Time

Exch

ange r

ate

1009080706050403020101

7.5

7.0

6.5

6.0

5.5

Time Series Plot for Exchange rate(with forecasts and their 95% confidence limits)