• No results found

Time Series Analysis using In a Nutshell

N/A
N/A
Protected

Academic year: 2021

Share "Time Series Analysis using In a Nutshell"

Copied!
47
0
0

Loading.... (view fulltext now)

Full text

(1)

Time Series Analysis

using

In a Nutshell

d J J M Rij k

Stochastic Processes:

X

X

X

14x 104 Realization Data Collection

dr. J.J.M. Rijpkema

Eindhoven University of Technology, dept. Mathematics & Computer Science

P.O.Box 513, 5600 MB Eindhoven, NL © 2012 [email protected]

jr / department of mathematics and computer science 2IS55 TSAwith R

Individual stochasts, that might be dependent  t

,

X

t1

, ,

X

t2

,

X

Stochastic Process 19405 1950 1960 1970 1980 1990 2000 2010 6 7 8 9 10 11 12 13 year labo rf or ce - dat a Model Fit • Model Identification • Parameter Estimation • Model Validation Model Use 2

Overview

• Introduction & Preliminaries

• Exploratory Data Analysis

• Exploratory Data Analysis

• Time Sequence Plot

• (Partial) Autocorrelation Function

• Exponential Smoothing Methods

• Simple Exponential Smoothing

• Holt and Holt-Winters Models

• ARMA Models

• The Bare Essentials

• Model Fitting

(2)

Introduction & Preliminaries

Stochastic Processes: Data Collection Realization

Stochastic Processes:

Individual stochasts, that might be dependent  t

,

X

t1

, ,

X

t2

,

X

Stochastic Process 19405 1950 1960 1970 1980 1990 2000 2010 6 7 8 9 10 11 12 13 14x 10 4 year labo rf or ce dat a Realization Model Fit • Model Identification • Parameter Estimation • Model Validation Model Use

jr / department of mathematics and computer science 2IS55 TSAwith R

2IS55

Restriction

Exploratory Data

Analysis?

Relevant

Models?

4

• References:

http://a-little-book-of-r-for-time-series.readthedocs.org/ Coghlan, Avril, A Little Book of R for Time Series,

(3)

• Software:

http://www r project org/

jr / department of mathematics and computer science 2IS55 TSAwith R

http://www.r-project.org/

Metaphor:

• Download and Install :

(4)

jr / department of mathematics and computer science 2IS55 TSAwith R

• Alternative: R-studio

(5)

Netherlands (Utrecht)

jr / department of mathematics and computer science 2IS55 TSAwith R

• Load package ‘forecast’

& ‘tseries’

:

(6)

Exploratory Data Analysis

• Example: Age of Death of 42 Successive Kings of England

> load("D:/..../kings.RData") > class(kings) [1] "numeric" > kings [1] 60 43 67 50 56 42 50 65 68 43 65 34 47 34 49 41 13 35 53 56 16 43 [23] 69 59 48 59 86 55 68 51 33 49 67 77 81 67 71 81 68 70 77 56 • General Properties:

jr / department of mathematics and computer science 2IS55 TSAwith R > kings.ts <- ts(kings)

> kings.ts

Time Series: Start = 1 End = 42 Frequency = 1

[1] 60 43 67 50 56 42 50 65 68 43 65 34 47 34 49 41 13 35 53 56 16 43 [23] 69 59 48 59 86 55 68 51 33 49 67 77 81 67 71 81 68 70 77 56

• Conversion to time series object:

12

• Time Sequence Plot:

> plot(kings.ts) ki n g s.ts 40 60 80

Exploratory Data Analysis

• Main Properties:

– Trend? – Cyclic Variation? Time 0 10 20 30 40 20 Cyclic Variation? – Irregular Variation?

• Sudden Changes?

• Outliers?

• Missing Values?

(7)

Are successive observations related ?

S tt

l t & S

l C

l ti

C

ffi i t f {(

)}

• Autocorrelation Function:

• Scatterplot & Sample Correlation Coefficient of {(x

t

,x

t-1

)}



1 1 2 t t t

x

x

x

x

r

x

x

Approximation ! > lag.plot(kings.ts,do.lines=F) 0 60 8 0 kin gs. ts

jr / department of mathematics and computer science 2IS55 TSAwith R

r=0.4

0 20 40 60 80 100 20 4 0 lag 1 k

Auto

correlation Coefficient at time-lag 1

20 20 60 100 20 20 60 100 14

• Generalisation:



2

k t t t k

x

x

x

x

r

x

x

> lag.plot(kings.ts,lags=12,do.lines=F) lag 1 ki ng s. ts 20 60 -20 20 60 100 lag 2 ki ng s. ts lag 3 ki ng s. ts -20 20 60 100 lag 4 ki ng s. ts lag 5 ki ng s. ts lag 6 ki ng s. ts 20 60 lag 7 ki ng s. ts 20 60 lag 8 ki ng s. ts lag 9 ki ng s. ts lag 10 ki ng s. ts lag 11 ki ng s. ts lag 12 ki ng s. ts 20 60

(8)

• Autocorrelation Function:

> acf(kings ts) > acf(kings.ts)$acf [,1] [1 ] 1 000000000 > acf(kings.ts) 0. 2 0 .6 1.0 ACF [1,] 1.000000000 [2,] 0.400584149 [3,] 0.238081338 [4,] 0.259547258 [5,] 0.347780525 [6,] 0.160923687 [7,] 0.031201729 [8,] 0.115411950 [9,] 0.078385052 [10,] -0.036221926 [11,] -0.001138564

jr / department of mathematics and computer science 2IS55 TSAwith R

0 5 10 15 -0 .2 Lag [12,] 0.110712654 [13,] -0.010138296 [14,] -0.116699180 [15,] 0.034735266 [16,] 0.025070163 [17,] -0.119576411 16

• Partial Autocorrelation:

Direct Pathway

x

t-k

x

t-k-1

x

t

x

t-k-2

x

t-2

x

t-1

Indirect Pathway

• Autocorrelation Function:

• Measure for the

overall

correlation between {x

t-k

} and {x

t

}

• Both through the direct and the indirect pathway !

• Partial Autocorrelation Function:

• Measure for the

direct

correlation between {x

t-k

} and {x

t

}

(9)

• (Partial) Autocorrelation Function:

> pacf(kings.ts) 3 5 10 15 -0 .3 -0 .1 0 .1 0 . L P a rt ia l A C F > acf(kings.ts)

jr / department of mathematics and computer science 2IS55 TSAwith R Lag

kings.ts

60

18

• EDA-Summary:

> tsdisplay(kings.ts)

0

10

20

30

40

20

6

0.

4

0.

4

2 4 6 8

12

-0

.4

0.

0

Lag

ACF

2 4 6 8

12

-0

.4

0.

0

Lag

PACF

(10)

• Example: Births per Month in New York City

> load("D:/..../births.RData") > births.ts <- ts(births,start=c(1946,1),frequency=12) > plot(births.ts)

b

ir

th

s.ts

2

22

42

6

2

83

0

Exploratory Data Analysis

• Main Properties:

– Trend?

– Seasonal Variation?

jr / department of mathematics and computer science 2IS55 TSAwith R

Time

1946

1950

1954

1958

20

2

Seasonal Variation? – Cyclic Variation? – Irregular Variation?

• Sudden Changes?

• Outliers?

• Missing Values?

births.ts

26

20 tsdisplay(births.ts)

• EDA-Summary:

1946

1948

1950

1952

1954

1956

1958

1960

20

2

0.

6

0.

6

F

0 5

15

25

35

-0

.4

0.

2

Lag

ACF

0 5

15

25

35

-0

.4

0.

2

Lag

PA

C

F

(11)

• Example: Monthly Sales for Australian Souvenir Shop

> load("D:/..../souvenir.RData") > souvenir.ts <- ts(souvenir,start=c(1987,1),frequency=12) > plot(souvenir.ts)

souvenir

.ts

4e+

0

4

8e+

04

Exploratory Data Analysis

• Main Properties:

– Trend?

– Seasonal Variation?

jr / department of mathematics and computer science 2IS55 TSAwith R

Time

1987

1989

1991

1993

0e+

00

Seasonal Variation? – Cyclic Variation? – Irregular Variation?

• Sudden Changes?

• Outliers?

• Missing Values?

souvenir.ts

1e+

05

22 tsdisplay(souvenir.ts)

• EDA-Summary:

1987

1988

1989

1990

1991

1992

1993

1994

0e+

00

0.

6

0.

6

0

5 10

20

-0

.2

0.

2

Lag

ACF

0

5 10

20

-0

.2

0.

2

Lag

PACF

(12)

• Time Sequence Plot after Log-Trafo:

> souvenir.log <- log(souvenir.ts) > plot(souvenir.log)

so

u

ven

ir

.log

91

0

1

1

Exploratory Data Analysis

• Main Properties:

– Trend?

– Seasonal Variation?

jr / department of mathematics and computer science 2IS55 TSAwith R

1987

1989

1991

1993

8

Seasonal Variation? – Cyclic Variation? – Irregular Variation?

• Sudden Changes?

• Outliers?

• Missing Values?

souvenir.log

10 24 > tsdisplay(souvenir.log.ts)

• EDA-Summary:

1987 1988 1989 1990 1991 1992 1993 1994 8 0. 4 0. 4 F 0 5 10 20 -0 .6 0. 0 Lag ACF 0 5 10 20 -0 .6 0. 0 Lag PAC F

(13)

• Example: Annual Rainfall in London

> load("D:/..../rain.RData") > rain.ts <- ts(rain,start=1813) > plot(rain.ts)

ra

in

.ts

25

30

35

Exploratory Data Analysis

• Main Properties:

– Trend?

jr / department of mathematics and computer science 2IS55 TSAwith R

Time

1820

1840

1860

1880

1900

20

– Trend? – Cyclic Variation? – Irregular Variation?

• Sudden Changes?

• Outliers?

• Missing Values?

rain.ts

0 26 > tsdisplay(rain.ts)

• EDA-Summary:

1820 1840 1860 1880 1900 20 30 0.2 0.2 5 10 15 20 -0 .3 0. 0 0 Lag ACF 5 10 15 20 -0 .3 0. 0 0 Lag PACF

(14)

• Example: Annual Diameter of Women’s Skirts

> load("D:/..../skirts.RData") > skirts.ts <- ts(skirts,start=1866) > plot(skirts.ts)

sk

ir

ts

.t

s

0

800

1000

Exploratory Data Analysis

• Main Properties:

– Trend?

jr / department of mathematics and computer science 2IS55 TSAwith R

Time

1870

1880

1890

1900

1910

60

0

– Cyclic Variation? – Irregular Variation?

• Sudden Changes?

• Outliers?

• Missing Values?

skirts.ts

0 28 > tsdisplay(skirts.ts)

• EDA-Summary:

1870 1880 1890 1900 1910 60 0 90 0. 8 0. 8 2 4 6 8 12 -0 .4 0. 2 Lag AC F 2 4 6 8 12 -0 .4 0. 2 Lag PAC F

(15)

• Example: Volcanic Dust Veil Index

> load("D:/..../volcano.RData")

> volcano.ts <- ts(volcano, start=1500) > plot(volcano.ts) vo lc ano. ts 200 400 600

Exploratory Data Analysis

• Main Properties:

– Trend?

jr / department of mathematics and computer science 2IS55 TSAwith R Time 1500 1600 1700 1800 1900 0 – Cyclic Variation? – Irregular Variation?

• Sudden Changes?

• Outliers?

• Missing Values?

volcano.ts

700 30 > tsdisplay(volcano.ts)

• EDA-Summary:

1500 1600 1700 1800 1900 03 00 4 4 0 5 10 15 20 25 0. 0 0. 4 Lag AC F 0 5 10 15 20 25 0. 0 0. 4 Lag PAC F

(16)

• Trend

– Long term changes in mean

• Seasonal Variation

– Periodic variations over time

• Types of Variation:

– Can be estimated & modeled – Can be corrected for

– Can be estimated & modeled – Can be corrected for

• Stationary Time Series

– No systematic change in mean and variance

– No strictly periodic variations

jr / department of mathematics and computer science 2IS55 TSAwith R

No strictly periodic variations

• Other Irregular Fluctuations

– Random or with structure ?

• Other Cyclic Variation

– Business cycle (~7 year)

32

Simple Exponential Smoothing

Example: Annual Rainfall in London

• Series with NO Trend and No Seasonality

• Basic Idea: one-step ahead prediction

Stationary Series • No trend (??) • No Seasonality ra in .ts 1820 1840 1860 1880 1900 20 25 30 35

 

0 1 1 2 2

ˆ 1

T T T T

x

c x

c x

c x



1

i i

c

Geometric Weights:

(17)

 

 

 

ˆ

1

1

ˆ

1

x

x

x

• Interpretation:

 

1

2

ˆ 1

T T

1

T

1

T

x

x

 

 

x

x

Weighted average of

 

1

 

1

1

 

1

T T T

x

x

x

 

 

 

x

ˆ

T 1

1

x

T

x

ˆ

T 1

1

 

ˆ

Simple Exponential Smoothing

• Overview:

g

g

past and present

α =0  past

α =1  present

jr / department of mathematics and computer science 2IS55 TSAwith R

t

x

 

1 1

ˆ

t

1

t

x

L

1 t

x

ˆ

1 t

L

ˆ

t

L

1

ˆ

1

ˆ

t t t

L

x

 

L

• Remark:

• Simple Exponential Smoothing allows for updates of level estimates

34

• Example: fixed parameter  = 0.2

• Adequate

initial

value for the level estimate needed

> rain.ses1 <- HoltWinters(rain.ts,alpha=0.2,beta=FALSE,gamma=FALSE)

1 1

ˆL x

A il bl I f

ti

> rain.ses1 H lt Wi t ti l thi ith t

• Smoothing Parameters:

> names(rain.ses1)

[1] "fitted" "x" "alpha" "beta“ "gamma“ [6] "coefficients" "seasonal" "SSE" "call"

• Available Information:

Holt-Winters exponential smoothing without trend and without seasonal component. Smoothing parameters: alpha: 0.2 beta : FALSE gamma: FALSE

Coefficients: [,1] a 25.30941

• Final Component Estimate:

(18)

• ‘Running’ Component Estimates:

> rain.ses1$fitted xhat level 1814 23.56000 23.56000

 

1

ˆ

1

ˆ

t

1

t

x

L

1815 24.06200 24.06200 1816 23.62160 23.62160 1817 25.14528 25.14528 1818 24.84622 24.84622 1819 24.65298 24.65298 1820 25.00438 25.00438 1821 24.53751 24.53751 1822 25.96801 25.96801 1823 25.54640 25.54640 ... > plot(rain.ses1$fitted) 2 25 28 xhat

jr / department of mathematics and computer science 2IS55 TSAwith R

2 2 22 25 28 1820 1840 1860 1880 1900 le ve l

α = 0.2

5 36 > plot(rain.ses1)

• In-Sample Prediction vs. Realization:

O b se rv ed / F itt ed 20 25 30 3 5 > rain.ses1$SSE [1] 1972.197

Running SSE

 

0 2 1

ˆ

1

T t t t s

x

x

1820 1840 1860 1880 1900

• Remark:

• In-sample comparison uses the same data for fitting and validation.

• Independent hold-out sample for validation would be preferred!

(19)

• Goodness-of-Fit Measures:

• Bias:

1

ˆ

1

n t t t t

x

x

MPE

n

x

• Mean Percentage Error

1

1

n

ˆ

t t t

ME

x

x

n

• Mean Error

The closer to 0,

the

• Variability:

1

1

n

ˆ

t t t

MAE

x

x

n

• Mean Absolute Error

• Root Mean Squared Error

1

ˆ

100

n t t t t

x

x

MAPE

n

x

• Mean Absolute Percentage Error

ˆ

• Mean Absolute Scaled Error

jr / department of mathematics and computer science 2IS55 TSAwith R

• In-Sample Accuracy:

> accuracy(rain.ses1)

ME RMSE MAE MPE MAPE MASE 0.08835385 4.46331492 3.41468131 -2.41358228 13.79285103 0.70334023

2 1

1

n

ˆ

t t t

RMSE

x

x

n

1

ˆ

1

n t t t

x

x

MASE

n

q

> rain.ses1.fore 38

• Holt-Winters Forecasts:

> rain.ses1.fore <- forecast.HoltWinters(rain.ses1,h=10) Point Forecast Lo 80 Hi 80 Lo 95 Hi 95 1913 25.30941 19.56146 31.05736 16.51867 34.10014 1914 25.30941 19.44762 31.17119 16.34458 34.27423 1915 25.30941 19.33596 31.28285 16.17381 34.44500 1916 25.30941 19.22635 31.39247 16.00617 34.61264 1917 25.30941 19.11867 31.50014 15.84150 34.77732 1918 25.30941 19.01284 31.60597 15.67964 34.93917 1919 25.30941 18.90876 31.71005 15.52046 35.09835 1920 25.30941 18.80634 31.81247 15.36383 35.25498 1921 25.30941 18.70551 31.91330 15.20962 35.40919 1922 25 30941 18 60620 32 01261 15 05774 35 56107

Forecasts from HoltWinters

35 > plot.forecast(rain.ses1.fore) 1922 25.30941 18.60620 32.01261 15.05774 35.56107 15 2 0 25 30

(20)

-5

5

15

• Diagnostics: In-Sample Forecast Errors

Constant

over time?

1820 1840 1860 1880 1900 0.3 0. 0 0.2 ACF 0.3 0. 0 0.2 PACF

Non-zero

Autocorrelations?

> tsdisplay(rain.ses1.fore$residuals)

jr / department of mathematics and computer science 2IS55 TSAwith R

5 10 15 20 -0 Lag 5 10 15 20 -0 Lag > Box.test(rain.ses1.fore$residuals,lag=20,type="Ljung-Box") Box-Ljung test data: rain.ses1.fore$residuals

X-squared = 22.5621, df = 20, p-value = 0.3108

   

 2 2 2 # 1 2 k i BL N p i r X N N N i 40

• Example: optimal  estimated

• Principle:

• Optimal value for the parameter  to be determined from ‘running’ 1-step

ahead prediction:

> rain.ses2 <- HoltWinters(laborforce.ts,beta=FALSE,gamma=FALSE) > rain.ses2 S thi t l h 0 02412151

• Smoothing Parameters:

 

 2 1 0

ˆ

min 1

T t t t

x

x

(or related, eg. AIC or BIC)

Smoothing parameters: alpha: 0.02412151 beta : FALSE gamma: FALSE

Coefficients: [,1] [,1] a 24.67819

• Final Component Estimate:

 

 

1

 

ˆ

T

1

T

1

ˆ

T

1

(21)

• ‘Running’ Component Estimates:

> rain.ses2$fitted xhat level 1814 23.56000 23.56000

 

1

ˆ

1

ˆ

t

1

t

x

L

1815 23.62054 23.62054 1816 23.57808 23.57808 1817 23.76290 23.76290 1818 23.76017 23.76017 1819 23.76306 23.76306 1820 23.82691 23.82691 1821 23.79900 23.79900 1822 23.98935 23.98935 1823 23.98623 23.98623 ... .5 24.5 xhat > plot(rain.ses2$fitted)

jr / department of mathematics and computer science 2IS55 TSAwith R

23 . 23.5 24. 5 1820 1840 1860 1880 1900 lev e l

optimal α

42

• In-Sample Prediction vs. Realization:

5 > plot(rain.ses2) > rain.ses2$SSE [1] 1828.855

Running SSE

 

0 2 1

ˆ

1

T t t t s

x

x

O b ser ved / F itt ed 20 25 30 3 5

• In-Sample Accuracy:

> accuracy(rain.ses2)

ME RMSE MAE MPE MAPE MASE

(22)

> rain.ses2.fore

• Holt-Winters Forecasts:

> rain.ses2.fore <- forecast.HoltWinters(rain.ses2,h=10) Point Forecast Lo 80 Hi 80 Lo 95 Hi 95 1913 24.67819 19.17493 30.18145 16.26169 33.09470 1914 24.67819 19.17333 30.18305 16.25924 33.09715 1915 24.67819 19.17173 30.18465 16.25679 33.09960 1916 24.67819 19.17013 30.18625 16.25434 33.10204 1917 24.67819 19.16853 30.18785 16.25190 33.10449 1918 24.67819 19.16694 30.18945 16.24945 33.10694 1919 24.67819 19.16534 30.19105 16.24701 33.10938 1920 24.67819 19.16374 30.19265 16.24456 33.11182 1921 24.67819 19.16214 30.19425 16.24212 33.11427 1922 24 67819 19 16054 30 19584 16 23968 33 11671

Forecasts from HoltWinters

35

> plot.forecast(rain.ses2.fore)

jr / department of mathematics and computer science 2IS55 TSAwith R 1922 24.67819 19.16054 30.19584 16.23968 33.11671 1820 1840 1860 1880 1900 1920 20 2 5 30 -5 5 44

• Diagnostics: In-Sample Forecast Errors

Constant

over time?

1820 1840 1860 1880 1900 0.3 0. 0 0.2 ACF 0.3 0. 0 0.2 PACF

Non-zero

Autocorrelations?

> tsdisplay(rain.ses2.fore$residuals) 5 10 15 20 -0 Lag 5 10 15 20 -0 Lag > Box.test(rain.ses2.fore$residuals,lag=20,type="Ljung-Box") Box-Ljung test data: rain.ses2.fore$residuals

X-squared = 17.4008, df = 20, p-value = 0.6268

    

 2 2 2 # 1 2 k i BL N p i r X N N N i

(23)

• Series with Trend but No Seasonality

Holt’s Exponential Smoothing

Example: Annual Diameter of Women’s Skirts

• Principle:

Time sk ir ts .ts 1870 1880 1890 1900 1910 600 80 0 1000

Example: Annual Diameter of Women’s Skirts

• No Seasonality

(annual data!)

jr / department of mathematics and computer science 2IS55 TSAwith R

 

1 ˆ 1 ˆ1

ˆT 1

t t t

x L T

Holt’s Exponential Smoothing

T t

x

ˆ

t

T

   1   1 ˆ ˆ ˆ 1 ˆ t t t t T L L T

ˆ

t

L

1 1

ˆ

T

1

ˆ

ˆ

t t t t

L

x

 

L

T

1 T t

x

ˆ

1 t

L

T

ˆ

t1

p

46

• Remarks:

• Holt’s ES allows for updates of level and trend estimations

• Two parameter version of Exponential Smoothing

• Special: Brown’s Exponential Smoothing

Special: Brown s Exponential Smoothing

• Both parameters are equal:

= β

• Similar to ARIMA(0,2,1) model (to be discussed)

• Practical:

• Adequate

initial

values for the level and trend estimates needed

ˆ

ˆ

1 1

ˆL x

T

ˆ

1

x

2

x

1

• Optimal value for the parameters  and  to be determined from ‘running’

1-step ahead prediction:

 

2

1

ˆ

(24)

• Example: optimal and  estimated

> skirts.hes <- HoltWinters(x=skirts.ts,gamma=FALSE)

• Smoothing Parameters:

> skirts.hes

Smoothing parameters: alpha: 0.8383481 beta : 1 gamma: FALSE

Main emphasis on recent values!

1 1

ˆ

T

1

ˆ

ˆ

t t t t

L

x

 

L

T

1

 

1

ˆ

ˆ

ˆ

1

ˆ

t t t t

T

L

L

T

jr / department of mathematics and computer science 2IS55 TSAwith R Coefficients: [,1]

a 529.308585 b 5.690464

• Final Component Estimate:

48

• ‘Running’ Component Estimates:

> skirts.hes$fitted

xhat level trend

1868 626.0000 617.0000 9.0000000

 

1

ˆ

1

ˆ

1

ˆ

T

1

t t t

x

L

T

1869 633.3233 625.1617 8.1616519 1870 645.9730 635.5673 10.4056551 1871 674.8676 655.2175 19.6501514 1872 721.5669 688.3922 33.1747101 1873 765.5280 726.9601 38.5679053 ... ... > plot(skirts.hes$fitted) 50 0 80 0 xh a t 90 0 e l 60 0 le ve -6 0 0 40 1870 1880 1890 1900 1910 tr end

optimal α and 

(25)

• In-Sample Prediction vs. Realization:

> plot(skirts.hes) > skirts.hes$SSE [1] 16954.18

Running SSE

 

0 2 1

ˆ

1

T t t t s

x

x

O b ser ved / F itt ed 0 700 900

jr / department of mathematics and computer science 2IS55 TSAwith R

• In-Sample Accuracy:

> accuracy(skirts.hes)

ME RMSE MAE MPE MAPE MASE 255.25079 454.78440 269.86059 33.42056 35.34162 11.21304 1870 1880 1890 1900 1910 50 > skirts.hes.fore 50

• Holt-Winters Forecasts:

> skirts.hes.fore <- forecast.HoltWinters(skirts.hes,h=19) Point Forecast Lo 80 Hi 80 Lo 95 Hi 95 1912 534.9990 509.55210 560.4460 496.08130 573.9168 1913 540.6895 491.01052 590.3685 464.71204 616.6670 1914 546.3800 465.36129 627.3987 422.47258 670.2874 1915 .... ... 0 200 0 > plot.forecast(skirts.hes.fore) -1 0 0 0 0 100 0

??

(26)

• Diagnostics: In-Sample Forecast Errors

-2 0 20

Constant

over time?

1870 1880 1890 1900 1910 -0. 4 0. 0 0. 4 ACF -0. 4 0. 0 0. 4 PACF

Non-zero

Autocorrelations?

> tsdisplay(skirts.hes.fore$residuals)

jr / department of mathematics and computer science 2IS55 TSAwith R

2 4 6 8 12 -Lag 2 4 6 8 12 -Lag > Box.test(skirts.hes.fore$residuals,lag=20,type="Ljung-Box") Box-Ljung test data: skirts.fore$residuals

X-squared = 19.7312, df = 20, p-value = 0.4749

   

 2 2 2 # 1 2 k i BL N p i r X N N N i 52

• Example: Births per Months in New York City

Holt-Winters Exponential Smoothing

(

Additive

Seasonality)

0 Time bi rt hs .t s 1946 1950 1954 1958 20 22 2 4 26 28 3 0

• Trend ?

• Additive

Seasonality ?

P i i l

 

1

ˆ

1

ˆ

1

ˆ

ˆ

TS

1

t t t t s

x

L

T

I

 Additive Holt-Winter’s ES

• Principle:

1 TS t

x

ˆ

1 t

L

T

ˆ

t1

I

ˆ

t1 TS t

x

ˆ

t

T

1

 

1

ˆ

ˆ

ˆ

1

ˆ

t t t t

T

L

L

T

ˆ

t

I

 

ˆ

TS

ˆ

1

ˆ

t t t t s

I

x

L

I

ˆ

t

L

1 1

ˆ

TS

ˆ

1

ˆ

ˆ

t t t s t t

L

x

I

 

L

T

(27)

• Remarks:

• Holt-Winter’s ES allows for updates of level, trend and seasonality

estimations

• Three parameter version of Exponential Smoothing

• Similar to SARIMA (0,1,1)x(0,1,1)

s

model

(to be discussed)

• Special: Simple Seasonal ES  No trend (T

t

=0), only seasonality !

 

1 ˆ1 ˆ

ˆS 1

t t t s

x LI

Simple Additive Seasonal ES

1 S t xLˆt1 Iˆt1

       ˆ TS ˆ 1 ˆ t t t t s I x L I

1 ˆ S ˆ 1 ˆ t t t s t LxI  LS t x Lˆt Iˆt

jr / department of mathematics and computer science 2IS55 TSAwith R

• Practical:

• Adequate

initial

values for the level, trend and seasonality estimates needed

• Optimal values for the parameters ,  and  to be determined from:

 

    

2 1 , , 0

ˆ

min 1

T t t t

x

x

(or related, eg. AIC or BIC)

54

• Example: optimal and  estimated

births.hw <- HoltWinters(births.ts,seasonal="additive")

• Smoothing Parameters:

• Final Component Estimates:

births.hw Smoothing parameters: alpha: 0.4823655 beta : 0.02988495 gamma: 0.563186

• Smoothing Parameters:

Coefficients: [,1] a 28.04366357 b 0.04199921 s1 -0.78546221 s2 -2.19944507 s3 0.87813012 s4 -0.65164728 s5 0 63427267

• Final Component Estimates:

ˆ

T

1

ˆ

ˆ

L

x

L

T

Emphasis for trend

s5 0.63427267 s6 0.21182821 s7 2.23177191 s8 2.17167733 s9 1.52077678 s10 1.16900861 s11 -0.97500043 s12 -0.18636055

1

1 1

T t t t t

L

x

 

L

T

1

 

1

ˆ

ˆ

ˆ

1

ˆ

t t t t

T

L

L

T

 

ˆ

TS

ˆ

1

ˆ

t t t t s

I

x

L

I

(28)

> births.hw$fitted

xhat level trend season

Jan 1947 23.13579 23.81055 -0.1567618007 -0.51798958

• ‘Running’ Component Estimates:

x

ˆ

tTS1

 

1

L

ˆ

t1

T

ˆ

t1

I

ˆ

t s

Feb 1947 21.83089 22.83531 -0.1812218860 -0.82319792 Mar 1947 23.90724 22.29623 -0.1919165635 1.80292708 Apr 1947 21.58463 22.00869 -0.1947742244 -0.22928125 May 1947 21.51602 21.85461 -0.1935580066 -0.14503125 Jun 1947 20.43661 21.77488 -0.1901562399 -1.14811458 Jul 1947 22.44490 21.74120 -0.1854799895 0.88917708 Aug 1947 22.51935 22.05453 -0.1705728887 0.63538542 Sep 1947 22.50969 22.51328 -0.1517657072 0.14817708 Oct 1947 22.96787 22.64867 -0.1431840736 0.46238542 Nov 1947 21.63717 22.57404 -0.1411352421 -0.79573958 Dec 1947 22.07360 22.49168 -0.1393790022 -0.27869792 22 26 xhat 24 27 lev el > plot(births.hw$fitted)

jr / department of mathematics and computer science 2IS55 TSAwith R Jan 1948 21.19997 22.35201 -0.1393876391 -1.01264664 Feb 1948 ...

optimal α,  and 

21 l -0 .2 0 0.0 0 tr end -2 0 2 1948 1950 1952 1954 1956 1958 1960 seas on 56

• In-Sample Prediction vs. Realization:

30 > plot(births.hw) > births.hw$SSE [1] 90.94058

Running SSE

 

0 2 1

ˆ

1

T t t t s

x

x

O b ser ved / F itt ed 20 22 24 26 28

• In-Sample Accuracy:

> accuracy(births.hw)

ME RMSE MAE MPE MAPE MASE 12.60682 17.77135 12.93276 50.15378 51.52523 10.81909

(29)

> births.hw.fore

• Holt-Winters Forecasts:

> births.hw.fore <- forecast.HoltWinters(births.hw,h=48) Point Forecast Lo 80 Hi 80 Lo 95 Hi 95 Jan 1960 27.30020 26.32517 28.27523 25.80902 28.79139 Feb 1960 25.92822 24.83950 27.01694 24.26316 27.59327 Mar 1960 29.04779 27.85040 30.24518 27.21654 30.87905 Apr 1960 27.56001 26.25756 28.86247 25.56808 29.55195 May 1960 28.88793 27.48307 30.29280 26.73938 31.03649 Jun 1960 28.50749 27.00220 30.01278 26.20535 30.80963 Jul 1960 30.56943 28.96521 32.17365 28.11598 33.02288 Aug 1960 30.55133 28.84929 32.25338 27.94828 33.15439 Sep 1960 29.94243 28.14338 31.74148 27.19102 32.69384 O t 1960 29 63266 27 73720 31 52813 26 73380 32 53153 > plot.forecast(births.hw.fore) 3 54 0

jr / department of mathematics and computer science 2IS55 TSAwith R Oct 1960 29.63266 27.73720 31.52813 26.73380 32.53153 Nov 1960 27.53065 25.53918 29.52213 24.48496 30.57635 Dec 1960 28.36129 26.27407 30.44852 25.16916 31.55342 Jan 1961 27.80419 25.52190 30.08648 24.31373 31.29466 Feb 1961 26.4322 ... 1950 1955 1960 20 25 30 3 -2 0 2 58

• Diagnostics: In-Sample Forecast Errors

Constant

over time?

1948 1950 1952 1954 1956 1958 1960 -0. 2 0. 0 0. 2 ACF -0. 2 0. 0 0. 2 PACF

Non-zero

Autocorrelations?

> tsdisplay(births.hw.fore$residuals) 0 5 15 25 35 -Lag 0 5 15 25 35 -Lag > Box.test(births.hw.fore$residuals,lag=20,type="Ljung-Box") data: births.hw.fore$residuals

    

 2 2 2 # 1 2 k i BL N p i r X N N N i

(30)

Stochastic Processes:

x 104

Realization:

ARMA Models: the Bare Essentials

Individual stochasts, that might be dependent  t

,

X

t1

, ,

X

t2

,

X

Stochastic Process 1940 1950 1960 1970 1980 1990 2000 2010 5 6 7 8 9 10 11 12 13 14x 10 year labo rf or ce dat a Model Fit • Model Identification • Parameter estimation • Model Validation

jr / department of mathematics and computer science 2IS55 TSAwith R

• Purely Random Processes

• Moving Average Processes: MA(q)

• Autoregressive Processes: AR(p)

• ARMA(p,q) & ARIMA(p,d,q) Processes

60

Basic Building Block

• Purely Random Process:

(white noise)

 

t

 

, , ,

Z

t1

Z

t2

,

Z

and mutually independent

 

~

0,2

t Z

Z N

 

• Simulation:

> ts.sim <- arima.sim(list(order=c(0,0,0)),n=100)> plot(ts.sim)

im 0

123

Exploratory Data Analysis

• Main Properties:

– Trend?

Time ts .s i 0 20 40 60 80 100 -3 -2 -1 0

– Trend?

– Seasonal Variation?

– Cyclic Variation?

– Irregular Variation?

(31)

ts.sim

0

2

• EDA-Summary:

> tsdisplay(ts.sim)

0

20

40

60

80

100

-3

0

0.

2

0.

2

F

jr / department of mathematics and computer science 2IS55 TSAwith R

5

10

15

20

-0

.3

0.

0

Lag

ACF

5

10

15

20

-0

.3

0.

0

Lag

PAC

F

62

• Moving Average Process: MA(q)

1 1

t t t q t q

X

Z

Z

Z

• Interpretation: Present Value = Moving Average of Past Disturbances (=shock)

• Process is mainly influenced by ‘random’ events from the past: Economics ?? • MA-models are often used to model time series which show short term dependencies

between successive observations

• Operator Notation:

B

X

t

X

t1

 

t q t

X

B

Z

backshift operator B

 

 

1

1

q q

B

B

q

B

with:

(32)

• Example: MA(2) Process

1 2

0.3

0.4

t t t t

X

Z

Z

Z

23

• Simulation:

 

t q t

X

B

Z

• Operator Notation:

 

 

1 0.3

0.4

2 q

B

B

B

with:

jr / department of mathematics and computer science 2IS55 TSAwith R

ts .s im 0 20 40 60 80 100 -3 -2 -1 0 1 > ts.sim <- arima.sim(list(order= + c(0,0,2), ma=c(-0.3,-0.4)),n=100) > plot(ts.sim)

ts.sim

0

2

64

• EDA-Summary:

> tsdisplay(ts.sim)

0

20

40

60

80

100

-3

0

0.

3

0.

3

F

MA-specific

5

10

15

20

-0

.3

0.

0

Lag

ACF

5

10

15

20

-0

.3

0.

0

Lag

PAC

F

(33)

• Autoregressive Process: AR(p)

1 1

t t p t p t

X

X

X

Z

Interpretation: Present Value

Moving Average of Past Values + Disturbance

• Interpretation: Present Value = Moving Average of Past Values + Disturbance

• Process is mainly influenced by past values of the process !

• AR-models are often used to model time series which show longer term dependencies between successive observations

• Operator Notation:

B

X

t

X

t1

backshift operator B

jr / department of mathematics and computer science 2IS55 TSAwith R

 

p

B

X

t

Z

t backshift operator B

 

 

1

1

p p

B

B

p

B

with:

66

• Example: AR(2) Process

 

0.3

1

0.4

2

t t t t

X

X

X

Z

23

• Simulation:

 

p

B

X

t

Z

t

• Operator Notation:

 

 

1 0.3

0.4

2 p

B

B

B

with:

ts .s im 0 20 40 60 80 100 -3 -2 -1 0 1 > ts.sim <- arima.sim(list(order= + c(2,0,0), ar=c(0.3,0.4)),n=100) > plot(ts.sim)

(34)

ts.sim

0 2

• EDA-Summary:

> tsdisplay(ts.sim) 0 20 40 60 80 100 -3 0 .2 F .2

AR-specific

jr / department of mathematics and computer science 2IS55 TSAwith R

5 10 15 20 -0 .2 0 Lag ACF 5 10 15 20 -0 .2 0 Lag PAC F 68

• Autoregressive Moving Average Process: ARMA(p,q)

 

1 1

1 1

t t p t p t t q t q

X

X

X

Z

Z

Z

• Interpretation: Process is influenced both by levels and by disturbances from

the past!

• Operator Notation:

p

 

B

X

t

q

 

B

Z

t backshift operator B

 

 

1

1

q q

B

B

q

B

 

 

1

1

p p

B

B

p

B

backshift operator B

(35)

• Example: ARMA(1,1) Process

 

0.6

1

0.4

1 t t t t

X

X

Z

Z

23

• Simulation:

• Operator Notation:

 

q

B

 

1 0.4

B

 

1

1 0.6B

B

 

 

p

B

X

t

q

B

Z

t

jr / department of mathematics and computer science 2IS55 TSAwith R

ts .s im 0 20 40 60 80 100 -3 -2 -1 0 1 > ts.sim <- arima.sim(list(order= + c(1,0,1),ar=c(0.6),ma=c(0.4)),n=100) > plot(ts.sim)

ts.sim

0

3

70

• EDA-Summary:

> tsdisplay(ts.sim)

0

20

40

60

80

100

-3

0

0.

6

0.

6

F

AR-specific ?

MA-specific ?

5

10

15

20

-0

.2

0.

2

Lag

ACF

5

10

15

20

-0

.2

0.

2

Lag

PAC

F

(36)

ARMA Model Fitting

stationary series without seasonality

Stochastic Processes:

Stochastic Processes:

Individual stochasts, that might be dependent  t

,

X

t1

, ,

X

t2

,

X

Stochastic Process 1940 1950 1960 1970 1980 1990 2000 2010 5 6 7 8 9 10 11 12 13 14x 104 year labo rf or ce - dat a Realization: Model Fit • Model Identification • Parameter estimation • Model Validation

jr / department of mathematics and computer science 2IS55 TSAwith R

EDA - Finger Print

• Autocorrelation

• Partial Autocorrelation

Theoretical Finger Print

• Autocorrelation

• Partial Autocorrelation

72

> plot(volcano.ts); tsdisplay(volcano.ts)

• Example: Volcanic Dust Veil Index

6 00

0.4

F

0.4

vo lc ano.t s 1500 1600 1700 1800 1900 0 200 400 6

Stationary ?

AR(2) ?

MA(3) ?

0

5 10 15 20 25

0.

0

0

Lag

PA

C

F

0

5 10 15 20 25

0.

0

0

Lag

AC

F

ARMA(1,1) ?

(37)

• Conjecture 1: MA(3)-model ?

> volcano.arma.0.3 <- Arima(volcano.ts,order=c(0,0,3))

> volcano.arma.0.3 Series: volcano.ts

ARIMA(0,0,3) with non-zero mean Coefficients:

ma1 ma2 ma3 intercept 0.7438 0.4513 0.1916 57.4559 s.e. 0.0455 0.0502 0.0442 7.6534

sigma^2 estimated as 4852: log likelihood=-2661.69

AIC 5333 39 AIC 5333 52 BIC 5354 15

  

1 2 3

57.5

0.74

0.45

0.19

t t t t t t t

X

X

X

Z

Z

Z

Z

jr / department of mathematics and computer science 2IS55 TSAwith R AIC=5333.39 AICc=5333.52 BIC=5354.15

• Model Forecasts:

> volcano.arma.0.3.fore <-+ forecast(volcano.arma.0.3,h=19) > plot.forecast(volcano.arma.0.3.fore) 1500 1600 1700 1800 1900 2000 0 2 0 0 400 600 74

• In-Sample Accuracy:

ME RMSE MAE MPE MAPE MASE -0.2205417 69.7825327 37.8638920 -Inf Inf 0.9926308

• In-Sample Diagnostics:

> tsdiag(volcano arma 0 3) > accuracy(volcano.arma.0.3) Standardized Residuals Time 1500 1600 1700 1800 1900 08 0.0 AC F ACF of Residuals

• In-Sample Diagnostics:

> tsdiag(volcano.arma.0.3)

Constant

over time?

Non-zero

Autocorrelations?

0 5 10 15 20 25 0 Lag 2 4 6 8 10 0. 0

p values for Ljung-Box statistic

p v alue

    

2  2 2 # 1 2 k i BL N p i r X N N N i

(38)

• Conjecture 2: AR(2)-model ?

> volcano.arma.2.0 <- Arima(volcano.ts,order=c(2,0,0))

> volcano.arma.2.0 Series: volcano.ts

ARIMA(2,0,0) with non-zero mean Coefficients:

ar1 ar2 intercept 0.7533 -0.1268 57.5274 s.e. 0.0457 0.0458 8.5958

sigma^2 estimated as 4870: log likelihood=-2662.54

AIC 5333 09 AIC 5333 17 BIC 5349 7

 

1 2

57.5

0.75

0.12

t t t t t t

X

X

X

X

X

Z

jr / department of mathematics and computer science 2IS55 TSAwith R AIC=5333.09 AICc=5333.17 BIC=5349.7

• Model Forecasts:

> volcano.arma.2.0.fore <-+ forecast(volcano.arma.2.0,h=19) > plot.forecast(volcano.arma.2.0.fore) 1500 1600 1700 1800 1900 2000 0 2 00 400 6 0 0 76

• In-Sample Accuracy:

ME RMSE MAE MPE MAPE MASE -0.2205417 69.7825327 37.8638920 -Inf Inf 0.9926308

• In-Sample Diagnostics:

> tsdiag(volcano arma 2 0) > accuracy(volcano.arma.2.0) Standardized Residuals Time 1500 1600 1700 1800 1900 08 0.0 AC F ACF of Residuals

• In-Sample Diagnostics:

> tsdiag(volcano.arma.2.0)

Constant

over time?

Non-zero

Autocorrelations?

0 5 10 15 20 25 0 Lag 2 4 6 8 10 0. 0

p values for Ljung-Box statistic

lag p v alue

    

2  2 2 # 1 2 k i BL N p i r X N N N i

(39)

• Conjecture 3: ARMA(1,1)-model ?

> volcano.arma.1.1 <- Arima(volcano.ts,order=c(1,0,1))

> volcano.arma.1.1 Series: volcano.ts

ARIMA(1,0,1) with non-zero mean Coefficients:

ar1 ma1 intercept 0.5848 0.1555 57.5473 s.e. 0.0526 0.0613 8.9412

sigma^2 estimated as 4883: log likelihood=-2663.21

AIC 5334 42 AIC 5334 5 BIC 5351 03

  

1 2 3

57.5

0.3

0.4

0.4

t t t t t t t

X

X

X

X

X

X

Z

jr / department of mathematics and computer science 2IS55 TSAwith R AIC=5334.42 AICc=5334.5 BIC=5351.03

• Model Forecasts:

> volcano.arma.1.1.fore <-+ forecast(volcano.arma.1.1,h=19) > plot.forecast(volcano.arma.1.1.fore) 1500 1600 1700 1800 1900 2000 0 2 0 0 400 600 78

• In-Sample Accuracy:

ME RMSE MAE MPE MAPE MASE -0.2374427 69.8819979 37.7767429 -Inf Inf 0.9903461

• In-Sample Diagnostics:

> tsdiag(volcano arma 1 1) > accuracy(volcano.arma.1.1) Standardized Residuals Time 1500 1600 1700 1800 1900 08 0.0 AC F ACF of Residuals

• In-Sample Diagnostics:

> tsdiag(volcano.arma.1.1)

Constant

over time?

Non-zero

Autocorrelations?

0 5 10 15 20 25 0 Lag 2 4 6 8 10 0. 0

p values for Ljung-Box statistic

p v alue

    

2  2 2 # 1 2 k i BL N p i r X N N N i

(40)

ARIMA Model Fitting

non-stationary series

Time ki ng s.ts 0 10 20 30 40 20 4 0 60 80 Time sk ir ts .ts 1870 1880 1890 1900 1910 600 80 0 1000

Stationary ?

• Level / Variation ?

R

d

jr / department of mathematics and computer science 2IS55 TSAwith R

• Remedy:

• Remove dominant non-stationarity through finite differencing:

X

t

X

t

X

t 1

 

1

B

X

t

• If successful then fit ARMA(p,q) on ▽X

t

ARIMA(p,1,q) on X

t

80

ARMA(p,q) model on W

t

:

 

 

p

W

t q

Z

t

B

B

-200 -100 0 100 200 300 400 500 la bo rfo rce - A R(a ic ) n ois e

ARIMA(p,d,q)-model on X

t

:

194019501960 1970 19801990 2000 2010 -6000 -4000 -2000 0 2000 4000 6000 year labo rforc e de trend pi ece w ise d t t

W

 

X

194019501960 1970 19801990 2000 2010 -400 -300 year 194019501960 1970 19801990 2000 2010 5 6 7 8 9 10 11 12 13 14x 104 year labo rfor ce - da ta

  

1

d

 

p

X

t q

Z

t

B

B

B

194019501960 1970 19801990 2000 2010 -400 -300 -200 -100 0 100 200 300 400 500 year la bo rfo rce - A R(a ic ) n ois e 194019501960 1970 19801990 2000 2010 5 6 7 8 9 10 11 12 13 14x 104 year la bo rfor ce da ta

(41)

• Example: Annual Diameter of Women’s Skirts

> plot(skirts.ts) rts .ts 800 1000 p ( ) sk i 1870 1880 1890 1900 1910 600 > skirts.d1 <- diff(skirts.ts,differences=1) > plot(skirts.d1) sk ir ts .dif 1 6 0 -20 20 60

jr / department of mathematics and computer science 2IS55 TSAwith R

1870 1880 1890 1900 1910 -6 > skirts.d2 <- diff(skirts.ts,differences=2) > plot(skirts.d2) sk ir ts .dif 2 1870 1880 1890 1900 1910 -4 0 -2 0 0 2 0 4 0 82 > tsdisplay(skirts.ts) 2 4 6 8 12 -0 .4 0. 2 0.8 AC F 2 4 6 8 12 -0 .4 0. 2 0.8 PAC F

• EDA-Summary:

2 4 6 8 12 Lag 2 4 6 8 12 Lag > tsdisplay(skirts.d1) 2 4 6 8 12 -0 .4 0. 2 0.6 Lag AC F 2 4 6 8 12 -0 .4 0. 2 0.6 Lag PAC F Lag Lag > tsdisplay(skirts.d2) 2 4 6 8 12 -0 .4 0. 0 0.4 ACF 2 4 6 8 12 -0 .4 0. 0 0.4 PACF

(42)

• Model:

W

t

 

2

X

t

 

X

t

X

t1

X

t

2

X

t1

X

t2 > tsdisplay(skirts.d2)

-0

.4

0.

0

0.4

PA

CF

AR(?)

-0

.4

0.

0

0.4

ACF

MA(?)

jr / department of mathematics and computer science 2IS55 TSAwith R

2 4 6 8

12

Lag

2 4 6 8

12

Lag

ARMA(p,q) on W

t

ARIMA(p,2,q) on X

t 84

• Conjecture: ARIMA(1,2,1)-model ?

> skirts.arima.1.2.1 <- Arima(skirts.ts,order=c(1,2,1)) > skirts.arima.1.2.1 Series: skirts.ts ARIMA(1,2,1) Coefficients: ar1 ma1 -0.3123 0.0139 s.e. 0.4265 0.4449

sigma^2 estimated as 388.7: log likelihood=-193.66

AIC 393 33 AIC 393 93 BIC 398 68

 

 

 

2 1 1

0.31

0.01

t t t t t t

W

X

W

W

Z

Z

AIC=393.33 AICc=393.93 BIC=398.68

• Model Forecasts:

> skirts.arima.1.2.1.fore <-+ forecast(skirts.arima.1.2.1,h=19) > plot(skirts.arima.1.2.1.fore) 1870 1890 1910 1930 -1000 0 500 1500

(43)

SARIMA Model Fitting

0 Time souvenir .t s 1987 1989 1991 1993 0e+ 0 0 4e+ 04 8 e + 0 4 Time bi rt h s. ts 1946 1950 1954 1958 20 22 24 26 28 3 0

• Remedy:

Stationary ?

• Level / Variation ?

Seasonality ?

• Additive / Multiplicative ?

jr / department of mathematics and computer science 2IS55 TSAwith R

y

• Remove dominant non-stationarity through finite differencing:

X

t

X

t

X

t 1

 

1

B

X

t

• Remove dominant seasonality through seasonal differencing:

 

1

s

S

X

t

X

t

X

t s

B

X

t 86 5000 500

ARMA(p,q) for W

t

:

Combined adjustment:

W

t

  

d

sD

X

t

 

1

B

d

1

B

s

D

X

t 194019501960 1970 19801990 2000 2010 -4000 -3000 -2000 -1000 0 1000 2000 3000 4000 5000 year la bo rfor ce ap erio di c

 

 

p

B

W

t

q

B

Z

t 194019501960 1970 19801990 2000 2010 -400 -300 -200 -100 0 100 200 300 400 500 year la bo rfo rce - A R(a ic ) n ois e

Generalisation to account for changes in seasonality:

500 194019501960 1970 19801990 20002010 -4000 -3000 -2000 -1000 0 1000 2000 3000 4000 5000 year la bo rfor ce ap er io dic

 

 

 

 

s p P t s q Q t

W

Z

B

B

B

B

194019501960 1970 19801990 2000 2010 -400 -300 -200 -100 0 100 200 300 400 500 year la bo rfo rce - A R(a ic ) n ois e

(44)

Equivalent:

 

 

 

 

s p P t s q Q t

W

Z

B

B

B

B

-300 -200 -100 0 100 200 300 400 500 labo rforc e - A R (a ic) n oise 194019501960 1970 19801990 2000 2010 -6000 -4000 -2000 0 2000 4000 6000 year la bo rf orce d etren d pi ec ew is e d D t s t

W

  

X

19405 19501960 1970 19801990 2000 2010 6 7 8 9 10 11 12 13 14x 104 year la bo rfor ce - d ata

 

 

q Q t 194019501960 1970 19801990 2000 2010 -400 year

SARIMA (p,d,q)x(P,D,Q)

s

-model:

jr / department of mathematics and computer science 2IS55 TSAwith R

194019501960 1970 19801990 2000 2010 -400 -300 -200 -100 0 100 200 300 400 500 year la bo rforc e - A R(a ic) n oise 194019501960 1970 19801990 2000 2010 5 6 7 8 9 10 11 12 13 14x 104 year labo rfor ce - da ta

 

 

 

 

 

s d D p P s t s q Q t

X

Z

B

B

B

B

88 28 3 0 > plot(births.ts); tsdisplay(births.ts)

• Example: Births per Month in New York City

5 10 15 20 -0 .4 0. 2 0.6 Lag ACF 5 10 15 20 -0 .4 0. 2 0.6 Lag PAC F > births.d1.sd1<-diff(diff(births.ts,differences=1),lag=12,differences=1) > plot(births.d1.sd1); tsdisplay(births.d1.sd1) bi rt hs .t s 1946 1950 1954 1958 20 22 24 26 0 5 15 25 35 -0 .4 -0 .1 0. 2 Lag ACF 0 5 15 25 35 -0 .4 -0 .1 0. 2 Lag PACF bi rt hs. d1. sd1 1948 1952 1956 1960 -3 -2 -1 0 1 2

(45)

• Model:

 

12

 

1

1

12

t t t

W

X

B

B

X

tsdisplay(births.d1.sd1,lag.max=40)

-0

.4

-0

.1

0.

2

PA

CF

AR(?), AR

s

(?)

-0

.4

-0

.1

0.

2

AC

F

MA(?), MA

s

(?)

jr / department of mathematics and computer science 2IS55 TSAwith R

0

10

20

30

40

Lag

0

10

20

30

40

Lag

ARMA(p,q) on W

t

SARIMA(p,1,q)x(P,1,Q)

12

on X

t 90

• Conjecture: SARIMA(3,1,3)x(1,1,0)

12

-model ?

> births.sarima.3.1.3.1.1.0<-Arima(births.ts,order=c(3,1,3), + seasonal=list(order=c(1,1,0),period=12)) > births.sarima.3.1.3.1.1.0 Series: births.ts ARIMA(3,1,3)(1,1,0)[12] Coefficients:

ar1 ar2 ar3 ma1 ma2 ma3 sar1 -1.0567 -0.0302 0.3607 0.9311 -0.4072 -0.7804 -0.5139 s.e. 0.1441 0.2055 0.1497 0.1211 0.1565 0.1288 0.0767 sigma^2 estimated as 0.5566: log likelihood=-178.26

2

AIC=372.51 AICc=373.5 BIC=396.86

• Model Forecasts:

> births.sarima.3.1.3.1.1.0.fore<-+ forecast(births.sarima.3.1.3.1.1.0,h=12) > plot(births.sarima.3.1.3.1.1.0.fore) 20 22 24 2 6 28 3 0 3 2

(46)

More Time Series Modeling…….

jr / department of mathematics and computer science 2IS55 TSAwith R

Paul S. Cowpertwaith et al.,

Introductory Time Series with R, ISBN 978-0387886978

92

Journal of Statistical Forecasting, July 2008, Volume 27, Issue 3

(47)

R b J H d

t l

R b t M Sh

t l

jr / department of mathematics and computer science 2IS55 TSAwith R

Rob. J. Hyndman et al.

,

Forecasting with Exponential Smoothing, ISBN 978-3540719168

Jonathan D. Cryer et al.,

Time Series Analysis with Applications in R,

ISBN 978-1441926135

Robert M. Shumway et al.

, Time Series Analysis and its Applications

with R examples, ISBN 978-1441978646

94

Suggestions for Improvements of TSA

R

are welcomed:

References

Related documents

[r]

A page has a record A at level 0 (parent level) and a record b at level 1 (scroll area and child level), if SaveEdit event of a field in both record has PeopleCode program written

Entry to you the state, was lost to our digital experience possible while the conference title game schedule is looking for the western colorado state rams and the school.. Subject

efficacy of dendritic cells targeting conserved influenza virus antigen expressed by 555.

If the account balance at the statutory retirement age is not su ffi cient to buy an annuity for the part of the ordinary public pension bene fi t that should be fi nanced out

100 Income received from travel, mileage or delivery charges must be included in the taxable gross income when incurred in connection with the sale of tangible personal property or

The present paper deals with the question of whether the sharp risk asymptotics for testing in the sense of Ermakov (1990) can be reproduced in an adaptive setting, in the context of