Sunteți pe pagina 1din 21

SERII DE TIMP CURSUL 4

Netezirea exponenial (Exponential smoothing)


-

Tehnic de ajustare care se poate aplica unei serii de timp cu o pronunat component aleatoare.
Este utilizat n principal la realizarea de predicii, atunci cnd alte metode (ARIMA, Trend
determinist etc.) nu dau rezultate.

Context
Fie seria de timp A1 , A2 , ,An..
Modelele de predicie au drept scop estimarea urmtoarelor componente:
1. Media
2. Trendul
3. Componenta sezonier
4. Componenta ciclic
Procesul de predicie
1. Se estimeaz parametrii modelului folosind date istorice.
2. Se testeaz modelul prin back-testing.
3. Se utilizeaz modelul pentru realizarea de predicii n viitor.

Indicatori de acuratee a prediciei


-

Mean absolute deviation (MAD) MAD

Mean square error (MSE) MSE

Root mean square error (RMSE) RMSE

Sum of forecast errors (SFE) SFE

1 n
At Ft
n t 1

1 n
( At Ft ) 2
n t 1

1 n
( At Ft ) 2

n t 1

(A

Ft )

t 1

Tracking signal (TS) TS = SFE/MAD

Senzitivitate vs. stabilitate


Senzitivitate abilitatea unui model de predicie de a rspunde la schimbrile de trend din seria de timp
real.
Stabilitate abilitatea unui model de predicie de a nu fi influenat de schimbrile temporare de trend.
Modele staionare
Metoda mediilor mobile

Ft 1

At At 1 At k 1
k

Exponential Smoothing

Ft 1 Ft ( At Ft ) At (1 ) Ft
-

0<<1 - constanta de netezire; valori marisenzitivitate mai mare, valori micistabilitate mai
mare

Yt 1 At (1 ) At 1 (1 ) 2 At 2 (1 ) 3 At 3
-

Valorile mai recente primesc ponderi mai marimemorie scurt.

Exemplu

Month

Apr-07

May-07

Jun-07

Jul-07

Aug-07

Sep-07

Oct-07

Nov-07

Dec-07

Actual

115

111

120

99

132

120

141

116

141

SMA (6
months)

104.8

108.0

111.7

111.5

109.5

114.8

116.2

120.5

121.3

ES( = 0.2)

104.8

106.8

107.7

110.1

107.9

112.7

114.2

119.5

118.8

160
140
120
100
Actual
80

SMA (6 months)

60

ES( = 0.2)

40
20
0
1

MAD

MSE

SFE

TS

Simple Moving Average

12.30

210.52

76.67

6.23

Exponential Smoothing

13.53

250.43

92.37

6.83

Predicie pentru primele trei luni ale anului 2008


Simple moving average
Forecast = (99+132+120+141+116+141)/6 = 124.8
Exponential smoothing
Forecast = 0.2(141) +(1.0 - 0.2)(118.8) = 123.3

Modele nestaionare

Double Exponential Smoothing

Metoda estimeaz valoarea ateptat la momentul t (Et) i modificarea la momentul t (Tt).


Predicia la momentul t+n este

Ft n E t nTt
3

unde

E t At (1 ) ( E t 1 Tt 1 )
Tt ( E t E t 1 ) (1 )Tt 1
-

(0 < < 1) este parametrul care controleaz media


(0 < < 1) este parametrul care controleaz trendul.

Holt-Winters Additive Method


-

estimeaz n plus componenta sezonier, cu periodicitatea p.


predicia la momentul t+n este

Ft n E t nTt S t n p
Unde:

E t ( At S t p ) (1 ) ( E t 1 Tt 1 )

Tt ( E t E t 1 ) (1 )Tt 1
S t ( At E t ) (1 ) S t p
-parametrul (0 < < 1) este folosit pentru estimarea componentei sezoniere.
Holt-Winters Multiplicative Method

Ft n ( E t nTt ) St n p

Et

At
(1 ) ( Et 1 Tt 1 )
St p

Tt ( E t E t 1 ) (1 )Tt 1
St

At
(1 ) S t p
Et

Filtrul Hoddrick-Prescott
-

metod utilizat pentru estimarea trendului n serii care prezint component ciclic

yt = t + ct

T 1

t min{ ( y t t ) 2 [( t 1 t ) ( t t 1 )]2 }
1

= 1600 pentru date trimestriale


date lunare: 100000-150000
date anuale: 5-15

Serii de timp sezoniere

PIB
40,000

36,000

32,000

28,000

24,000

20,000

16,000
00

01

02

03

04

05

06

07

08

09

10

11

12

13

14

Sezonalitate:
- Stochastic SARIMA
- Determinist medii sezoniere + trend sau sinusoide

Dac f(.) este o serie determinist, atunci f(.) este periodic cu perioada s dac
f t f t k s , k 0,1,2, .
Dac Yt este un process stochastic, acesta este sezonier (periodic) de perioad s dac Yt i Yt+ks au
aceeai distribuie.

Sezonalitate determinist Regression with seasonal dummies


D1 = (1,0,0,0, 1,0,0,0, 1,0,0,0,...)
D2 = (0,1,0,0, 0,1,0,0, 0,1,0,0,)
D3 = (0,0,1,0, 0,0,1,0, 0,0,1,0,...)
D4 = (0,0,0,1, 0,0,0,1, 0,0,0,1,...)

Sezonalitate + trend: Yt t

Dit at .

i 1

Yn h n h i Di ,n h a n h .
i 1

Predicia: Yn h n h

D
i

i ,n h

i 1

Exemplu
Numrul de pasageri transportai pe aeroporturile din Romnia
PASAGERI
3,500,000

3,000,000

2,500,000

2,000,000

1,500,000

1,000,000

500,000
1
1
4q
5q
0
0
20
20

1
6q
0
20

q
07
0
2

1
1
8q
9q
0
0
20
20

1
1
1q
0q
1
1
20
20

q
12
0
2

Transformata Box-Cox pentru a stabiliza variana: Yt ln Yt

3q
01

1
4q
1
20

LNPAS
15.2

14.8

14.4

14.0

13.6

13.2
2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

Testul pentru trend determinist

Dependent Variable: LOG(PASAGERI)


Method: Least Squares
Date: 03/09/15 Time: 20:00
Sample (adjusted): 2004Q1 2014Q3
Included observations: 43 after adjustments
Variable

Coefficient

Std. Error

t-Statistic

Prob.

C
@TREND

13.74419
0.030092

0.066799
0.002739

205.7531
10.98836

0.0000
0.0000

R-squared
Adjusted R-squared
S.E. of regression
Sum squared resid
Log likelihood
F-statistic
Prob(F-statistic)

0.746513
0.740331
0.222848
2.036113
4.564032
120.7441
0.000000

Mean dependent var


S.D. dependent var
Akaike info criterion
Schwarz criterion
Hannan-Quinn criter.
Durbin-Watson stat

14.37612
0.437319
-0.119257
-0.037341
-0.089049
1.092921

Corelograma reziduurilor

Corelograma seriei logaritmate

Model cu trend i sezonalitate


4

Yt t i Dit at sau ln Yt t i Dit at .


i 1

i 1

Dependent Variable: PASAGERI


Method: Least Squares
Date: 03/09/15 Time: 20:07
Sample (adjusted): 2004Q1 2014Q3
Included observations: 43 after adjustments
Variable

Coefficient

Std. Error

t-Statistic

Prob.

@TREND
D1
D2
D3
D4

48471.73
517092.2
963172.0
1345242.
712056.6

2725.701
86194.22
87943.46
89741.39
90442.35

17.78322
5.999151
10.95217
14.99021
7.873044

0.0000
0.0000
0.0000
0.0000
0.0000

R-squared
Adjusted R-squared
S.E. of regression
Sum squared resid
Log likelihood
Durbin-Watson stat

0.917148
0.908427
221437.0
1.86E+12
-587.5961
0.758846

Mean dependent var


S.D. dependent var
Akaike info criterion
Schwarz criterion
Hannan-Quinn criter.

1906305.
731756.8
27.56261
27.76740
27.63813

Dependent Variable: LOG(PASAGERI)


Method: Least Squares
Date: 03/09/15 Time: 20:08
Sample (adjusted): 2004Q1 2014Q3
Included observations: 43 after adjustments
Variable

Coefficient

Std. Error

t-Statistic

Prob.

@TREND
D1
D2
D3
D4

0.029384
13.55297
13.80789
13.97890
13.69018

0.001964
0.062092
0.063352
0.064647
0.065152

14.96505
218.2721
217.9545
216.2330
210.1258

0.0000
0.0000
0.0000
0.0000
0.0000

R-squared
Adjusted R-squared
S.E. of regression
Sum squared resid
Log likelihood
Durbin-Watson stat

0.879620
0.866949
0.159517
0.966941
20.57423
0.118787

Mean dependent var


S.D. dependent var
Akaike info criterion
Schwarz criterion
Hannan-Quinn criter.

10

14.37612
0.437319
-0.724383
-0.519592
-0.648862

15.5
15.0
14.5
.3

14.0

.2
13.5
.1
13.0

.0
-.1
-.2
-.3
04

05

06

07

08

Residual

09

10

Actual

11
Fitted

Corelograma reziduurilor

11

12

13

14

Predicia

6,000,000

5,000,000

4,000,000

3,000,000

2,000,000

1,000,000

0
04

05

06

07

08

09

10

L
PASAGERI

11

12

13

14

U
PASAGERIF

7,000,000

Forecast: PASAGERIF
Actual: PASAGERI
Forecast sample: 2004Q1 2014Q4
Included observations: 43
Root Mean Squared Error 305878.4
Mean Absolute Error
254579.7
Mean Abs. Percent Error
13.74182
Theil Inequality Coefficient 0.073921
Bias Proportion
0.006671
Variance Proportion
0.104974
Covariance Proportion
0.888355

6,000,000
5,000,000
4,000,000
3,000,000
2,000,000
1,000,000
0
04

05

06

07

08

09

PASAGERIF

10

11

2 S.E.

12

12

13

14

Sezonalitate Stochastic SARIMA

SARIMA (P, D, Q)s : P B s 1 B s Yt 0 Q B s at , unde


B 1 B

P B s 1 1 B s 2 B 2 s P B sP
Q

2 B 2 s Q B sQ .

Exemplu: SARIMA(0,0,1)12=SMA(1)12
Yt 0 at at 12 .

Condiia de invertibilitate: ||< 1.

13

E(Yt) = 0.

Var Yt 1 2 a2


, k 12

ACF : k 1 2
.
0, altfel

Exemplu: SARIMA(1,0,0)12

1 B Y
12

0 at - model AR sezonal.

Yt Yt 12 0 at .

Condiia de staionaritate:||<1.

E Yt

Var Yt

ACF : 12 k k , k 0,1, 2, .

0
.
1

a2
.
1 2

Modelul multiplicativ sezonal

SARIMA(p, d, q)(P,D,Q)s : p B P B s 1 B 1 B s Yt 0 q B Q B s at .
d

Condiie: rdcinile polinoamelor (B); (Bs); (B) i (Bs) snt n afara cercului unitate!

Exemplu: modelul SARIMA(0,1,1)(0,1,1)12

1 B 1 B12 Yt 1 B 1 B12 at , unde ||<1 i ||<1.

Fie Wt = (1 B)(1 B12)Yt, unde = (1 B) este diferena standard, iar 12= (1 B12)
este diferena sezonier.

Wt 1 B 1 B12 at

Wt at at 1 at 12 at 13 .
Wt ~ I 0

14

1 2 1 2 a2 , k 0

2
2
1 a , k 1

k 1 2 a2 , k 12 .

2
a , k 11,13
0, o.w.


1 2 , k 1


, k 12

.
k 1 2

, k 11,13

2
2
1 1
0, o.w.

SARIMA(1, 1, 1)(1,1,1)12.

1 B 1 B12 (1 B)(1 B12 ) ln Yt 1 B 1 B12 t


AR(1) ne-sezonier*AR(1) sezonier*diferen ne-sezonier*diferen sezonier=
MA(1) ne-sezonier*MA(1) sezonier

Exemplu Numrul de pasageri transportai de liniile aeriene n Romn, valori lunare.

15

PASAGERI
1,200,000

1,000,000

800,000

600,000

400,000

200,000

5
00

1
2

1
6m
0
0

7
00

1
m
2

8
00

1
m

1
9m
0
20

0
01

1
m

m
11
0
2

1
2

2
01

1
m
2

3
01

1
2

4
01

a. Logaritmarea pentru inducerea staionaritii n varian: Yt ln Yt .


b. Eliminarea trendului prin difereniere: ln Yt (1 B ) ln Yt ln Yt ln Yt 1
DLNPAS
.6

.4

.2

.0

-.2

-.4

-.6
2005

2006

2007

2008

2009

2010

16

2011

2012

2013

2014

c. Corelograma seriei logaritmate i differentiate

d. Desezonalizare: Xt = (1 - B)(1 - B12)ln Yt


series dlnpas=d(lnpas,1)
series x=dlnpas-dlnpas(-12)

e. Corelograma seriei Xt

17

f. Includerea termenului sezonier SMA(12)


Dependent Variable: X
Method: Least Squares
Date: 03/09/15 Time: 21:48
Sample (adjusted): 2006M02 2014M09
Included observations: 104 after adjustments
Convergence achieved after 13 iterations
MA Backcast: 2005M01 2006M01
Variable

Coefficient

Std. Error

t-Statistic

Prob.

C
MA(1)
SMA(12)

-0.002467
-0.741865
-0.932179

0.000847
0.067615
0.030537

-2.913685
-10.97193
-30.52573

0.0044
0.0000
0.0000

R-squared
Adjusted R-squared
S.E. of regression
Sum squared resid
Log likelihood
F-statistic
Prob(F-statistic)
Inverted MA Roots

0.643076
0.636008
0.095244
0.916222
98.48852
90.98681
0.000000
.99
.50-.86i
-.50+.86i
-.99

Mean dependent var


S.D. dependent var
Akaike info criterion
Schwarz criterion
Hannan-Quinn criter.
Durbin-Watson stat

.86-.50i
.50+.86i
-.50-.86i

.86+.50i
.00+.99i
-.86+.50i

18

-0.000836
0.157868
-1.836318
-1.760037
-1.805414
1.702707

.74
-.00-.99i
-.86-.50i

g. Includerea componentei sezoniere SAR(12)

Dependent Variable: X
Method: Least Squares
Date: 03/09/15 Time: 21:50
Sample (adjusted): 2007M03 2014M09
Included observations: 91 after adjustments
Convergence achieved after 31 iterations
MA Backcast: 2006M02 2007M02
Variable

Coefficient

Std. Error

t-Statistic

Prob.

C
AR(1)
SAR(12)
MA(1)
SMA(12)

-0.003168
0.378653
-0.330655
-0.850327
0.974889

0.002761
0.135663
0.056928
0.079750
0.015391

-1.147497
2.791137
-5.808277
-10.66237
63.34215

0.2544
0.0065
0.0000
0.0000
0.0000

R-squared
Adjusted R-squared
S.E. of regression
Sum squared resid
Log likelihood
F-statistic
Prob(F-statistic)
Inverted AR Roots

Inverted MA Roots

0.742181
0.730190
0.077057
0.510648
106.7001
61.89199
0.000000
.88+.24i
.38
-.24-.88i
-.88-.24i
.96+.26i
.71+.71i
-.26-.96i
-.96+.26i

Mean dependent var


S.D. dependent var
Akaike info criterion
Schwarz criterion
Hannan-Quinn criter.
Durbin-Watson stat

-0.005014
0.148348
-2.235168
-2.097208
-2.179510
1.975411

.88-.24i
.24-.88i
-.64+.64i

.64-.64i
.24+.88i
-.64-.64i

.64-.64i
-.24+.88i
-.88+.24i

.96-.26i
.26-.96i
-.71-.71i

.85
.26+.96i
-.71-.71i

.71-.71i
-.26+.96i
-.96-.26i

Model final:

1 0.37 B 1 0.33B12 X t 1 0.85B 1 0.97 B12 t


unde t este WN N(0, =0.07).
1 0.37 B 1 0.33B (1 B)(1 B ) ln Yt 1 0.85B 1 0.97 B12 t
12

12

unde t este WN N(0, =0.07).

19

Predicia
.6
.4
.2
.0
-.2
-.4

.2

-.6

.1
.0
-.1
-.2
-.3
2007

2008

2009

2010

Residual

2011
Actual

2012

2013

2014

Fitted

1,400,000

Forecast: PASAGERIF
Actual: PASAGERI
Forecast sample: 2005M01 2014M09
Adjusted sample: 2007M03 2014M09
Included observations: 91
Root Mean Squared Error 50852.49
Mean Absolute Error
37763.02
Mean Abs. Percent Error
5.429306
Theil Inequality Coefficient 0.032662
Bias Proportion
0.000374
Variance Proportion
0.003338
Covariance Proportion
0.996288

1,200,000

1,000,000

800,000

600,000

400,000

200,000
2007

2008

2009

2010
PASAGERIF

2011

2012
2 S.E.

20

2013

2014

1,400,000

1,200,000

1,000,000

800,000

600,000

400,000
I

II

III

IV

II

2012

III

IV

2013
UPPER
PASAGERI

21

II
2014

PASAGERIF
LOW ER

III