STAD57 Time Series Analysis Lecure 5 1
Exploraory Daa Analysis Check if given TS is saionary: µ is consan σ 2 is consan γ(s,) is funcion of h= s If no, ry o make i saionary using some of he mehods below: De-rending Differencing Transformaions 2
De-rending Plo TS and/or is MA: if µ seems changing, ry o esimae µ & subrac i from series Y esimae rend ˆ Since E[ ], we have How do we esimae µ? work wih Yˆ ˆ E[ Yˆ ] E[ ˆ ] 0 For deerminisic rend (i.e. funcion of ), can use regression 3
Esimaing Trend Assume deerminisic rend µ =f() For linear rend, use simple linear regression Y 0 1 For nonlinear rend, can use polynomial regression 2 0 1 2... Y or some oher nonlinear regression mehod Regression s explanaory variable is ime (), or some funcion hereof Response could be MA of (o reduce variabiliy) 4
Example Umbrella sales w/ fied linear rend De-rended TS ˆ 6 8 10 12 14 ˆ -4-2 0 2 4 2001 2002 2003 2004 2005 2006 2001 2002 2003 2004 2005 2006 5
Example J&J sales w/ fied quadraic rend De-rended TS 0 5 10 15 ˆ b b b 0 1 2 2-3 -2-1 0 1 2 3 1960 1965 1970 1975 1980 1960 1965 1970 1975 1980 6
Regression in R Fi linear model Yi 0 11, i... p p, i i wih command: lm( Y ~ 1 + + n ) Can save oupu o R objec: ou=lm(y~1+ ) Use summary(ou) o see model summary Coefficien & error sd esimaes, significance ess Feed oupu o oher funcions o ge: ANOVA able: aov(ou) Fied values: fied(ou) Akaike s crierion: AIC(ou), ec 7
Differencing Alernaive o fiing linear rend is differencing: Y ( ) ( Y Y ) 0 1 1 1 1 If {Y } saionary {Y Y 1 } also saionary Differencing more appropriae when {Y } is random walk { } is random walk w/ drif Use when { } seems o hover around linear rend In his case, de-rending is no enough o make series saionary Disadvanage of differencing is ha we canno model dynamics of {Y }, only of {Y Y 1 } 8
Differencing Define backshif operaor B as B k exend i o powers so ha B 1 k Define 1 s order difference operaor as (1 B) Exend i o higher (d h ) order differences d d (1 B) by algebraically expanding operaor (1 B) d 2 2 2 E.g. (1 B) (1 2 B B ) B B 1 and 2 2 2 1 2 9
Differencing in R For 1 s order differences, i.e. use diff() 1 For d h order differences, i.e. use diff(, differences=d) d d (1 B) For simple (1 s order) differences a lag k, i.e. k (1 B ) k, use diff(, lag=k) 10
gemp Example Global Temperaure -0.4-0.2 0.0 0.2 0.4 0.6 TS w/ fied linear rend 1880 1900 1920 1940 1960 1980 2000 gempd gempdif -0.3-0.2-0.1 0.0 0.1 0.2 0.3-0.3-0.2-0.1 0.0 0.1 0.2 0.3 de-rended series 1880 1900 1920 1940 1960 1980 2000 differenced series ˆ 11 1880 1900 1920 1940 1960 1980 2000
ACF of ˆ Example Global Temperaure ACF -0.2 0.0 0.2 0.4 0.6 0.8 1.0 ACF of 0 5 10 15 20 Differencing considerably decreases auo-correlaions random walk w/ drif is more plausible model for series ACF ACF -0.2 0.0 0.2 0.4 0.6 0.8 1.0-0.2 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 ACF of 0 5 10 15 20 12
Seasonaliy Differencing can also be used for seasonaliy If series has seasonal paern wih period d, hen d-lag differences remove paern Define Z (1 B d ) d If d, E[ Z ] E[ d ] 0 paern of period d ( ) d 13
ˆ Example Umbrella sales (quarerly daa, annual paern d=4) y -4-2 0 2 4 2001 2002 2003 2004 2005 2006 6 8 10 12 14 ˆ -2-1 0 1 2 4 2002 2003 2004 2005 2006 differencing also removed linear rend 14 2001 2002 2003 2004 2005 2006
Time Series Regression Can also use regression model o esimae relaionship of one TS o ohers E.g. Y e, where {,Y } are 0 1 2 joinly saionary TS Usual leas squares esimaion is no opimal when dealing wih non-i.i.d. TS daa However, resuls are sill consisen (reliable for large n) if series are saionary Bu never use leas squares for non-saionary TS (e.g. random walks); can ge very bad resuls 15
Example 70 80 90 110 130 50 60 70 80 90 100 20 40 60 80 100 M Cardiovascular Moraliy 1970 1972 1974 1976 1978 1980 Temperaure T 1970 1972 1974 1976 1978 1980 Pariculaes P 50 60 70 80 90 100 Scaer-plo marix of TS relaionships 50 60 70 80 90 100 Moraliy Temperaure Pariculaes 70 80 90 110 130 20 40 60 80 100 20 40 60 80 100 70 80 90 110 130 1970 1972 1974 1976 1978 1980 2 fi model: M 0 1 2T 3T 4P 16
Transformaions If TS has non-consan variance, a nonlinear ransformaion can someimes help For posiive series in paricular, he Box-Cox family of power ransforms can be useful: Y ( 1) /, 0 log( ), 0 Try differen values of λ, and check which one seems o give bes resuls Noe: nonlinear ransforms can also change µ 17
Example Series w/ rend De-rended series J&J sales Original daa: 0 5 10 15 quadraic rend -3-2 -1 0 1 2 3 1960 1970 1980 1960 1970 1980 Transformed daa: Y log( ) 0 1 2 linear rend -0.4-0.2 0.0 0.2 0.4 1960 1970 1980 1960 1970 1980 18
Saionariy Saionariy of γ(s,) is mos difficul o check In pracice, canno verify saionariy since here is no way o esimae γ(s,), only γ(h) Essenially, we assume saionariy in order o carry on wih any TS analysis There are, however, 2 hings we can check: Sample ACF does no change a lo when calculaed from separae sub-sequences of daa Auocorrelaions drop o zero relaively fas (i.e. exponenially) for large lags 19
Example Saionary ACF (AR model) Non-saionary ACF (Random walk) 0.0 0.2 0.4 0.6 0.8 1.0 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 30 0 5 10 15 20 25 30 20