Chap 4: Les Processus ARIMA

Analysis of Time Series, Statistical Modeling · course

Voir tous les documents en systèmes d'exploitation et cloud

Chap 4

Les Processus ARIMA

(p,d,q)

1

En analyse de séries chronologiques,

un modèle autorégressif à moyenne mobile intégrée

(ARIMA) est une généralisation d'un modèle autorégressif à

moyenne mobile (ARMA).

Ces deux modèles sont ajustés aux données de séries

chronologiques:

 Soit pour mieux comprendre les données,

 soit pour prédire les points futurs de la série (prévisions).

2

les

données montrent

Les modèles ARIMA sont appliqués dans certains cas

stationnarité,

où une étape de différenciation initiale (correspondant à la

partie "intégrée" du modèle) peut être appliquée une ou

plusieurs fois pour éliminer la non-stationnarité.

de non-

preuves

des

3

Le I (pour "integrated") indique que les valeurs des

données ont été remplacées par la différence entre leurs

valeurs et les valeurs précédentes

(et ce processus de différenciation peut avoir été

effectué plus d'une fois).

Le but de chacune de ces fonctionnalités est d'adapter

au mieux le modèle aux données.

4

 Non-seasonal ARIMA models

Seasonal ARIMA models: SARIMA

5

ARIMA(p,d,q)

d : est le degré de différenciation (le nombre de fois où

les données ont eu des valeurs passées soustraites

6

y′ : is the differenced series (it may have been

differenced more than once).

The “predictors” on the right hand side include both

lagged values of yt and lagged errors,

7

8

La différenciation statistique est une transformation appliquée

aux données de séries chronologiques afin de les rendre

stationnaires. Le code R est diff : [i] – [i-1]

Les propriétés d'une série chronologique stationnaire ne

dépendent pas de l'heure à laquelle la série est observée. Afin

de différencier les données, la différence entre les observations

consécutives est calculée.

Mathématiquement, cela est montré comme

Y’t = yt – yt-1

9

il peut être nécessaire de différencier

les

Parfois,

données une deuxième fois pour obtenir une série

chronologique stationnaire,

appelée différenciation de second ordre:

10

Une autre méthode de différenciation des données

Publicité

est la différenciation saisonnière,

qui consiste à calculer

observation

et

précédente,

par exemple une année. Cela se présente comme:

l'observation correspondante de la saison

la différence entre une

11

Library(fpp2)

Window(uschange)

autoplot(uschange[,"Consumption"]) +

xlab("Year") + ylab("Quarterly percentage

change")

12

13

Comparer la série avec: ARIMA(1,0,3) model

yt=c+0.589yt−1−0.353εt−1+0.0846εt−2+0.174εt−3+εt,

where c=0.745×(1−0.589)=0.307 and εt is white noise

with a standard deviation of 0.592

14

15

Test de stationnarité Kwiatkowski-Phillips-Schmidt-Shin (KPSS) test

Pour tester objectivement la stationnarité on peut utiliser le test KPSS,

H0: Série stationnaire

H1: Série non stationnaire

Si le P value < 0,05 on acceptera H1

Package urca

Ur.kpss

ur.kpss(uschange[,1])

# KPSS Unit Root /

Cointegration Test # #####

The value of the test statistic is: 0.2848

16

urt<-ur.kpss(u,type=c("mu","tau"))

> summary(urt) # KPSS Unit Root Test

 #Test is of type: mu with 4 lags.

 Value of test-statistic is:

0.2848 Critical value for a significance level of:

 10pct 5pct 2.5pct 1pct

critical values 0.347 0.463 0.574 0.739

17

Exemples d’ARIMA

ARIMA(0, 1, 0) model is given by:

ARIMA(0, 2, 2) model is given by :

18

certaines

L’hypothèse de stationnarité, présente -

conditions - dans les modèles ARMA, n’est que rarement vériée

pour des séries économiques.

sous

En revanche, on peut considérer les différences premières

∆Xt = Xt−Xt−1,

ou des différences à des ordres plus élevés

19

Un processus (Xt) est un processus ARIMA(p,d,q) - autorégressif

moyenne mobile intégré - s’il vérifie une équation du type

20

 arima.sim(n=200, list(ar=0.4, ma=0.8, d=1))

Xt = 0,4Xt-1 +0,8Et-1 + Et ARMA(1,1)

 arima.sim(n=200, list(ar=c(0.4,0.9), ma=0.8, d=1))

 arima.sim(n=200, list(ar=c(0.4, 0, 0.9), ma=0.8,

d=2))

21

Publicité

AirPassengers

Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1949 112 118 132 129 121 135 148 148 136 119 104 118

> plot(AirPassengers)

Que remarquez vous (série

NS)

d<-diff(AirPassengers)

> as.ts(d)

Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov 1949

6 14 -3 -8 14 13 0 -12 -17 -15 1950 -3 11 15 -6 -10 24 21 0 -12 -25 -19

22

plot.ts(d) >

d1<-diff(d) >

as.ts(d1)

plot.ts(d1)

> d2<-diff(d1)

> as.ts(d2)

23

plot.ts(d) >

d1<-diff(d) >

as.ts(d1)

plot.ts(d1)

> d2<-diff(d1)

> as.ts(d2)

24

 Comment estimer le meilleur ARIMA pour une série:

 Comment estimer d

 Comment estimer p, q

25

26

Retour à AirPassengers

fit<-arima(AirPassengers,

order=c(2,2,1))

 Fit

Call: arima(x = AirPassengers, order = c(2,

2, 1)) Coefficients: ar1 ar2 ma1 0.3845 -

0.2259 -1.0000 s.e. 0.0828 0.0838 0.0177

sigma^2 estimated as 980.3: log likelihood =

-692.94, aic = 1393.88

27

 > fit1<-arima(AirPassengers,

order=c(2,1,2))

 > fit1

Call:

arima(x = AirPassengers, order = c(2, 1, 2))

Coefficients:

ar1 ar2 ma1 ma2

0.3517 0.1887 -0.0806 -0.7218

s.e. 0.1543 0.1501 0.1216 0.1143

sigma^2 estimated as 887.2: log likelihood = -688.7, aic = 1387.41

28

Quel ARIMA FAUDRAIT IL CHOISIR

29

Maximum likelihood estimation

30

In practice, R will report the value of the log

likelihood of the data; that is, the logarithm of

the probability of the observed data coming

from the estimated model. For given values

of p, d and q, R will try to maximise the log

likelihood when finding parameter estimates.

31

Le critère d'information d'Akaike, (en anglais Akaike

information criterion ou AIC) est une mesure de la

qualité d'un modèle statistique proposée,

Publicité

Lorsque l'on estime un modèle statistique, il est possible

d'augmenter la vraisemblance du modèle en ajoutant

un paramètre.

On choisit alors le modèle avec le critère

d'information d'Akaike le plus faible.

32

Good models are obtained by minimising

the AIC or AICc,

33

It is important to note that these information criteria

to be good guides to selecting the

tend not

appropriate order of differencing (d) of a model, but

only for selecting the values of p and q.

34

En effet, la différenciation modifie les données sur

lesquelles la probabilité est calculée, ce qui rend les

valeurs AIC entre les modèles avec différents ordres

de différenciation non comparables..

So we need to use some other approach to

choose d, and then we can use the AICc to

select p and q.

35

36

> install.packages("forecast")

library(forecast)

> checkresiduals(fit)

 Ljung-Box test data: Residuals from ARIMA(2,2,1) Q* = 234.29, df = 21,

 p-value < 2.2e-16 Model df: 3. Total lags used: 24

> checkresiduals(fit, plot = TRUE )

37

38

Forecast

help(checkresiduals) >

autoplot(forcast(fit))

Error in forcast(fit) : could not find function

"forcast"

> autoplot(forecast(fit))

39

40

Recherche du meilleur modèle

par la fonction auto,arima

41

The auto.arima() function in R uses a variation of

the Hyndman-Khandakar algorithm (Hyndman &

Khandakar, 2008), which combines unit root

tests, minimisation of the AICc and MLE to obtain

an ARIMA model.

The arguments to auto.arima() provide for many

variations on the algorithm. What is described

here is the default behaviour

42

Hyndman-Khandakar algorithm for automatic ARIMA

modelling

1.The number of differences 0≤d≤2 is determined using

repeated KPSS tests.

2.The values of p and q are then chosen by minimising

the AICc after differencing the data d times. Rather than

considering every possible combination of p and q, the

algorithm uses a stepwise search to traverse the model

space.

43

Four initial models are fitted:ARIMA(0,d,0)(0,d,0),

ARIMA(2,d,2)(2,d,2),

Publicité

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

ARIMA(0,d,1)(0,d,1).

A constant is included unless d=2. If d≤1, an

additional model is also fitted:

ARIMA(0,d,0) without a constant.

44

2.The best model (with the smallest AICc value) fitted in step (a) is

set to be the “current model.”

3.Variations on the current model are considered:

3.vary pp and/or qq from the current model by ±1;

4.include/exclude cc from the current model.

4.The best model considered so far (either the current model or

one of these variations) becomes the new current model.

4.Repeat Step 2(c) until no lower AICc can be found.

45

Modelling procedure

When fitting an ARIMA model to a set of (non-seasonal) time series

data, the following procedure provides a useful general approach.

Plot the data and identify any unusual observations.

If necessary, transform the data (using a Box-Cox transformation) to

stabilise the variance boxcox(object, …)..

If the data are non-stationary, take first differences of the data until

the data are stationary.

Examine the ACF/PACF: Is an ARIMA(p,d,0p,d,0) or ARIMA(0,d,q0,d,q)

model appropriate?

Try your chosen model(s), and use the AICc to search for a better

model.

Check the residuals from your chosen model by plotting the ACF of

the residuals, and doing a portmanteau test of the residuals. If they

do not look like white noise, try a modified model.

46

auto.arima(AirPassengers)

Optimisation d’un ARIMA

 Series: AirPassengers

 ARIMA(2,1,1)(0,1,0)[12]

 Coefficients:

 ar1 ar2 ma1 0.5960 0.2143 -0.9819 s.e. 0.0888 0.0880 0.0292

 sigma^2 estimated as 132.3:

 log likelihood=-504.92 AIC=1017.85 AICc=1018.17 BIC=1029.35

47

Evaluer l’optimum

> fit1<-auto.arima(AirPassengers)

checkresiduals(fit1)

48

49

Prédiction

predict(fit1, n.ahead = 5)

 $pred Jan Feb Mar Apr May

 1961 445.6349 420.3950 449.1983

491.8399 503.3945 $se

Jan Feb Mar Apr May

1961 11.50524 13.50261 15.15798

16.24046 17.04072

50

 futur<-forecast(fit1, h=10)

 > plot.forecast(futur)

 Error in plot.forecast(futur)

 : could not find function "plot.forecast«

 > autoplot(forecast(fit1), h=10)

51

52

Happy

53