time series in 10am recording spss - open university

81
Time Series in SPSS Dr Jason Verrall [email protected] 07311 188 800 This tutorial will begin at 10am for about an hour. I will be recording this presentation so please let me know if you have any questions or concerns about this. Mics will be muted until the end of the tutorial, when I will also stop recording. Feel free to use the Chat Box at any time! I will email slides out after the tutorial. Tutorials are enhanced by your interaction Please vote in the polls and ask questions! M249 Practical Modern Statistics TMA02 due on 27 January! Things you might need today: M249 Computer Book 2 Note-taking equipment Drink of your choice

Upload: others

Post on 04-May-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Time Series in 10am recording SPSS - Open University

Time Series in SPSS

Dr Jason [email protected]

07311 188 800

• This tutorial will begin at 10am for about anhour.

• I will be recording this presentation soplease let me know if you have anyquestions or concerns about this.

• Mics will be muted until the end of thetutorial, when I will also stop recording.

• Feel free to use the Chat Box at any time!• I will email slides out after the tutorial.

Tutorials are enhanced by your interaction Please vote in the polls and ask questions!

M249 Practical Modern Statistics

TMA02 due on 27 January!

• Things you might need today:• M249 Computer Book 2• Note-taking equipment• Drink of your choice

Page 2: Time Series in 10am recording SPSS - Open University

Time Series in SPSS (Computer Book 2)

• Plotting a Time Series• Estimating Time Series Components

• Additive & non-additive models• ARMA & ARIMA models

• Selecting• Fitting• Evaluating• Forecasting

• Forecasting • Smoothing functions

2

Computer Book 2 has detailed instructions!

M249 Practical Modern Statistics

Page 3: Time Series in 10am recording SPSS - Open University

Trend, Variance and Seasonality

3

Time index

Valu

e (a

rb)

Simulation E How would you describe the trend &

variance in this graph?

Page 4: Time Series in 10am recording SPSS - Open University

Trend, Variance and Seasonality

4

Time index

Valu

e (a

rb)

How would you describe the trend &

variance in this graph?

Changing trend Changing variance

No seasonality

Simulation E

Page 5: Time Series in 10am recording SPSS - Open University

Time Series Plotting

5

Analyze→ Forecasting → Sequence Charts

Data: flow.sav Reference: Computer Book 2 pp. 6-8

Page 6: Time Series in 10am recording SPSS - Open University

Time Series Plotting

6

Analyze→ Forecasting → Sequence Charts

Data: flow.sav Reference: Computer Book 2 pp. 6-8

Page 7: Time Series in 10am recording SPSS - Open University

Time Series Plotting

7

Analyze→ Forecasting → Sequence Charts

Data: flow.sav Reference: Computer Book 2 pp. 6-8

Page 8: Time Series in 10am recording SPSS - Open University

Time Series Plotting

8

Chart Editor → Select X-Axis

Data: flow.sav Reference: Computer Book 2 pp. 6-8

Page 9: Time Series in 10am recording SPSS - Open University

Time Series Plotting

9

Period-1

Chart Editor → Select X-Axis

Data: flow.sav Reference: Computer Book 2 pp. 6-8

Page 10: Time Series in 10am recording SPSS - Open University

Time Series Plotting

10

Chart Editor → Select X-Axis

Data: flow.sav Reference: Computer Book 2 pp. 6-8

Page 11: Time Series in 10am recording SPSS - Open University

Estimating Time Series Components

11

M249 Practical Modern Statistics

• Additive model• Multiplicative model• How to estimate components

• Seasonality• Trend & seasonally-adjusted• Irregular (noise)

Real life has noise.Removing the noise helps to show any underlying structures and patterns

Page 12: Time Series in 10am recording SPSS - Open University

Additive Model

12

Xt = mt + st + WtRandom variable

Page 13: Time Series in 10am recording SPSS - Open University

Additive Model

13

Xt = mt + st + WtRandom variable

Trend componentMay be zero, linear or

changing

Can plug in any estimation here

�𝑚𝑚𝑡𝑡 = 𝑀𝑀𝑀𝑀 𝑡𝑡 ; �𝑚𝑚𝑡𝑡 = 𝑆𝑆𝑀𝑀(𝑡𝑡)

Page 14: Time Series in 10am recording SPSS - Open University

Additive Model

14

Xt = mt + st + WtRandom variable

Trend componentMay be zero, linear or

changingSeasonal component

May be zero or varying periodicity

𝑌𝑌𝑡𝑡 = 𝑋𝑋𝑡𝑡 − 𝑆𝑆𝑀𝑀 𝑡𝑡 = 𝑆𝑆𝑡𝑡 + 𝑊𝑊𝑡𝑡′

Seasonal factors sum to zero�𝑠𝑠𝑗𝑗 = 𝐹𝐹𝑗𝑗 − �𝐹𝐹 for 𝑗𝑗 = [1,𝑇𝑇]

Can plug in any estimation here

�𝑚𝑚𝑡𝑡 = 𝑀𝑀𝑀𝑀 𝑡𝑡 ; �𝑚𝑚𝑡𝑡 = 𝑆𝑆𝑀𝑀(𝑡𝑡)

Page 15: Time Series in 10am recording SPSS - Open University

Additive Model

15

Xt = mt + st + WtRandom variable

Trend componentMay be zero, linear or

changingSeasonal component

May be zero or varying periodicity

Irregular componentNoise, error and everything else

𝑌𝑌𝑡𝑡 = 𝑋𝑋𝑡𝑡 − 𝑆𝑆𝑀𝑀 𝑡𝑡 = 𝑆𝑆𝑡𝑡 + 𝑊𝑊𝑡𝑡′

Seasonal factors sum to zero�𝑠𝑠𝑗𝑗 = 𝐹𝐹𝑗𝑗 − �𝐹𝐹 for 𝑗𝑗 = [1,𝑇𝑇]

𝑍𝑍𝑡𝑡 = 𝑋𝑋𝑡𝑡 − �𝑆𝑆𝑡𝑡 = 𝑚𝑚𝑡𝑡 + 𝑊𝑊𝑡𝑡′

Error usually assumed to be distributed with zero

mean and constant variance

𝑊𝑊𝑡𝑡~(0,𝜎𝜎2)Not independent

(correlogram, histogram)

Can plug in any estimation here

�𝑚𝑚𝑡𝑡 = 𝑀𝑀𝑀𝑀 𝑡𝑡 ; �𝑚𝑚𝑡𝑡 = 𝑆𝑆𝑀𝑀(𝑡𝑡)

Page 16: Time Series in 10am recording SPSS - Open University

Additive Model

16

Time index

Valu

e (a

rb)

Transformed from multiplicative model

Simulation B

Page 17: Time Series in 10am recording SPSS - Open University

Irregular componentNoise, error and everything else

Multiplicative Model

17

Xt = mt x st x WtRandom variable

Page 18: Time Series in 10am recording SPSS - Open University

Multiplicative Model

18

Xt = mt x st x WtRandom variable

Trend componentMay be constant, linear

or changing

Irregular componentNoise, error and everything else

Page 19: Time Series in 10am recording SPSS - Open University

Multiplicative Model

19

Xt = mt x st x WtRandom variable

Trend componentMay be constant, linear

or changingSeasonal component

May be zero or varying periodicity

Seasonal factors sum to 1

Irregular componentNoise, error and everything else

Page 20: Time Series in 10am recording SPSS - Open University

Multiplicative Model

20

Xt = mt x st x WtRandom variable

Trend componentMay be constant, linear

or changingSeasonal component

May be zero or varying periodicity

Seasonal factors sum to 1

Irregular componentNoise, error and everything else

𝑌𝑌𝑡𝑡 = log 𝑋𝑋𝑡𝑡= log 𝑚𝑚𝑡𝑡 × 𝑠𝑠𝑡𝑡 × 𝑊𝑊𝑡𝑡= log 𝑚𝑚𝑡𝑡 + log 𝑠𝑠𝑡𝑡 + log 𝑊𝑊𝑡𝑡

Log transformation

Page 21: Time Series in 10am recording SPSS - Open University

Multiplicative Model

21

Page 22: Time Series in 10am recording SPSS - Open University

Deconstructing A Series

22

How would you describe this time

series?

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Page 23: Time Series in 10am recording SPSS - Open University

Deconstructing A Series

23

Changing trend

Constant variance

Seasonal - annual

How would you describe this time

series?

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Page 24: Time Series in 10am recording SPSS - Open University

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Deconstructing A Series – Seasonal

24

Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Analyze→ Forecasting → Seasonal Decomposition

Page 25: Time Series in 10am recording SPSS - Open University

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Deconstructing A Series – Seasonal

25

Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Analyze→ Forecasting → Seasonal Decomposition

Page 26: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Seasonal

26

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Page 27: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Seasonal

27

Seasonally-Adjusted Series

𝑍𝑍𝑡𝑡 = 𝑋𝑋𝑡𝑡 − �𝑆𝑆𝑡𝑡= 𝑚𝑚𝑡𝑡 + 𝑊𝑊𝑡𝑡

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Page 28: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Seasonal

28� = 1 × 10−5 ≈ 0

Seasonally-Adjusted Series

𝑍𝑍𝑡𝑡 = 𝑋𝑋𝑡𝑡 − �𝑆𝑆𝑡𝑡= 𝑚𝑚𝑡𝑡 + 𝑊𝑊𝑡𝑡

Seasonal Factors

�𝑆𝑆𝑗𝑗 = 𝐹𝐹𝑗𝑗 − �𝐹𝐹

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Page 29: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Seasonal

29

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Follow the book’s advice on renaming SPSS variables!

Page 30: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Trend

30

Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Transform → Create Time Series

Page 31: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Trend

31

Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Order must be ODD

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Transform → Create Time Series

Page 32: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Trend

32

Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Transform → Create Time Series

More informative

variable name

trend

Page 33: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Trend

33

Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Tren

d

Trend Estimate (MA(13))

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Page 34: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Irregular

34

Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Transform → Compute Variable

Page 35: Time Series in 10am recording SPSS - Open University

Deconstructing A Series - Irregular

35

Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Transform → Compute Variable

Page 36: Time Series in 10am recording SPSS - Open University

Deconstructing A Series

36

Irregular Component Estimate Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Analyze→ Forecasting → Sequence Charts

Page 37: Time Series in 10am recording SPSS - Open University

Deconstructing A Series

37

Irregular Component Estimate Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Analyze→ Descriptive Statistics → Descriptives

Analyze→ Forecasting → Sequence Charts

Page 38: Time Series in 10am recording SPSS - Open University

Deconstructing A Series Raw data Estimated seasonal component �𝑆𝑆𝑡𝑡 Estimated trend component �𝑚𝑚𝑡𝑡 Estimated irregular component �𝑊𝑊𝑡𝑡

Unemployment Claimants

Raw claimantsSeasonally-adjusted seriesMoving average (13)

http

s://

desp

icab

lem

e.fa

ndom

.com

/wik

i/Dav

e

38

Data: claimants.sav Reference: Computer Book 2 pp. 16-20

Page 39: Time Series in 10am recording SPSS - Open University

ARMA & ARIMA models

39

M249 Practical Modern Statistics

• Model selection • Fitting a model

• Estimating parameters

• Evaluating a model• Goodness-of-fit

• Forecasting using a model• Predicting future values with prediction intervals

Page 40: Time Series in 10am recording SPSS - Open University

ARMA & ARIMA models

• Book 2 (S14, pp.115-127) goes into some detail about how to select suitable candidate ARMA and ARIMA models

• Principle of Parsimony• Correlogram and partial correlogram indications

40

Page 41: Time Series in 10am recording SPSS - Open University

ARMA & ARIMA models

• Book 2 (S14, pp.115-127) goes into some detail about how to select suitable candidate ARMA and ARIMA models

• Principle of Parsimony• Correlogram and partial correlogram indications

• Here, I’ll show how to build an ARIMA model and we’ll compare the fit of two candidates

41

Page 42: Time Series in 10am recording SPSS - Open University

ARMA & ARIMA models

• Book 2 (S14, pp.115-127) goes into some detail about how to select suitable candidate ARMA and ARIMA models

• Principle of Parsimony• Correlogram and partial correlogram indications

• Here, I’ll show how to build an ARIMA model and we’ll compare the fit of two candidates

42

ARIMA framework assumes that a time series is stationary• Constant mean, variance• The I in ARIMA covers differencing and other

methods to make the series stationary

Page 43: Time Series in 10am recording SPSS - Open University

ARIMA Model Fitting

• We’ll fit two models:• ARIMA (0,0,1): 𝑋𝑋𝑡𝑡 − 𝜇𝜇 = 𝑍𝑍𝑡𝑡 − 𝜃𝜃1𝑍𝑍𝑡𝑡−1

• ARIMA (1,0,0): 𝑋𝑋𝑡𝑡 − 𝜇𝜇 = 𝛽𝛽1 𝑋𝑋𝑡𝑡−1 − 𝜇𝜇 + 𝑍𝑍𝑡𝑡

43

ACF: 𝜌𝜌𝑞𝑞 = −𝜃𝜃11+𝜃𝜃12

ACF: 𝜌𝜌𝑘𝑘 = 𝛽𝛽1𝑘𝑘

Here we have theoreticalmodels we hope fit our

(noisy) real data

Page 44: Time Series in 10am recording SPSS - Open University

ARIMA Model Fitting

• We’ll fit two models:• ARIMA (0,0,1): 𝑋𝑋𝑡𝑡 − 𝜇𝜇 = 𝑍𝑍𝑡𝑡 − 𝜃𝜃1𝑍𝑍𝑡𝑡−1

• ARIMA (1,0,0): 𝑋𝑋𝑡𝑡 − 𝜇𝜇 = 𝛽𝛽1 𝑋𝑋𝑡𝑡−1 − 𝜇𝜇 + 𝑍𝑍𝑡𝑡

• SPSS uses Root Mean Squared Error (RMSE) as the cost function

• 𝑅𝑅𝑀𝑀𝑆𝑆𝑅𝑅 = ∑𝑖𝑖=1𝑛𝑛 𝑥𝑥𝑖𝑖− �𝑥𝑥𝑖𝑖 2

𝑛𝑛• 𝑆𝑆𝑆𝑆𝑅𝑅 = 𝑛𝑛 − 𝑑𝑑 − 𝑘𝑘 𝑅𝑅𝑀𝑀𝑆𝑆𝑅𝑅2

44

ACF: 𝜌𝜌𝑞𝑞 = −𝜃𝜃11+𝜃𝜃12

ACF: 𝜌𝜌𝑘𝑘 = 𝛽𝛽1𝑘𝑘

Here we have theoreticalmodels we hope fit our

(noisy) real data

Page 45: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting

Source data is flow.sav and we’ll use the seasonally-adjusted series

45

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Let’s get modelling

Page 46: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting

46

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Analyze→ Forecasting → Create Traditional Models

Page 47: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting

47

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Analyze→ Forecasting → Create Traditional Models

Set other options as shown in Computer Book 2

Page 48: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting

48

Data: flow.sav Reference: Computer Book 2 pp. 42-55

𝑋𝑋𝑡𝑡 − 𝜇𝜇 = 𝑍𝑍𝑡𝑡 − 𝜃𝜃1𝑍𝑍𝑡𝑡−1

𝑋𝑋𝑡𝑡 − 1.374 = 𝑍𝑍𝑡𝑡 + 0.401𝑍𝑍𝑡𝑡−1

Goodness of fit

Parameters of fit

Page 49: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting – Errors

49

For the model to be a good fit, errors should be uncorrelated and approx. Normal (0,𝜎𝜎2)

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Analyse error distribution

Page 50: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting – Errors

For the model to be a good fit, errors should be uncorrelated and approx. Normal (0,𝜎𝜎2)

50

Graphs → Legacy Dialogs→ HistogramAnalyze→ Descriptives → Explore → Plots

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 51: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting – Errors

For the model to be a good fit, errors should be uncorrelated and approx. Normal (0,𝜎𝜎2)

51

This is a specifictest for

Normality, and is both more

sensitive and more powerful

than K-S.Graphs → Legacy Dialogs→ HistogramAnalyze→ Descriptives → Explore → Plots

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 52: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting – Errors

52

For the model to be a good fit, errors should be uncorrelated and approx. Normal (0,𝜎𝜎2)

Analyze→ Forecasting → Autocorrelations

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 53: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting – Errors

53

For the model to be a good fit, errors should be uncorrelated and approx. Normal (0,𝜎𝜎2)

Analyze→ Forecasting → Autocorrelations

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 54: Time Series in 10am recording SPSS - Open University

ARIMA(0,0,1) Model Fitting – Errors

54

For the model to be a good fit, errors should be uncorrelated and approx. Normal (0,𝜎𝜎2)

Analyze→ Forecasting → Autocorrelations

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 55: Time Series in 10am recording SPSS - Open University

ARIMA(1,0,0) Model Fitting

55

Set other options as shown in Computer Book 2

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 56: Time Series in 10am recording SPSS - Open University

ARIMA(1,0,0) Model Fitting

56

𝑋𝑋𝑡𝑡 − 𝜇𝜇 = 𝛽𝛽1 𝑋𝑋𝑡𝑡−1 − 𝜇𝜇

𝑋𝑋𝑡𝑡 − 1.373 = 0.383 𝑋𝑋𝑡𝑡−1 − 1.373 + 𝑍𝑍𝑡𝑡

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 57: Time Series in 10am recording SPSS - Open University

ARIMA(1,0,0) Model Fitting

57

𝑋𝑋𝑡𝑡 − 𝜇𝜇 = 𝛽𝛽1 𝑋𝑋𝑡𝑡−1 − 𝜇𝜇

𝑋𝑋𝑡𝑡 − 1.373 = 0.383 𝑋𝑋𝑡𝑡−1 − 1.373 + 𝑍𝑍𝑡𝑡

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Goodness of fit

Parameters of fit

Page 58: Time Series in 10am recording SPSS - Open University

ARIMA(1,0,0) Model Fitting

58

For the model to be a good fit, errors should be uncorrelated and approx. Normal (0,𝜎𝜎2)

Graphs → Legacy Dialogs→ HistogramAnalyze→ Descriptives → Explore → Plots

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Analyse error distribution

Page 59: Time Series in 10am recording SPSS - Open University

ARIMA(1,0,0) Model Fitting

59

For the model to be a good fit, errors should be uncorrelated and approx. Normal (0,𝜎𝜎2)

Graphs → Legacy Dialogs→ HistogramAnalyze→ Descriptives → Explore → Plots

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 60: Time Series in 10am recording SPSS - Open University

ARIMA(1,0,0) Model Fitting

60

For the model to be a good fit, errors should be uncorrelated and approx. Normal (0,𝜎𝜎2)

Analyze→ Forecasting → Autocorrelations

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 61: Time Series in 10am recording SPSS - Open University

Model Comparison

61

Serial Model Parsimony(p + q) 𝜇𝜇 Parameter

2 RMSE Ljung-Box p

Error Mean

Error Normality p

A ARIMA(0,0,1) 1 1.374 -0.401 0.563 0.129 4.7x10-4 0.681

B ARIMA(1,0,0) 1 1.373 0.383 0.564 0.164 8.68x10-4 0.722

Which model do you choose – A or B?

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Page 62: Time Series in 10am recording SPSS - Open University

Cautious Forecasting

62

What do all forecasting models

assume?

Page 63: Time Series in 10am recording SPSS - Open University

Cautious Forecasting

63

What do all forecasting models

assume?

All forecasting methods in this module assume that the past

is a guide to the future.

Page 64: Time Series in 10am recording SPSS - Open University

Cautious Forecasting

64

What do all forecasting models

assume?

All forecasting methods in this module assume that the past

is a guide to the future.

Past values can therefore be

used to predict future values.

Page 65: Time Series in 10am recording SPSS - Open University

Cautious Forecasting

65

What do all forecasting models

assume?

All forecasting methods in this module assume that the past

is a guide to the future.

Past values can therefore be

used to predict future values.

This is not always the case!

Page 66: Time Series in 10am recording SPSS - Open University

Forecast with ARIMA (0,0,1)

66

Quite wide prediction intervals compared to observed data variance

Data: flow.sav Reference: Computer Book 2 pp. 42-55

Forecast

Page 67: Time Series in 10am recording SPSS - Open University

Further Reading (OU Library E-books)• Time Series Analysis: Forecasting and Control

• https://pmt-eu.hosted.exlibrisgroup.com/permalink/f/gvehrt/TN_cdi_safari_books_9780470272848

• Forecasting Fundamentals• https://pmt-

eu.hosted.exlibrisgroup.com/permalink/f/h21g24/44OPN_ALMA_DS51128131320002316

• Error analysis for biologists: statistics you can understand• https://pmt-

eu.hosted.exlibrisgroup.com/permalink/f/gvehrt/TN_cdi_askewsholts_vlebooks_9781119106906

Other Resources• M249 materials

(https://learn2.open.ac.uk/course/view.php?id=208584&area=resources)

• M249 Student Forums

• Wikipedia

• CrossValidated (https://stats.stackexchange.com/ )

• SPSS help (https://www.ibm.com/uk-en/products/spss-statistics )

• YouTube – Research By Design (https://www.youtube.com/channel/UCXLbK1bH-w1oklGm4dLYrHw )

• Contact me:• [email protected]• 07311 188 800

67

Thank you! Any questions?

Recording will be available from M249-20J Online Tutorial Roomhttps://learn2.open.ac.uk/mod/connecthosted/view.php?id=1648457&group=270251

Page 68: Time Series in 10am recording SPSS - Open University

Smoothing & Forecasting

68

M249 Practical Modern Statistics

• Above, we used a simple centred moving average to estimate the trend component –this is an example of smoothing

• Other methods can be applied to an additive model without explicit decomposition• Exponential – constant trend, no seasonality• Holt – variable trend, no seasonality• Holt-Winters – variable trend with seasonality

Page 69: Time Series in 10am recording SPSS - Open University

Smoothing & Forecasting

69

M249 Practical Modern Statistics

• Above, we used a simple centred moving average to estimate the trend component –this is an example of smoothing

• Other methods can be applied to an additive model without explicit decomposition• Exponential – constant trend, no seasonality• Holt – variable trend, no seasonality• Holt-Winters – variable trend with seasonality

• Here we’ll assume that Holt-Winters is suitable for claimants.sav

• Time Series Models are straight forward but have lots of options; here I’ll show the start and end result only

Page 70: Time Series in 10am recording SPSS - Open University

Smoothing & Forecasting

70

The Holt-Winters exponential model has three parameters which are optimised automatically by SPSS:

Exponential Model: 𝑋𝑋𝑡𝑡 = 𝑚𝑚 + 𝑏𝑏𝑡𝑡 + 𝑠𝑠𝑡𝑡 + 𝑊𝑊𝑡𝑡

1-Step Ahead Forecast: �𝑥𝑥𝑡𝑡+1 = �𝑚𝑚𝑡𝑡 + �𝑏𝑏 + �𝑠𝑠𝑡𝑡+1

Page 71: Time Series in 10am recording SPSS - Open University

Smoothing & Forecasting

71

The Holt-Winters exponential model has three parameters which are optimised automatically by SPSS:

Exponential Model: 𝑋𝑋𝑡𝑡 = 𝑚𝑚 + 𝑏𝑏𝑡𝑡 + 𝑠𝑠𝑡𝑡 + 𝑊𝑊𝑡𝑡

1-Step Ahead Forecast: �𝑥𝑥𝑡𝑡+1 = �𝑚𝑚𝑡𝑡 + �𝑏𝑏 + �𝑠𝑠𝑡𝑡+1

Parameter Function Initial Value

𝛼𝛼 Level 𝑥𝑥1

𝛾𝛾 Slope 0 𝑜𝑜𝑜𝑜𝑥𝑥𝑡𝑡+1 − 𝑥𝑥1

𝑇𝑇

𝛿𝛿 Seasonal component adjustment 𝑆𝑆𝑗𝑗 = 𝐹𝐹𝑗𝑗 − �𝐹𝐹

𝛼𝛼, 𝛾𝛾, 𝛿𝛿 ∈ 0,1 3

Page 72: Time Series in 10am recording SPSS - Open University

Smoothing & Forecasting

72

The Holt-Winters exponential model has three parameters which are optimised automatically by SPSS:

Exponential Model: 𝑋𝑋𝑡𝑡 = 𝑚𝑚 + 𝑏𝑏𝑡𝑡 + 𝑠𝑠𝑡𝑡 + 𝑊𝑊𝑡𝑡

1-Step Ahead Forecast: �𝑥𝑥𝑡𝑡+1 = �𝑚𝑚𝑡𝑡 + �𝑏𝑏 + �𝑠𝑠𝑡𝑡+1

Parameter Function Initial Value

𝛼𝛼 Level 𝑥𝑥1

𝛾𝛾 Slope 0 𝑜𝑜𝑜𝑜𝑥𝑥𝑡𝑡+1 − 𝑥𝑥1

𝑇𝑇

𝛿𝛿 Seasonal component adjustment 𝑆𝑆𝑗𝑗 = 𝐹𝐹𝑗𝑗 − �𝐹𝐹

𝛼𝛼, 𝛾𝛾, 𝛿𝛿 ∈ 0,1 30 1

Little weight on recent observations

Most weight on recent observations

Page 73: Time Series in 10am recording SPSS - Open University

Smoothing & Forecasting

73

The Holt-Winters exponential model has three parameters which are optimised automatically by SPSS:

Exponential Model: 𝑋𝑋𝑡𝑡 = 𝑚𝑚 + 𝑏𝑏𝑡𝑡 + 𝑠𝑠𝑡𝑡 + 𝑊𝑊𝑡𝑡

1-Step Ahead Forecast: �𝑥𝑥𝑡𝑡+1 = �𝑚𝑚𝑡𝑡 + �𝑏𝑏 + �𝑠𝑠𝑡𝑡+1

Parameter Function Initial Value

𝛼𝛼 Level 𝑥𝑥1

𝛾𝛾 Slope 0 𝑜𝑜𝑜𝑜𝑥𝑥𝑡𝑡+1 − 𝑥𝑥1

𝑇𝑇

𝛿𝛿 Seasonal component adjustment 𝑆𝑆𝑗𝑗 = 𝐹𝐹𝑗𝑗 − �𝐹𝐹

𝛼𝛼, 𝛾𝛾, 𝛿𝛿 ∈ 0,1 30 1

Little weight on recent observations

Most weight on recent observations

SPSS deals with all of this automatically!

Page 74: Time Series in 10am recording SPSS - Open University

Smoothing & Forecasting – Holt-Winters

74

Data: claimants.sav Reference: Computer Book 2 pp. 33-37

Analyze→ Forecasting → Create Traditional Models

Page 75: Time Series in 10am recording SPSS - Open University

Smoothing & Forecasting – Holt-Winters

75

Data: claimants.sav Reference: Computer Book 2 pp. 33-37

Analyze→ Forecasting → Create Traditional Models

Page 76: Time Series in 10am recording SPSS - Open University

Simple Forecasting

76

Claimant numbers with 12 month forecast

Data: claimants.sav Reference: Computer Book 2 pp. 33-37

Page 77: Time Series in 10am recording SPSS - Open University

Simple Forecasting

77

Claimant numbers with 12 month forecast

Data: claimants.sav Reference: Computer Book 2 pp. 33-37

Page 78: Time Series in 10am recording SPSS - Open University

Simple Forecasting

78

Claimant numbers with 12 month forecast

Hmmm.. H0 for Ljung-Box is that there is zerocorrelation between errors. This p-value suggeststhat this model may not be the best for the data

Data: claimants.sav Reference: Computer Book 2 pp. 33-37

Page 79: Time Series in 10am recording SPSS - Open University

Forecasting & Errors

79

Actual claimant numbers with 12 month forecast

Clai

man

ts

Month

Visually, the forecast looks pretty close to reality, even up to 12 months out.

Data: claimants.sav Reference: Computer Book 2 pp. 33-37

Page 80: Time Series in 10am recording SPSS - Open University

Forecasting & Errors

80

Actual claimant numbers with 12 month forecast

Clai

man

ts

Month

Visually, the forecast looks pretty close to reality, even up to 12 months out.

How can we objectively assess different models?

Data: claimants.sav Reference: Computer Book 2 pp. 33-37

Page 81: Time Series in 10am recording SPSS - Open University

Forecasting & Errors

81

Actual claimant numbers with 12 month forecast

Clai

man

ts

Month

Visually, the forecast looks pretty close to reality, even up to 12 months out.

How can we objectively assess different models?

1. Compare cost (error or loss) functiona. SPSS uses RMSEb. SSE also in the materials

2. Examine error correlogram3. Examine histogram of errors

More to come on this later

Data: claimants.sav Reference: Computer Book 2 pp. 33-37