CNwt QwBU=@a Qmi C O}yW = =Q u H xm jQ@ w ? = x@ u s v CavY QO xS} w EL=@t 100 Q=DWwv CU=Q} w |vWwOv|wUwt O}aUO}U s_mousavi@pwut.ac.ir 1391 R}}=B x=oWv=O ?r=]t CUQyi O 1 1 1 1 3 5 6 6 7 7 8 8 9 10 10 Q=DioV}B v tR |=y|QU pw= pYi | = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |= Q . |rY Q}}e O | = Q s} Q . . . . = Q s} Q . . . | = Q Ov . |rY Q}}e O . . . . . . . . . . . . . . . | = = Q x RH ............... = O . . . . . . . . . . R = xi w x RH . . . . . . . . . . . . . . . . . . . . |oDU@t . . . . . . . T = u}o =} h Qa . . . . . |oDU@t T = w h Qa . |oDU@t w T = w w ` w h Qa . |oDU@t w x@ =L . . . . =o |oDU@t v tR | U i C= D w vwQ ' y| U v tR | U i C= D w v tR | U U D U D 1111 J 2111 vwQ 3111 111 v tR | y| U yp t QO y r -t } D } D y w yO N w 221 v t } D 131 v } Q=w m } D 231 } D 331 yO N Q v hr= v } Q= m D= U @= D t 1331 y 2331 21 121 y v } Q=w w 11 31 16 16 16 17 17 17 19 19 19 20 21 21 21 23 23 24 25 26 26 27 27 27 28 30 30 30 32 34 34 35 35 36 37 37 } B |iO=YD |=ypOt swO pYi x = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . =ov|oDU@ty ......... . . . . . x Ok . . . . h Qa R = x}@ 112 D 212 W 312 X= N 412 } QO |R U w swO x@DQt O}iU xiwv t t w . . . . . . . . . . . . . . .| . . . . . . . . . . . . . x Ok . . . . . . . . . . . . h Qa . . . . . . . QU =kD Qort . | =Y = x@ Q w . . . . . . . . . p =i Qort .......... = x}@ . . . . . . . . . . . . . . w} Q . . . . . . . . . . . . h Qa . w} Q w | =DU = | =DU . . AR(1) O x@ Q w . . . AR(1) Ov Q =o |oDU@t . . . . | R |oDU@t w ` = .......... = x}@ . . . . . . xD = Q = O =YD iO 122 D 222 a 322 D t X= N 422 } w iO B p D uORs o swO = uORs o t t v= D a 522 |R U W 622 w = O U oQ D= | yp t D 132 }= 232 D t X= N 332 v y 432 yO N @ D 532 |R U W 632 i } VR= @ | yp t 732 } U oQ D= QO }= v w } p t swO } i Q } H = x}@W xDi=} . . . . Q x W |R U ... . . . . = | yxO=O Q VR= @ AR Q@ xDi=} O Q } = O 832 Q 932 VR= @ | yp t |v=yH p t % = | tO | U 12 22 32 }= |=ypOt swU pYi =DU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . QLD u}o =} . . . . w h Qa MA(q) Ov Q = x}@ =o |oDU@t R = =F . . . . . . . . . . . . . xD = Q MA . O = x}@ Q x xD = Q O . . . . . . . . . . ARMA Ov Q |@} Q . . . . . . . . . . . . . . . h Qa . . . . . . . . . O x@ Q w . . . . . . . . . . | QH p}rL ARMA . . . . . . . . . . Q = x}@ l X= N w |R U W w Q } t y % 113 | yp t 213 i } VR= @ x W |R U W | U @ i } VR= @ p t } i % @ D O = O m D | yp t D t X= N 233 D % W 13 23 123 133 VR= @ w |R U ? = | yp t D } p t swO O } i D % v = v t | yp t = O | yp t 143 33 43 37 39 40 40 41 42 43 44 44 45 47 47 50 50 51 52 53 54 . . . . . . . . . . . . . . . . . . . . . . . . . . . p O@ } Q Q D Mv | U 243 }==v |=ypOt sQ=yJ pYi =DU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |rY Q} ARIMA . . . . . . . Q O} w Q p =i . . . . . . . . . . . . |k}ir O . . . . . . . . . . = =F h Qa . . . . . . . . . Q = x}@ . . . . . . . . . . . . |rY ARIMA = . . . . . . . . . . . . . . h Qa ............ Q x . . . . . . . . . . . . . . . . ARCH = . . . . . . . . . SP500 = Q ARCH O h Qa O = = Q O . GARCH = O x w Q = \U xD = Q GARCH O = x}@ . . . . . . . . SP500 Q Q Q . . . . . . . . s}r Q O== . . = x}@ |v} V} GARCH i j @ e O p t D 114 D p t 214 r D | U w yp t w } VR= @ w |R U D 314 W 414 i } VR= @ O | yp t D 124 } wQ 224 O | yp t p t } | y| U 134 D %|Q= } B v uO m p t 234 @ \ @ t | y @ 334 p t w |R U W 434 @ VR= @ 534 k= | U QO |Q= } B v 634 | yp t i } VR= @ | U |R U W w 56 @ B QO 14 24 34 734 H=Qt ` G Q=DioV}B OW x=Q= OvDUy OD@= x=Q |= QO w | " OD@t xv}tR u}= CU= = xm |v=Um |}=vW Qw_vt x@ QO =} p@=k u=o}=Q |R UxO B R R Q Q |twta Q=DWwv Q= i=s v |= @ w x xm CiQo Q=Qk Q} R CQ Y @ x@ TQO R C= } U QO w http://cran.r-project.org/doc/contrib/Mousavi-R-lang_in_Farsi.pdf j} Q] R= =Q Q}kL sy w |t "O W O |=x a w CU= xDiQo Q=Qk RoU=BU =yv |Q= =H u}ty R= Ovtxkqa u= R= =iDU= xO w O xDio xDWwv xm OUQ|t Q_v x@ OQ t x W xm OvO=O Q=Qk V} wN C@Lt h]r w w l}vwQDmr= CUB OQ t EL=@t u=wva Q} R Q=L Q=DWwv u}=Q@=v@ "sO=Di= R OOt x@ X=N EL=@t R= |=xQ=B x}yD Qmi x@ x=Q xt=O= QO xOv@ Q |t KQ]t xOv@ lOv= Ca=@ OL "OO o x@ EL=@t u}= Q@ w |t s}OkD pYi OvJ w O W Q xm OwW|t u=Wv Q]=N =Hv}= Z i CU= " =kDQ= u < w K QO xO wtv ?Um qY= Q =Q R QO u K W xm w | D Q QO "O W R = u}tR O w Q t pY=L '| L OQ=O w Q}O=kt '|v=tR |v=tR = Q | y| U Q Kkvt xDWwv =D Q_v Q=y_= xvwo Qy = Q Ovv=t | y| U x@ =YDN= X Q |t V}=Q} w OO o Q = x}rw= |}=vW 'xS} w EL=@t ?}kaD Q= i=s v @ =yvW}B |= @ |O ::: w R}}=B QyD u= O EL@t u}rw= O@=}|t xt=O= Q Qw t Q |t=Qo xOvv=wN xm CU= u}= OvU} wv 'CU}v prN R= x R= |r=N Q=L xR}Hw ,=trUt wtv Oy=wN 1391 S QO x } w |= @ "O |vWwOv|wUwt O}aUO}U u R xO =iDU= w p =@kDU= pw= pYi |v=tR |=y|QU |v=tR x@ Ov=wD|t =@ "OO o x@ C= y O =Wt C@F pta "Ovvm|t Q}}eD u=tR C= y Q |t O}m =D =Ut |v=tR pY=wi =@ xDUUo C@F |w O =Wt xawtHt w 1,2, ,n w CQ Y w |t "O W xm CU= |}=yOv}Qi C@F QO |wQ =Hv}= QP =Wv x1 x2 |rYi OvDQ=@a |v=tR =Hv= xDUw}B =} QO "O } B s x@ |v=tR xawtHt '?U=vt |v=tR xO=O u R= xn = C=Q}}eD w T =}kt w w |v=tR g CU= xOW C@F " 1949-1960 = xQwO QO Q t wva Q} R R OwN QO |}=yxO=O p}=i R= u}= "OyO|t u=Wv ::: pmW 1 1 1 1111 y|QU s}UQD u= =NDv= ? n = u} Qi=Ut O=OaD xm OwW|t xO=iDU= AirPassengers w O@t s}UQD Q CQ Y <= xt : t = 1 2 '|v=tR |QU = | y| U xDUUo } w f OvwQ 11 |QU w s}UQD |=Q@ Qiv Q=Ry ?UL Q@ xv=y=t |rrtr=u}@ =Q %p=Ft > data(AirPassengers) 1 1391 ' |vWwOv|wUwt 2 > AP <{ AirPassengers > plot(AP, ylab = "Passengers (1000's)") O w| x w window() = x R = t m OQ=O O Hw s v @ u @ R QO | Qo}O `@=D "CU= q=@ = O Q | y ) m |= H= pY=L 11 pmW 400 300 100 200 Passengers (1000’s) 500 600 v= D 1950 1952 1954 1956 1958 1960 Time u} Qi=Ut xv=y=t |v=tR Q | U V}=tv %11 O}vm xHwD Q} R p=Ft x@ "OyO CUOx@ " pmW =Q |v=tR Q x wtHt Q} R l} | U R= |= a > x <{ AirPassengers > y <{ window(x, 1950, 1951) CU= Q} R " w CQ Y x@ u xH}Dv xm Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1950 115 126 141 135 125 149 170 170 158 133 114 140 1951 145 " O}vm xHwD Q} R p=Ft x@ x=t ,qFt 'O}W=@ xDW=O pQDvm p=U R= |rYi |wQ O}y=wN@ Qo = > x <{ AirPassengers > y <{ window(x, 1950, c(1951,0)) CU= Q} R " w CQ Y x@ u xH}Dv xm Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1950 115 126 141 135 125 149 170 170 158 133 114 140 O}vm xHwD Q} R p=Ft x@ =} " > x <{ AirPassengers > y <{ window(x, c(1950,2), c(1951,3)) |v=tR 3 = Q | y| U 1 pYi Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1950 126 141 135 125 149 170 170 158 133 114 140 1951 145 150 178 O M} Q=D xm O}vm xHwD Q} R x = = |v=tR "OQ= v V1 V2 V3 V4 V5 3.59 2.20 4.53 7.01 10.45 9.60 19.12 21.93 24.20 25.22 3.13 3.97 17.52 11.77 9.65 2.76 4.17 6.71 10.57 9.87 1.22 2.81 6.25 9.07 28.12 ... ... ... ... 1 2 3 4 5 x@ wtv sUQ "O =Q =yu TBU V6 43.86 42.28 18.26 7.58 20.00 ... Q sy QU CWB w xO=O Q= k " CU= Q} R KQW x@ V7 59.97 37.32 72.26 15.45 36.48 ... = = Q | U x@ uwvm = V8 V9 V10 V11 V12 92.29 47.00 19.16 12.45 8.84 14.11 6.75 4.40 2.62 2.82 32.45 12.09 5.12 3.03 2.46 29.85 4.25 1.74 1.12 1.04 45.32 12.19 2.98 2.85 2.19 ... ... ... ... ... = O}=@ =OD@= xv=y=t =Q |Q t | yp U w | v y t = O pw= CQ Y | y ) m "O=O s =Hv= = | yxO=O = u}= s}UQD w |t =Q Q m Q |= @ w u= D CQ Y wO > x <{ matrix(scan("F:/R_les/data/ghar.txt"), ncol=12, byrow=T) > y <{ t(x) > y <{ matrix(y,ncol=1, byrow=T) > ts.plot(y) CU= Q} R KQW x@ " w = O swO CQ Y | y ) m > x <{ read.table("F:/R_les/data/ghar.txt") > y <{ as.matrix(y) > y <{ t(x) > y <{ matrix(y, ncol=1, byrow=T) > ts.plot(y) 2111 v tR |QU OvJ | = O}rwD p}=i 1990 u}= w = p U =D 1958 u)D ?UL Q@ "OQ=O O Hw = =}r=QDU= qmW w p U R= C qFt QO , =Wv "O=O u w w x s-= D CQ Y @ =Q |v=tR QD}r uw}r}t ?UL Q@ Q}aWr=<=t 'Ca=U w |t xOv=wN "O W RO ) m \UwD Q | U OvJ w |t u= D wr}m ?UL Q@ C=w online w x Q CQ Y @ | U Q j @ xU > "http://www.massey.ac.nz/~pscowper/ts/cbe.dat" > CBE <{ read.table(www, header = T) CBE1:4, ] CU= Q} R " w x = = O |HwQN CQ Y @ q @ | y ) m 1391 ' |vWwOv|wUwt 4 choc beer elec 1 1451 96.3 1497 2 2037 84.4 1463 3 2477 91.2 1648 4 2785 81.9 1595 |=Q=O w Q OvQ=Ov M} Q=D Qo}O wtv p}O@D |v=tR |= @ "O =@ x@ "OvDUy x=t CQ a Q | U x@ ts() ` = = w p U =iDU= =@ @ D R= xO Ok=i q=@ =} =Q < W= = w |t x_Lqt xm Qw]u=ty | yxO=O O W u}= O}=@ u}=Q@=v@ "OvDU}v |v=tR O}vm xHwD Q} R " Q =D = | U Q N U = O x@ Q=m u}= | y ) m > "http://www.massey.ac.nz/~pscowper/ts/cbe.dat" > CBE <{ read.table(www, header = T) > Elec.ts <- ts(CBE, 3], start = 1958, freq = 12) > Beer.ts <- ts(CBE, 2], start = 1958, freq = 12) > Choc.ts <- ts(CBE, 1], start = 1958, freq = 12) > plot(cbind(Elec.ts, Beer.ts, Choc.ts)) " CU= q=@ = O 10000 14000 6000 150 6000 2000 Choc.ts 100 Beer.ts 200 2000 Elec.ts cbind(Elec.ts, Beer.ts, Choc.ts) 1960 1965 1970 1975 1980 1985 Time |v=tR 1. trend 2. seasonal variation Q | U OvJ V}=tv %21 pmW Q | y ) m |= H= 1990 pY=L wtv 21 Q=O |v=tR 5 = Q | y| U 3111 i C=Q}}eD w OvwQ |rY 3 CQB Q}O=kt '2 |rYi = =} ,v L= w |rm Cr=L ' u}@D = Q t Q QO w Q}}eD '1 OvwQ xmr@ OyO|t CUOx@ Q C= CU= |rYi Q}}eD p=U Qy C= O u} QDxO=U "Ov} wo OvwQ 'OvwW|tv Qy=_ |@ w=vD w |t 'OvwQ K=w u= D = |t Qy=_ R}v QO 'OR U w x xm |v=tR |= @ p t `}tHD =@ |rYi C=Q}}eD Q}F-=D wor= =yvD xv |v=tR =Q | U | wor= Q=QmD q=@ p=Ft QO CQ Y @ uOQw CUOx@ Q =Q Q sUQ | U =]N Q}O=kt l}D=tDU}U | U QO pYi 1 Q}}eD C= Q CU= |]N Vy=m w V}=Ri= 'OvwQ |= @ " Qy Q}O=kt xYqN "OwW|t s=Hv= aggregate() `@=D R= xO=iDU= =@ R QO Q=m u}= "OQ@ u}@ R= xvq=U Q=t x@ xv=y=t = |t u}at =yxO=O R= l} Qy |=Q@ "OR U pYi cycle() `@=D w OwW|t XNWt boxplot() `@=D \UwD pYi =Q > data(AirPassengers) > AP <{ AirPassengers > layout(1:2) > plot(aggregate(AP)) > boxplot(AP ~ cycle(AP)) " Q |t x_Lqt xm Qw]u=ty w |t xOv=wN "O W RO ) m \UwD online = O Q | y ) m |= H= w x xv=y=t CQ Y @ pY=L =m}@ |Q wtv 31 Q=O = | yxO=O %p=Ft 2000 5000 aggregate(AP) OO o CU= q=@ 1950 1952 1954 1956 1958 1960 100 400 Time 1 =yv ts() ` = @ D R= |v=tR Q | U boxplot x@ =yv p}O@D `}tHD `@=D \UwD xvq=U \UwDt 2 3 O w x W Q |= @ w 4 6 7 `}tHD xvq=U u QO 8 9 Q V}=tv | U OvDU}v |v=tR Q |t x_Lqt "OO o 5 Q 10 | U freq 11 12 %31 pmW =yxO=O u}= "CU= =v Q ?w D xQwO w `w W unemploy Q}eD QDt=Q=B xm w |t 'O W =iDU= xO w |t u}at s}UkD Qorta "O W > www <{ "http://www.massey.ac.nz/~pscowper/ts/Maine.dat" > Maine.month <{ read.table(www, header = TRUE) 3. outliers = t s v w 1391 ' |vWwOv|wUwt 6 > Maine.month.ts <{ ts(unemploy, start = c(1996, 1), freq = 12) > Maine.annual.ts <{ aggregate(Maine.month.ts)/12 > layout(1:2) > plot(Maine.month.ts, ylab = "unemployed (%)") > plot(Maine.annual.ts, ylab = "unemployed (%)") CU= q=@ = O Q | y ) m |= H= pY=L wtv 41 Q=O 3 4 5 6 unemployed (%) " 1996 1998 2000 2002 2004 2006 4.5 3.5 unemployed (%) Time 1996 1998 2000 2002 2004 Time =yv \UwDt =m}@ w |Q Q | U V}=tv %41 pmW |v=tR |=y|QU 21 x} RHD 1 2 1 =ypOt =ypOt u}=Q@=v@ w |t xOy=Wt |rYi "O W O = |t Q} R " W @ Q}}eD =} C= w OvwQ =y|QU w x xm 'CU= 4 |atH pOt '|v=tR CQ Y @ Q R= |r}N = | U xO U O QO ' W x_Lqt ,q@k xm Qw]u=ty x} RHD l} "OvDUy |}=yxirw-t |=Q=O xt = mt + st + zt s xirw-t "CU= |rYi C=Q}}eD xOv}=tv t w OvwQ xv=Wv mt xi w r -t " CU= xOW xOy=Wt Q | U O = w u tR |t u=Wv " yO u xt =Q t u QO xm z =]N R}v t =Wv Q} R CQwYx@ xm 'CU= 5 |@ Q pOt l} ?U=vt pOt 'OwW Qy=_ OvwQ l} CQwYx@ |rYi C=Q}}eD Qo = w |t "O W xt = mt :st:zt 0 4. additive 5. multiplicative 0 0 xO=O |v=tR 7 Q |t p}O@D |atH pOt x@ |@ Q pOt 'Q}N= x]@=Q "OO o R= = Q | y| U pYi 1 sD} Q=or uDiQo =@ OwW|t x_Lqt xm Qw]u=ty yt = ln(xt ) = ln(mt ) + ln(st ) + ln(zt ) = mt + st + zt 0 0 0 R QO Qo = "Ovm|t x@ Q OQw @ l w Q =F QLDt u}ov=}t Q =iDU= =@ VwQ R= xO Q |t O=H}= \ @ t xO=O p t |= @ "OO o =yDv= | w |t s}UQD QO w O W 51 Q=O =Q |rYi Q}}eD C= wtv xU =@ pmW l} x=ov pmW |@ Q w |atH pOt OvwQ w w x Q} R CQ Y @ decompose() ` = R plot() ` = p w `= @ D ' Q}o Q=Qk 'O 2 2 1 =yxirw -t x} RHD @ D = O N=O j i = =F QO @ D Q O}rwD | y ) m QO 'q @ p t j @ pmW OOQo|t x_Lqt =Hm} |rYi C=Q}}eD w OvwQ Q=Owtv l} |wQ xQNq=@ w OwW|t p=@vO |@ Q pOt =yO)m "61 trend seasonal 14000 8000 12000 2000 1.10 2000 6000 1.00 0.94 random 1.06 0.90 1.00 observed Decomposition of multiplicative time series 1960 1965 1970 1975 1980 1985 1990 Time Q = xirw-t V}=tv | U | y %51 pmW 31 |oDU@ty |oDU@ty u}vJ O}=@ =yv p}rLD = | yxO=O j} Q] w x} RHD Q w Ovy=wN xDU@ty |r=wDt |= @ "O @ w |t h} QaD |oDU@ty `@=D \UwD |v=tR R= w O W = Q | y| U QO = Q}eDt | y = 'Cq L R= |oDU@ty Q=DN=U Q |t "OO o |r}N QO Q u}at "OO o Q O O =Wt OQw @ x W x y |vWwOv|wUwt 8 2000 4000 6000 8000 10000 14000 1391 ' 1960 1965 1970 1975 1980 1985 1990 Time |rYi Q}}eD C= w OvwQ V}=tv pmW %61 Tv=} Q}eDt u}ov=}t x@ xm CU= E (x) u Q =v CU= xat=H u}ov=}t `k=w w |t }= @ @ " w QO 'O W E (x )2 ] = QLv= `@ Qt u}ov=}t ; p L C i= w |t "O W xO=O =@ Q=w w xO=O u =Wv w |t xO=O CQ a "O W V}=tv R}v 2 = @ CU= h} QaD p@=k Q} R " E Q =@ xm |=} Q O}t= h L V}=tv R}v xm OwW|t xDN=vW |oDU@ty w 1 3 1 u}ov=}t h} QaD Tv=} Q=wwm w x Tv=} Q=wwm s=v x@ |twyit 'O}W=@ xDW=O CQ Y @ = x x Q}eD @ CU= m t x Tv=} Q=w 2 3 1 h} QaD (x y) Q}eD t wO Qo = (x y) = E (x x)(y y )] ; R= n O x@ xR= v= x wtv l} Qo = |= v CU= Q} R " "O Q}o|t w x CQ Y @ u O xR= v= =Q w -1 u} @ O w ?} Q u}= "Ovm|t u}at Oa)@ uwO@ "OQ= v O Hw (x y) (x y) Q}eD x]@=Q xm Owtv Cov(x y) = ; t wO Q OQw @ =Q u}@ |]N =@ R}t `k=w \ DQ= u= xvwtv Tv=} Q=wwm QO Tv=} Q=wwm w |t O}W=@ xDW=O u= D (xi yi) X (xi ; x)(yi ; y)=n w x CQ Y @ =Q (x y) Q}eD t wO u}@ =@ R}t |oDU@ty ?} Q \ DQ= u= = Q}eDt u}@ |]N \=@DQ= xm CU= |vat u}O@ OW=@ QiY ?} Q u}= Qo = | y w |t h} QaD Q} R "O W w x CQ Y @ (x y) = Q}eDt u}@ | y (x y) = E (x x)(y y )] = (xy) x y x y ; ; |va } Q "OQ=O Q= k +1 xat=H |oDU@ty |v=tR 9 Q |t x@U=Lt Q} R "OO o = Q | y| U pYi 1 w x xvwtv |oDU@ty ?} Q CQ Y @ Cov(x y) sd(x) sd(y) Cor(x y) = |oDU@tyOwN w Tv=} Q=wmwD= 3 3 1 `@=wD h} QaD w x |v=tR |QU l} u}ov=}t `@=D "OwW|t xDN=OQB u}ov=}t x@ =OD@= |v=tR |=y|QU |oDU@ty h} QaD |=Q@ CQ Y @ O = |t " W @ (t) = E (xt ) Q OQw @ w CU= 6 =DU}= u}ov=}t QO |v=tR Q =ov 'OW=@v | U x x = O = |t Q} R " W @ = u tR R= t |a@=D CU= Q} R w |a@=D |va} 'OW=@ C@=F u}ov=}t `@=D Qo = CU= Q} R w x " n X R= x wtv CQ Y @ u |= v xt =n i=1 w x CU= =DU}= u}ov=}t CQ Y @ ' QO xm |v=tR Q | U l} Tv=} Q=w `@=D 2 (t) = E (xt )2] ; w x x wtv OQwQ@ "OOQo|t CQ Y @ u |= v 2 C = x@ p}O@D @ F Var(x) = = = x =ov 'OW=@ =DU}= R}v Tv=} Q=w QO |v=tR |QU Qo = P CU= Q} R " (xt ; x) n;1 xDU@ty CU= umtt =yQ}eDt =t= "OvOw@ =DU}= Tv=} Q=w |oDU@ =yv 2(t) w 2 u}ov=}t QO =iD x@ \ki =yQ}eDt u}@ |oDU@ty xm CU= | ys o Cw " Ov} wo 7 Q}N-=D xm O}Owtv x_Lqt swO =Q x@DQt Q Qo = "Ovt=v 9 |B=}B |oDU@ty =} w 8 |oDU@tyOwN =Q hrDNt |=yu=tR w x CQ Y @ =Q CU= k |v=tR =DU}= |v=tR | =yQ}eDt u}@ | U =Q = = | ys o O= w Q wvm =D | U u Q OvW=@ R}v | U " OaD "OW=@ xDW=O = Q}eDt l} |oDU@ty QO VO N @ |a@=D xm k |va} (acvf) Tv=} Q=wwmwD= `@=D u=wD|t x=ov 'OW=@ swO x@DQt |=DU}= |v=tR R= wtv u=}@ Q} R "O k = E (xt )(xt+k )] ; `@=D "CU= E (xt ) = E (xt+k ) = |va ; CU}v u=tR x@ xDU@=w u}ov=}t =Q} R } ' w |t h} QaD Q} R "O W w x CQ Y @ k Q} O = = = (acf) |oDU@t OQ= v u tR N-D @ x@ |oDU@ k `@=D w yO N k = k2 O = |t " W @ 6. stationary 7. lag 0 = 2 Q = }R ' 8. Autocorrelation CU= 0 = 1 x m CiQo xH}Dv 9. Serial correlation w |t q=@ h} QaD u= D =iDU= =@ R= xO 1391 ' |vWwOv|wUwt 10 1331 yOwN x@U=Lt |oDU@t O =Wt CiH x y n 1 ; w |t "OW=@ xDUUo |v=tR Q u= D x1 x2 l} | U xn n O}v O =Wt x y Q wvm = m Z i u |va} (x1 x2 ) (x2 x3 ) Q Z i swO Q}eDt wva x@ u= O =Wt u}twO =Q x y Q}eDt w pw= (xn 1 xn) ; u= wva x@ Qy GwR O =Wt u}rw= Qo = "CN=U CU= Q} R QO =Q x y w " nP ;1 ; r1 = s t=1 nP ;1 ; xt x(1) t=1 Ovt=v " ; O =Wt u}@ |oDU@tyOwN ?} Q C= y ; w |t nP ;1 t=1 k Q} = = N-D @ =Q rk = t=1 t=1 R= =Q |v=tR Q = q]= | U C a R= |r}N ; = = w n P w ; t R= @ y W @ nQ @ u QO m k=w QO m i m xR= v= @ o= (xt ; x)2 w |t j} Q] u}ty x@ "CU= u= D Q n P x = n1 t=1 xt u QO xm k = 0 1 2 2 u}= nP ;1 xt x1 = n 1 1 xt x t=2 t=1 x Q}eD u} |oDU@t ` x r1 O = R | = O x n Q (xt ; x) (xt+1 ; x) (xt ; x) CQ Y 2 | yu tR QO (xt ; x) (xt+k ; x) n P n P =iDU= Q} R pwtQi |oDU@tyOwN ?} Q nP ;k ; xO t=1 wtv x@U=Lt xt+1 x(2) x2 = n 1 1 CU= hrDNt "O W "O t=1 CU= =Q u w " r1 = ; ;1 ; 2 nP x@ |oDU@ty ?} Q 'O}vm CQ Y xt x(1) xt+1 x(2) ; =Q Q x@U=Lt QO = } R "O m = rk O =@ k > n4 Q =Q y =kt }O } v Q wtat |= @ ,q O}yO|t CUO " w |t xDiQo Q_v "O W 2 QO p n Q= Okt 5% w r |vat K]U =@ k uO @ Q=O |= xrY=i Q 2331 10 Q=ov|oDU@ty w |t "O W Q =iDU= =ypw] QwLt xO k ?U Q = Q r wLt k L @ yZ a Q Q=O wtv R= ' |v=tR = Q | y| U Q}UiD Q OQw @ |= @ w Q}@aD Q |= @ wLt "CU= Oa)@ uwO@ OQ=O Q=Qk |wQ |oDU@tyOwN Q}O=kt xm =yZQa QwLt "Ovt=v Q=ov|oDU@ty =Q Q=Owtv u}= 10. correlogram |v=tR 11 Q}oxvwtv |v=tR xrY=i x@ |oDU@ OyO|t u=Wv "OQ=O | =F p t u= wvax@ w |t "O W xO R =iDU= lag.plot() ` = QO @ D R= sy x@ C@Uv hrDNt = =Q W OO o N-D Q U D t J D | yxO=O ' pYi 1 =yQ}N-=D xm =ypw] = Q}N-=D s}UQD Q | y > lag.plot(LakeHuron, lag=4, labels=F, do.lines=F, diag.col = "red") C lag=4 Q pm Q | s} Q Q} = =y = LakeHuron = |= @ "71 Q | y| U U= w = |= @ =F u J 'q @ p t QO LakeHuron 576 577 578 579 580 581 582 LakeHuron 576 577 578 579 580 581 582 LakeHuron lag 3 lag 4 576 577 578 579 580 581 582 Q}N-=D CU= Q} R " w x CQ Y @ u 576 577 578 579 580 581 582 lag 2 LakeHuron lag 1 |rm pmW w |t "O W = | yQ=O =iDU= xO wtv %71 pmW acf() ` = R @ D R= QO Q =ov|oDU@ty s}UQD w rk x@ =Lt U acf(x, lag.max=NULL, type=c("correlation","covariance","partial"), plot=TRUE) u QO x w Q} = Oa lag.max Q | x@ =L 10log(N) = QD = xD type CU= =yxO=O " x]@=Q | R= xm CU= Q V}B Z i O = |t " W @ "correlation" Q R |=Q=O 10 P =v@t | = w 'OO o h L u t oQ Q = w P 'OO o h L u t oQ QO u sD} Q=or u}= Qo = "CU= Q_v = x wtv w y v u}= Qo = "Ovm|t u}at =Q O xR= v= acf ` = N-D O= OQ t Nx m 'OO o w CU= @ D ` v w xm t y " U Q Q=O @ % D % t m =Q m R= |= WQ % CU= `@=D u}= Q V}B Z i Q |t sUQ Q=ov|oDU@ty Q=Owtv CQwY u}= QO w CU= TRUE ZQiV}B |=Q=O |k]vt u=twoQ u}= %plot "OO o w |t "O W R= = A J =yQ}N-=D =yv x@ |UQDUO k=0 Q o= " Q |=R= x@ acf Q }O =kt Q |t xQ}NP |= @ w OO o w |tv sUQ xOW xDio wtv 'OW=@ w O W acf(x)$acf Q=O w x Q CQ Y @ |Q=O @ QO FALSE = w u}= Qo = u t oQ Q}O=kt u}= xm O}W=@ xDW=O xHwD CU= acf$acfk+1] CQwYx@ q=@ Q=OQ@ u}=Q@=v@ "OwW|t xO=iDU= Q=OQ@ T}Ov= u=wva x@ Q}N-=D u=tR " O}}=tv x_Lqt " =Q acf$acf1] Ok acf ` = =F wv x CU= l} Q@=Q@ Q} R = O | y ) m Q= @ D p t u= O = t ' W @ wvm = a @ u 1391 ' |vWwOv|wUwt 12 > www <{ "http://www.massey.ac.nz/~pscowper/ts/wave.dat" > wave.dat <{ read.table (www, header=T) > par(mfrow=c(2,1), mar=c(2,4,2,2)) > plot(ts(waveht), ylab = 'wave height (mm)') > acf(waveht, main="") CU= q=@ = O Q | y ) m |= H= pY=L wtv 81 Q=O −500 0 wave height (mm) 500 " 100 200 300 400 −0.5 0.0 ACF 0.5 1.0 0 0 5 =ov|oDU@ty u Q 10 w 15 |v=tR Q | U w |t x@U=Lt Q} R "O W > acf(waveht)$acf2] 1] 0.4702564 w |t x@U=Lt Q} R "O W w x O = CQ Y @ ' W @ 20 V}=tv 25 %81 pmW CQ Y @ k=1 k=1 Tv=} Q=wwmwD= x@U=Lt Qw_vt Qo = ,=OOHt w x QO acf QO Q= Okt p@k p=Ft xt=O= QO > acf(waveht, type = c("covariance"))$acf2] 1] 33328.39 r O N xrY=i xv=Wv xm OvQ=O OwHw =y k u}}=B O = |t =yxvwtv " W @ r xR= v= u}@ R= k Q}O=kt Qo = "O x@ O}=@ =Hv}= xD@r= "O m OQ =Q uwQO Q}O=kt xm \N wO QO xrY=i Q}o|t Q=Qk Q xO = u QO xm 'CU= =iDU= OQwt %5 K]U u}J]N w q @ QO QO Q | U Q@=Q@ %5 2 p w x \N CQ Y @ N w } QiY CU= |vFDUt xOa=k u}= u swO " O}vm|t x_Lqt xm Qw]u=ty |vat K]U =@ uO @ Q=O |oDU@ty u}}aD |=Q@ k = 0 |va wO Q u R= xm CU= R= =D = |Q N U w |t x=ov 'Ot Z i u= D OvDUy u=v}t]= w Q}@ Q}N= uw r0 = 1 x u}= =D wO ' yxO=O O= m pw= " rk Q =kt }O w]N \ CW=O xHwD xDmv xU Q}N-=D 40 |=Q@ ,qFt %5 K]U QO xm u swU "OvQ=Ov |Q=O|vat Cw=iD QiY =@ =t= OvW=@v QiY ,=k}kO CU= umtt " Q O}vmv = |Qw=O u T U= =ov|oDU@ty O QO " yO Q@ |t O}v=Ov =]N pwtWt w =Q =Wv xDUy Vy=m l} u r0 < RH@ w x Q}@ =D uO i= uw CQ Y @ Q =ov|oDU@ty = OaD =@ ?U=vDt w QO =Q O N =yxO=O OvwQ ,qwtat |v=tR 13 w CU= Q x@=Wt Q}O=kt | U QO |W=v xm C@Ft R= R Q}O=kt O}vm|t x_Lqt Q OvDUy syx@ l}ORv " 1 acf(AirPassengers) pmW 91 w nQ @ = | y| U = | yxO=O = =Q " pYi = | yu tR QO −0.2 0.0 0.2 0.4 ACF 0.6 0.8 1.0 Series AirPassengers 0.0 0.5 1.0 1.5 Lag AirPassengers = Q xvq=U QO ' yxO=O | U =v = | yxO=O Q =ov|oDU@ty w |t Qy=_ Q=ov|oDU@ty ?w D "O W %91 pmW O = xDW=O OwHw R}v |rYi |wQ ' W @ Q}}eD Qo = C= x]@=Q xm CU= p=Um} Q}N-=D QO |oDU@ty Q=Okt QFm =OL "OwW|t x_Lqt ?w=vD u}ty =@ R}v u Q=ov|oDU@ty =D w Tmar=@ "OyO|t u=Wv Q iQ u J =@ |ivt x]@=Q xm Ov=xOW =OH sy " xm |rYi P h L Ov=xOW =OH sy =Q = R= p U 0.5 = x t = R= x t 6 12 \ Q}}eD w OvwQ P h L R= TB |v=tR Q Q |t s}UQD 111 pmW | U QO =ov|oDU@ty QO Q pkDUt July D D w w x U= = W U m y QO R= |rY= = w 101 }= t =iDU= =@ Q} R O)m xO pmW m QO Q TB Q=}at =}at QLv= xm O}vm|t x_Lqt h= QLv= h= w CU= 41 O Q O |= @ " vQ=O 111 P vwQ h L R= w =Hv= | TB 'Q=}at h= O h y CU= "Ov=xOW OQwQ@ Q | U pmW TBU QLv= "CU= Q |t "OO o =ov|oDU@ty QO Q w@v QFw-t ,qt=m xO QDW}@ |UQQ@ Qo = "Ovm|t 'O W s sy QO " |iO=YD xirw-t OyO|t u=Wv Q}}eD C= |oDU@tyOwN X}NWD Q=ov|oDU@ty |rY= = xirw-t x@ x} RHD =Q} R OUQ|tv CUQO Q_v x@ Q}@aD u}= "CU= | yxO=O | U Q R= u}@ |]N C@Ft xm q=@ Q}O=kt p=Ft CQ Y @ =Q x t xOR=wO ' y Q}}eD K}LYD C= =DU@=D MQ u > data(AirPassengers) > AP <{ AirPassengers > AP.decom <{ decompose(AP, "multiplicative") > plot(ts(AP.decom$random7:138])) > acf(AP.decom$random7:138]) |rY Q}}e K}LY C pm | wv}U = rk | Q} x i C= GwR w x Q}O=kt 'CU= |Uwv}U ,=@} QkD |rYi OvwQ xirw-t w K}LYD |rYi C=Q}}eD decompose() `@=D R= "OO o (xt xt+12 ) CQ Y @ CU= u=DUtR lJwm Q}O=kt p=@vO x@ OyO|t C= w xm U D Q OQw @ 109 Q Q June = @= @ D |vWwOv|wUwt 14 0.90 0.95 1.00 ts(AP.decom$random[7:138]) 1.05 1.10 1391 ' 0 20 40 60 80 100 120 Time AirPassengers | =YD xirw-t iO O}vm xHwD Q} R " = O x@ =yQ=}at | y ) m > AP <{ AirPassengers > AP.decom <{ decompose(AP, "multiplicative") > sd(AP7:138]) 1] 109.4187 > sd(AP7:138] - AP.decom$trend7:138]) 1] 41.11491 > sd(AP.decom$random7:138]) 1] 0.0333884 %101 pmW QLv= x@U=Lt h= Q CU= |= @ " 0.03 Q Q @= @ |rYi |v=tR 15 0.4 −0.2 0.0 0.2 ACF 0.6 0.8 1.0 Series AP.decom$random[7:138] 0 5 10 15 20 Lag AirPassengers | =YD xirw-t Q=ov|oDU@ty iO %111 pmW = Q | y| U 1 pYi swO pYi x}=B |iO=YD |=ypOt |}=yQorta ,=vt "OwW|t EL@ 'OQ=O |Oa@ pwYi QO |O=} R OQ@ Q=m xm |iO=YD |=ypOt R= |=xQ=B pYi u}= QO O QD?U=vt X}NWD p t Q |t QDK=w "OO o w Q OO R |= @ | } H Q= @= w O@=}|t Ovvm|t =iDU= |r}N =yv xO QDW}@ \U@ R}v xDWPo | = EL@ | y R= |v=tR = Q | y| U = u}vJty R= |=xQ B xm Q |t |iQat OO o Q}o|t Q=Qk |UQQ@ 1 O}iU xiwv Ovm|t u=}@ xt |va t = = O =t}k=@ } yx v O O =Wt = u tR QO =Q p t w x y Q w | U CQ Y u}= Q | yxO=O | U CU= QO " Zw u}@ Cw =iD R= y |W=v Qit pOt \UwD ^t |va} | =]N O O l} 'p t 1 1 2 O =t}k=@ QO x v Q Q}O=kt u x W OQw @ w CU= Q} R " xt = yt y^t ; 1. White noise 16 OQ t 12 xtOkt " w "O yt Q | U w x CQ Y @ x}=B |iO=YD 17 Tmavt Q=ov|oDU@ty QO |rYi OvW=@ xDU@ty O}=@v =yxOv=t}k=@ Q}}eD =} C= Q w OvwQ Ovv=t |v=tR Q Q |t Q} R h} QaD ?Hwt xO}= u}= "OyO u=Wv "OO o 2 = Q = w xm OW xO}O u}vJty wn xH}Dv p w |t u= D w |t wor= `wv I}y O}=@v =yv Q=ov|oDU@ty =Pr | w |t x=ov 'Ovm u= D w : t = 1 2 n = Q}eDt Qo = 'Ov} wo 2 (DWN) xDUUo O}iU xiwv =Q f t | y qkDU= C}Y=N |w 2 T = OvW=@ R= " v } Q=w w Q}B p=tQv p=tDL= |r=oJ `@=D QiY u}ov=}t =@ u=Um} `} RwD g |v=tR |QU pkDUt sy |=Q=O w CU= " m m W=O Uw o U |a@ O \UwD xOW =Q p t = x}@W Q |R U w |t | U "O W =iDU= =yxO=O 3 |R=Ux}@W xO Q R}=tDt xOW xOy=Wt "OO o Q w |t |= @ u R= u= D rnorm(100) w O}=tv O=H}= xOv} =F Q O = |t p t |= @ " @ } Ovm O=H}= " =Q Q |= @ =Q = = |}=yw} Q=vU Ov=wD|t R |@ wN@ Q=m u}= u t U OvDUy = | yxO=O R= i v | U 3 1 2 Q xDi=} VR= @ p t O =D = Q =F wtv QO "O Q CU= =iDU= O xO =Um} `} RwD OQ= v U= p t v u |= @ |=Q=O " O}it Ov}Qi = QDt=Q=B p t | y = Qy QO xm |vat u}O@ 'OW=@ u=Um} = |}=D100 hrDNt | y = Q | y= H= = x}@W |R U =@ OwW P h L " Q = Qy |= H= Q @ `@=D u}= Qo = =t= CU= 12 Q `w W pmW q=@ 2 T = v } Q=w w =v}t]= = xR @ = O x@ uwvm = = O xH}Dv Q w |t v= D | y ) m set.seed() ` = 100 x = Q Q u |= @ =Um} OOa Q=ov|oDU@ty w swO Tv=} Q=wwmwD= `@=D |=Q=O 'OW=@ u O}vm xHwD Q} R u Q |R U 100 O Q |t O=H}= | y ) m |= H= = | yxO=O xm pkDUt Q}eDt x]kv xm CU= "OO o O = x}@W | > set.seed(1) > w <{ rnorm(100) > plot.ts(w, type = "l") Q @ Q =D Ov} wo R}v 4 |oDN=U 'p t |= @ " i o x}@W = = R= Cor(wi wj ) = 0 i 6= j x C Q wt N (0 2) x C | = O}i x w Q R QO |R U C kw= w 2 1 2 = Q}eDt Qo = "CU= R= y QO "O W h} QaD w1 w2 pYi = xirw-t xm OW x_Lqt p@k pYi | y| U ,a v |YNWt =Q O | U | y =t= 'OvDUy xDU@ty |v=tR | U = | yp t @ D t v @ |= H= Q |t pY=L "OO o x@DQt =iDt Cw 4 1 2 X=wN w QiY u}ov=}t |=Q=O w xDU@ty=v w f t g CQwY x@ |iO=YD Q}eDt Qo = 8 > < 2 (k) = > :0 CU= Q} R " k=0 k=0 6 Q = }R 2. Discrete white noise Cov(wt wt+k ) = E (wt ; )(wt+k ; )] 3. Simulation 4. Synthetic |vWwOv|wUwt 18 −2 −1 0 w 1 2 1391 ' 0 20 40 60 80 100 Time O}iU xiwv |v=tR Q V}=tv | U %12 pmW = E (wt) = E (wt+k ) = 0 w |t xH}Dv x=ov 'CU= 8 > < ( 2) "O W E wt = a2 E (wt wt+k ) = E (wt)E (wt+k ) = > :0 0 k=0 k=0 %R= 8 > <1 x@ pta QO =t= OvW=@ QiY Q@=Q@ O}=@ |vat u}O@ u}= w 6 OvwW|t `k=w u=v}t]= Q}@ 'Q}N-=D 20 w %5 O k=0 u t uw w uO @ Q=O :0 |=R= x@ xOW 6 CUDQ=@a |oDU@tyOwN `@=D 6 = x}@W O}iU xiwv |R U = | yxO=O r = pN=O =t= 'CU}v QiY ,=k}kO =y k Q}O=kt xR @ |oDU@tyOwN `@=D Q}oxvwtv | r O}vm xHwD Q} R p=Ft x@ uwvm = "CU= p=mW= q@ R}v =y k OQ=O O Hw " U= @ D QO r= "OQ=O @ D |oORuwQ}@ l} Ovm|t x@U=Lt }= " | 7 Q} Q_v O}vm xHwD Q} R p=Ft x@ " Q}}eD Cra C= |vat K]U x@ xHwD =@ |DL "OvQ=Ov QiY =@ |Q=O|vat Cw=iD =yv xm CU= " > set.seed(2) > acf(rnorm(100)) w |a = R xD@ C ARMAacf() ` = u w k=0 k=0 k = cck = > 0 w u J = N-D QO xm 'CU= w x CQ Y @ =Q "O > wn <{ ARMAacf(ar=0, ma=0, lag.max=20) wtv s}UQD 22 pmW q=@ = O w l} R= OQ t Q | y ) m |= H= xH}Dv r O}iU xiwv l} k |oDU@tyOwN `@=D xm plot() ` = = w |t @ D @ u= D =Q `@=D u}= pY=L x}=B |iO=YD 19 = O 2 pYi | y ) m |= H= xH}Dv | yp t 0.4 −0.2 0.0 0.2 ACF 0.6 0.8 1.0 Series rnorm(100) 0 5 10 15 20 Lag O}iU xiwv |oDU@tyOwN `@=D V}=tv > plot(wn, type='h') QiY Q@=Q@ Q}O=kt =yQ}N-=D Q}=U Q |= @ w CU= l} Q@=Q@ k=0 QO %22 pmW xm 'CU= pmW q=@ 32 = O Q CU= " 5 |iO=YD uORs=o 1 2 2 xtOkt Q}o =Qi pOt | Q |DL ,qwtat "CU= |iO=YD R= u VR= @ = O Q |@U=vt | y vwQ |= @ Q =@ = |iO=YD VR= @ , r e h} QaD Q CU= |iO=YD xt = uORs o f g x=ov "CU= |v=tR Q | U l} xt f = uORs o ARIMA CU= QD?U=vt " % o= 22 g w u J 2 2 2 xm O}vm Q Z i xt = xt 1 + wt ; =@ u}vJty = xrO=at w q @ QO xt 1 = x t 2 + w t ; x ; 1 ; |v} Ro}=H =@ "CU= O}iU xiwv w |t xH}Dv 6 wQUB |v} Ro}=H % m O W 5. Random walk VwQ xt = wt + wt 1 + wt 2 + 6. Back substitution ; ; u}= xt=O= w Q wt x xt 3 |v Ro = | U f |r@k QO g u QO ; } m } H |vWwOv|wUwt 20 0.0 0.2 0.4 wn 0.6 0.8 1.0 1391 ' 5 10 15 20 Index O}iU xiwv | Q_v |oDU@tyOwN `@=D V}=tv P w |t %= r "O W Q `w W t=1 %32 = u tR R= w xt = w1 + w2 + pmW CU}v C}=yv|@ w Q j i | U pta QO + wt w x Qorta l} u=wD|t u}=Q@=v@ "OOQo|t p=ta= R}v xO}J}B |v=tR |=y|QU |=ypOt |=Q@ wQUB |v} Ro}=H CQ Y @ wtv h} QaD Q} R "O 7 wQUB p=kDv= CU= Q} R " B (xt ) = xt 3 2 2 Qorta w x xm CQ Y @ B Qort a 1 ; =@ Q O xDio Qorta Qo = "Ov} wo R}v Q}N-=D Qorta u x@ OQ=wt R= |=xQ=B QO xm 'OwW|t xO}t=v wQUB p=kDv= Qorta , D t x W =ov %x B n(xt ) = xt Q QmD = wvm = 'OO o Q= n ; w |t xDWwv Qorta u}= =@ |iO=YD "O W xt = B (xt ) + wt (1 B )xt = wt xt = (1 B ) 1 wt = (1 + B + B 2 + )wt xt = wt + wt 1 + wt 2 + ) ; ) ) 7. Backward shift operator ; ; ; ; uORs o u x}=B |iO=YD 21 |iO=YD " CU= Q} R w x CQ Y @ x = 0 x @ k (t) = Cov(xt xt+k ) = Cov CU= Q} R " l}ORv R= t X i=1 uORs=o swO xHwD =@ |iO=YD wi t+k X j =1 ! wj = x@DQt = X=wN 4 2 2 = Ov}Qi i=j swO w x |oDU@tyOwN ?} Q uwvm = "CU= =DU}==v Ov}Qi u}=Q@=v@ 'CU= u=tR R= Ov)m |r}N }= @ @ " w x U= J m |= L t w Oy=wN C@Ft Q}O=kt CQ Y @ w O @ @ k CQ Y @ |=Q=O @ |iO=YD v Q= = Q w X= N |a@=D Tv=} Q=wwm 2 1 p k (t) = p Cov(xt xt+k ) = p 2 t = Var(xt ) Var(xt+k ) t (t + k)2 1 + k=t k Ok u Q =v C QDm w x_ q p = w x t x C@U k Ok = Qy t x@DQt Cov(wi wj ) CQ Y @ Q= pYi 2 uORs o X O | yp t t p L R = t @ nQ @ | y =ov|oDU@ty uORs o |= @ Q w Q |= @ CU= l} x@ O = |t Vy=m l} Q=Okt " @ } 8 p=iD x 5 2 2 Qorta xm OW=@ |iO=YD uORs=o f t g |QU Qo = p=Ft |=Q@ "Ovm p}O@D =DU}= |QU x@ =Q =DU}==v |QU Ov=wD|t Qorta u}= xt xt 1 = wt ; ; w x CQ Y @ u x x]@=Q xm Ovm|t O=H}= =Q O}iU xiwv |QU f t g pw= x@DQt p=iD 'CU= =DU}==v CU= " w |t h} QaD Q} R "O W xt = xt xt r Q ; =} QUB p=kDv= Qorta ?UL Q@ Ov=wD|t "OO o u @ w r 1 u}=Q@=v@ "CU= r xt = (1 B )xt x CU= Q} R n |va} p=iD Qorta ; " r w x CQ Y @ r ; m O}W=@ xDW=O xHwD w x p=iD Qorta QDq=@ CQ Y @ = x@DQt | y = (1 ; B )n |R=Ux}@W 6 2 2 w |t Qy=_ =yQ=Owtv QO pOt |rY= C=}YwYN w CU= O}it |v=tR |QU l} xar=]t |=Q@ |R=Ux}@W ,=@r=e "O W wkr=@ u=mt= l} x wvax@ Ov=wD|t pOt u= =Wv OwN 'O=O u R= =Q x@=Wt =} wYN |N} Q=D C Y xO=O xm |Dkw u}=Q@=v@ Q |iQat "OO o " > set.seed(2) > x <{ w <{ rnorm(1000) 8. Dierence operator Ovm = x}@W |R U =Q |iO=YD = l} Ov=wD|t Q} R uORs o Q u |= @ = O | y ) m 1391 ' |vWwOv|wUwt 22 > for (t in 2:1000) xt] <{ xt - 1] + wt] > plot(x, type = "l") = for xkr Q| | Ok x x =vt uORs o xkrL L "OO o t yOQ= xm Owtv O=H}= |}=yO)m =@ R= u QO @ , t =Q w |iO=YD OyO|t C@Uv = = x}@W uORs o |R U wx O}iU xiwv @ =Q Q wDUO u}rw= | U Q w |t xD@r= "Ovm|t O=H}= u= D =Q |iO=YD O = OWv " W @ x =iDU= xO > set.seed(2) # so you can reproduce the results > v <{ rnorm(1000) # v contains 1000 iid N(0,1) variates > x <{ cumsum(v) # x is a random walk > plot(x, type = "l") Q =ov|oDU@ty CUOx@ uOQw Q CU= xOW |= @ " =Wv xO=O u 42 pmW O =H}= QO x W O Q | U |wQ Qy@ 0 20 x 40 60 | U Q 0 200 400 600 800 1000 Index |iO=YD = V}=tv uORs o %42 pmW w |t xOy=Wt 52 pmW QO xH}Dv TBU "OOQo|t =QH= Q} R QwDUO 'p@k |=yxt=vQ@ xt=O= QO 'xOW |R=Ux}@W "O W > acf(x) Q |t O}iU xiwv "OO o p=iD Qorta p=ta= ' 62 pmW QO = Q | yxO=O | U x@ p}O@D p=iD l} Q CU= jO=Y R}v xOW |= @ " xH}Dv TBU = x}@W |R U w |t =QH= Q} R QwDUO 'Q}N= "O W QO |iO=YD Q = O uORs o ' W w x_Lqt ,q@k xm Qw]u=ty O xDio ?r]t xm O}O O}=@ uwvm = | U OQ t QO x W = x = Q xt=O= | y t v @ CU= OwHwt QO " R di() ` = QO @ D w |t xOy=Wt "O W > acf(di(x)) u =v}t]= = xR @ R= |oORuwQ}@ w w |tv x_Lqt Q=ov|oDU@ty OQ t wO "O W Q |YNWt |= @ wor= 'Q}N= pmW | QO = x}@W |QU CiQ|t Q=_Dv= xm Qw]uty u}=Q@=v@ "CU}v =vDa= p@=k %5 uOw@ Q=O|vat K]U QO xm OQ=O OwHw |R U x}=B |iO=YD 23 = O | yp t pYi 2 0.0 0.2 0.4 ACF 0.6 0.8 1.0 Series x 0 5 10 15 20 25 30 Lag |iO=YD = =ov|oDU@tyOwN V}=tv %52 uORs o Q Ovm|t " pmW Q}B |iO=YD |w = Ov}Qi l} uORs o w}UQoQwD= AR(p) =YDN= x@ Q xt = 1 xt 1 + 2xt 2 + ; 1 3 2 =kDv= Qorta ?UL Q@ Q}N= xrO=at Qo = "OvDUy p = 0 = 6 D t w}UQoQwD= Ov}Qi O = QDt=Q=B @ p t | y i w O}iU xiwv w Oy=wN Q} R ; ; ; ; w}UQoQwD= u x@ ?@U u}ty x@ w 1 = 1 CU= xDWPo u QO = xm CU= = | yu tR QO wt f w x g u QO Q =} QUB AR(1) x = X N Cr=L |iO=YD x =y x@ C@Uv t uw}UQoQ `k=w =mv x@ uwvm = C = uORs o O u}= QO p t Ov} wo " = CU= Q@=Q@ % @ x^t = 1xt 1 + 2xt 2 + ; ; xm pB p)xt = wt O}vm xHwD Q} R O = |t Q | U CQ Y @ 'OO o u @ w " " W @ |v=tR g ; "O @ p(B )xt = (1 1B 2B 2 xt =Q f + pxt p + wt ; p p x@ Q O x W 32 |=ypOt h} QaD Qo = 'Ov} wo x R= + t pxt ; t = Q u tR QO OQw @ 1391 ' |vWwOv|wUwt 24 0.0 0.2 0.4 ACF 0.6 0.8 1.0 Series diff(x) 0 5 10 15 20 25 30 Lag p=iD p=ta= =@ |iO=YD = =ov|oDU@tyOwN V}=tv uORs o Q Q |t "OO o Q =]N OQw @ =a@ Qt pk=OL C w}UQoQwD= O Qo = "OW=@ \rDNt =} Q k = Ov}Qi uORs o u}}aD w |k}kL = xW} Q | y CU= =DU}= Ov}Qi x=ov QO " Q OL=w 'OO o R= Q Q} R p=Ft Q=yJ x@ uwvm = "CU= =DU}==v Ov}Qi ; 1 2 B=0x QUB p=kDv= Qorta w w O W t xrtHOvJ u}= xW} Q "OwW|t xH}Dv QDoQR@ R= w w = QDt=Q=B ; m m 2 3 2 |}=DU}= p(B ) = 0 x =Q J | y }Q s ; } i w x CQ Y @ } }= v w AR(1) CU= QDoQR@ OL=w R= } t ; " R= |m} =Q} R 'CU= =DU}==v t ; } ; ; U= " |va} U= | y L=w R= 1 + 41 B 2 = 0 } Q |=Q=O oQ @ ; rO t ; w ; |= t Q k = } R "OO o xt = B p ; t x } 1 4 t;2 }= v + wt v= H @ p t 3 a R= xO J "O W U Q= w x CQ Y @ }= t L CQ Y @ ; ; = xW} Q =Q} R 'CU= =DU}= | y ; } O x = 21 xt 1 + 12 xt 2 + wt w x AR(2) O 1 1)(B + 2)xt = wt |va 12 (B 2 + B 2)xt = wt QU =kD Qort =iD = 2 (B C B = 1 2 = xW (B ) = 21 (B 1)(B + 2) xrt Ov w | xH}D C O QD R B = 2 jr] O Q Q | | =DU = ?@ B = 1 Ok \k CU= OL=w =yxW} Q " D p t 1 rO ; iO p t 2 ; UO @ t xm CU= CQ Y @ ; } m =at rO D ; U= H D ; ; CU= | y x = xt 1 41 xt 2 + wt w x AR(2) O 1 2)2 xt = wt |va 41 (B 2 4B + 4)xt = wt x =a 4 (B B = 2 x O | C x (B ) = 14 (B 2)2 x =a p = =iDU= =@ =Q} R "CU= =DU}= t |= O = |t OL=w H x = 12 xt 1 + wt =at xW} Q =Q} R 'CU= =DU}= t rO R= xO " W @ |}=DU}==v |= " w x@ pOt B ) xrt Ov = xW =t jr] | B = 1 x C = 1 B | =Y O}v x w AR Ov Q | =DU = | =DU QDW}@ p ( " @= @ VwQ Ov=wD|t xm Ovt=v xYNWt xrO=at |=Q=O |= @ B=2QQ 1 QO pmW %62 U= @ t t AR(2) v i O p t 4 x}=B |iO=YD 25 2QQ = xW} Q @= @ y R= l} Qy jr]t QOk "OW=@|t i= p ; 1 w CU= \rDNt O O= a= xm OvDUy CU= OL=w " xrO=at O x W = xW} Q | y xDio `@=D =@ w |t xm u= D =yJ sQ w OQ=O O Hw w w polyroot() =F w s U OQ= t 'p t u= wvax@ = x@ |a@=D s v Q |UQQ@ "O m =Q R QO |= = 2 pYi B = 2i QDoQR@ xm OW=@|t R= xrtHOvJ =y|QU |}=DU}= O | yp t = xW} Q x@U=Lt | y wtv x@U=Lt w O Q |= @ xYNWt =Q w |t x@U=Lt "O W w =F %s U p t > polyroot(c(-2,1,1)) 1] 1-0i -2+0i %R= OvDQ=@a =yxW} Q jr]t QOk > Mod(polyroot(c(-2,1,1))) 1] 1 2 =yJ p=Ft %sQ > polyroot(c(1,0,1/4)) 1] 0+2i 0-2i %R= OvDQ=@a =yxW} Q jr]t QOk > Mod(polyroot(c(1,0,1/4))) 1] 2 2 AR(1) p t swO O " w x CU= Q} R CQ Y @ AR(1) O x@DQt O 3 3 2 X=wN O =Wt ,q@k xm Qw]u=ty p t ' W x y xt = xt 1 + wt ; xm =Wv O=O u w |t "OW=@|t u= D 2 T = v } Q=w w QiY u}ov=}t =@ O}iU xiwv wt f g u QO xm x = 0 k = k 2=(1 2) ; xm CWwv w |t u= D < 1 Ov Q j j } i |}=DU}= Q \ W w B Qort =iDU= =@ a R= xO (1 ; B )xt = wt wtv x@U=Lt "O xt = (1 B ) 1wt ; ; = wt + wt 1 + wt 2 + ; 2 ; = 1 X i wt i ; i=0 =Q xt w |t uwvm = u= D 1391 ' |vWwOv|wUwt 26 " 1 X E (xt ) = E ! i wt = i ; i=0 1 X O}vm xHwD u}ov=}t x@U=Lt x@ uwvm = iE (wt i) = 0 ; i=0 CU= Q} R KQW x@ Tv=} Q=wwmwD= ! " k = Cov(xt xt+k ) = Cov = 1 X i=0 X j =k +i = k 2 wt i i 1 X ; j =0 O}vm s}UkD Tv=} Q=w Q@ =Q ; X1 i=0 QDW}@ CaQU =@ QDmJwm | O |t 72 " } pmW QO 2i = k 2=(1 2) ; Ov}Qi 4 3 2 Q=ov|oDU@ty = t w Q |= @ (k 0) | y |iv ; Tv=} Q=wwmwD= xm CU= |i=m |oDU@tyOwN `@=D x@U=Lt k = k p}t QiY CtU x@ j ; ij Cov(wt i wt+k j ) AR(1) " j wt+k |=R= x@ Q=ov|oDU@ty u}=Q@=v@ "CU= C@Ft Q}O=kt Q =ov|oDU@ty |= @ Q j <1 j =F xt=O= wO p t u QO xm Ovm|t QO " > plot(0:10, rho(0:10, -0.7), type = "b", xlab="lag k") > rho <{ function(k, alpha) alpha^k > par(mfrow=c(2,1), mar=c(4,4,2,4)) > plot(0:10, rho(0:10, 0.7), type = "b", xlab="lag k", + ylab=expression(rk]), main=expression(alpha==0.7)) > plot(0:10, rho(0:10, -0.7), type = "b", xlab="lag k", + ylab=expression(rk]), main=expression(alpha==-0.7)) > abline(h=0, lty=2) 9 x x@ \ki t Qo = |DL 'OvDUy QiY hr=Nt =yQ}N-=D s=tD |} RH |oDU@tyOwN `@=D Q =y|oDU@tyOwN Q}O=kt |= @ k k Q} ' N= 5 3 2 xrO=at j@=]t x =y|oDU@ty QF= xm CU= |oDU@ty R= |awv ' Q}N-=D QO |} RH |oDU@tyOwN `@=D "OW=@ xDW=O |oDU@ t;1 w Oy=wN QiY "O @ CU= ' AR(k) k>1 s O xDi=} p t =tD AR(1) | R ? Q u} k = Q |= @ Q VR= @ } H } t= @ |oDU@tyOwN `@=D p=Ft |oDU@tyOwN `@=D Q=ov|oDU@ty u}=Q@=v@ "CU= QiY w x@U=Lt Q |= @ pacf() = x@ |a@=D s v R Q}o Q=Qk QO "O k Q} = QQ k>p Q@=Q@ N-D QO @= @ =iDU= xO w OQ t Q P QDmJwm Q}N-=D =@ |} RH |oDU@tyOwN `@=D '|rm Cr=L O w | AR Ov Q |=R= v= D QO x@ k ?}=Q AR(p) Ov}Qi QO |va} t w "OQ=O O Hw 9. Partial autocorrelation function Q |= @ "OO o h L } i x@DQt u}}aD Q |} RH |= @ |} RH |oDU@tyOwN `@=D s}UQD x}=B |iO=YD 27 = O | yp t 2 pYi 0.0 0.4 rk 0.8 α = 0.7 0 2 4 6 8 10 8 10 lag k 0.0 −0.5 rk 0.5 1.0 α = − 0.7 0 2 4 6 lag k = 0:7 ;0:7 Q |= @ AR(1) Ov Q =ov|oDU@ty V}=tv } i Q %72 pmW |R=Ux}@W QO |} RH |oDU@tyOwN w |oDU@tyOwN `@=wD |oDU@tyOwN Q=ov|oDU@ty QO k>1Q =kt }O w Ov}Qi O = x}@W Q} R w x W |R U w x CQ Y @ R QO 6 3 2 AR(1) O p t Q O}vm|t x_Lqt xm Qw]u=ty "OOQo|t s}UQD 82 pmW |= @ O w |vat |oDU@ty '|} RH "OQ= v O Hw |Q=O xOW |R=Ux}@W |=yxO=O Q@ x.ar Q Q R= xO =iDU= =@ | U |= @ u w}UQoQwD= pOt 'Q} R |=yO)m u xDi=} VR=Q@ |=ypOt 7 3 2 xDi=} VR=Q@ |=ypOt 8 3 2 O = |t VR=Q@ =yxO=O Q@ ar() `@=D \UwD R QO QO " @ } 10 |@v=Ht Tv=} Q=w xm 'O@=}|t Q O VR= @ x W xO=O QDt=Q=B w %95 u=v}t]= w |t "O W > set.seed(1) > x <{ w <{ rnorm(100) > for (t in 2:100) xt] <- 0.7 xt - 1] + wt] > x.ar <{ ar(x, method = "mle") > x.ar$order pOt x@DQ pOt QDt=Q=B 1] 1 > x.ar$ar 10. asymtotic AR(p) = = O O p t = x}@W xR @ @ x W |R U QNDU= G= x.ar$asy.var |vWwOv|wUwt 28 −1 0 x 1 2 3 1391 ' 0 20 40 60 80 100 0.6 0.2 −0.2 ACF 1.0 Index 0 5 10 15 20 0.2 0.4 0.6 −0.2 Partial ACF Lag 5 10 15 20 Lag V}=y|oDU@tyOwN w AR(1) Ov Q V}=tv Q@ 'OW =iDU= =yO)m } i %82 pmW 1] 0.6009459 > x.ar$ar + c(-2, 2) sqrt(x.ar$asy.var) pOt QDt=Q=B u=v}t]= xR=@ 1] 0.4404031 0.7614886 ? =NDv= "CU= Q=wDU= |}=tvDUQO QFm =OL `@=D = T U= Q Ov}Qi xO QO VR= @ x]@= x@U=Lt "CU= pOt QDt=Q=B pk=OL Qov=}@ xm OwW|t s=Hv= 12 AIC x]@= " QO xm 11 mle Ov}Qi x@ \w@ Qt R= ' CU= Q} R p VwQ Okt Q= w x O CQ Y @ x W xDio AIC = ;2 log-likelihood + 2 number of parameters CUQO x@DQt Q= Okt R= = = O xm O}vm xHwD "Ovm|t Q=}DN= 'q @ | y ) m ^ = 0:6 Q Q AR(1) QDmJwm xm 'Ot CUOx@ O w "OQ= v O Hw E}L u}= @= @ Q Q | U w |t O}OQD =@ "CU= u= D =@ =aO= u}= = = O QDt=Q=B p t AIC u QDm } Q wtv |@=} R=@ OQw @ "O Q |t pOt QDt=Q=B Q=Okt pt=W %95 u=v}t]= x =Nro QF= |= v R= 11. Maximum likelihood estimation AR p t % |W=v xm OyO|t u=Wv Q CU= xOW |Q oR U |= @ " VR=Q@ P h L w = O = =Q tO |v=yH 12. Akaike Information Criterion R= =Q = =t= xR @ |W=v 1970 |=x @ D QO } p t " U= |=tO |QU OvwQ V}=Ri= |iO=YD xO}OB l} p=kDv= ar() ` = p = 1 |va O C = 0:7 O J m @ p t ' R= |O= }= w OO o xDi=} =aO= Q u} QDy@ =Q VR= @ = 9 3 2 Q p U R= | U u}= Ov}=Ri OvwQ xm Owtv x}=B |iO=YD 29 "O wtv =iDU= u}at `@=wD xO R= xm O wtv u uw @ xO O}vm xHwD xvq=U " = = O |R Up t =Q Q | tO | U = O | yp t 2 pYi OvwQ xirw-t CU= umtt '=yxO=O u}ov=}t x@ xDi=} Q VR= @ AR O x@ p t > www <{ "http://www.massey.ac.nz/~pscowper/ts/global.dat" > Global <{ scan(www) > Global.ts <{ ts(Global, st = c(1856, 1), end = c(2005, 12), fr = 12) > Global.ar <{ ar(aggregate(Global.ts, FUN = mean), method = "mle") > mean(aggregate(Global.ts, FUN = mean)) −0.2 0.0 0.2 0.4 ACF 0.6 0.8 1.0 1] -0.1382628 > Global.ar$order 1] 4 > Global.ar$ar 1] 0.58762026 0.01260253 0.11116731 0.26763656 > acf(Global.ar$res-(1:Global.ar$order)], lag = 50, main="") 0 10 20 30 40 50 Lag =yxOv=t}k=@ Q=ov|oDU@ty V}=tv Q}N-=D QO rk O Okt RH x@ =Q} R "OyO|t u=Wv Q= |t Q_v x@ ?U=vt '=yxO=O Q@ " UQ xO=O CUOx@ O = QDt=Q=B =Q p t | y w =Q O}iU xiwv AR(4) xvq=U \UwDt = O Q | U %92 pmW l} '=yxOv=t}k=@ Q P O Q 92 p t VR= @ = r " vQ=O Q= k u | tO u}ov=}t Q=Okt xm Q}N= pmW Q=ov|oDU@ty =v}t]= = xR @ QO =yv x}k@ 27 = O G}=Dv x@ xHwD =@ uwvm = | y ) m CWwv " w |t 'CU= u= D x^t = 0:14+0:59(xt 1 +0:14)+0:013(xt 2+0:14)+0:11(xt 3 +0:15)+0:27(xt 4 +0:15) ; ; ; ; ; swU pYi =DU}= |=ypOt O}m = ,= xt =Q f g |v=tR Q w |t | U "O W | Q}o}B EL@ xt=O= u |va} 'Ovmv Q}}eD u=tR f (xt1 xt2 Cov(xt xs) T = w u wvm = "OW KQ]t |@r=]t |}=DU}= x@ `H=Q ,q@k =kDv= QF= QO p xt ) = f (xt1 +h xt2 +h xt +h) k w |t pt=W R}v =Q u=tR v } Q=w m w O W QO w `} RwD `@=D Qo = Ov} wo 1 =DU}= Q QO | U s= D k C@=F Tv=} Q=w w u}ov=}t 'Omw-t |}=DU}= xm O}vm xHwD O = xDW=O |oDU@ " W @ lQLDt X=wN w xrtH quQ } N u}vJty w O}iU xiwv = |Q H xrtH R= q x@ Q CU= Q} R w x " 1. Strictly stationary xt = wt + 1 wt 1 + ; 30 u}ov=}t h} QaD |]N ?}mQD D t R= CQ Y @ u + q wt k= t s q ; ; j Q}N-=D x@ \ki |=ypOt MA(q) % (MA) j Ov}Qi 13 1 1 3 QLDt u}ov=}t Ov}Qi l x]@=Q "OW=@|t O}iU xiwv |r@k =DU}= 31 =kDv= Qorta ?UL Q@ p w |t u= D 2 = xrO=at "CU= w Tv=} Q=w =Q q @ = QiY u}ov=}t =@ O}iU xiwv w O | yp t wt f g u QO wtv |U} wvR=@ "O xt = (1 + 1B + 2B 2 + =DU}= CqtH R= |y=vDt `tH pt=W MA |=yOv}Qi xm u}= x@ Q_v "CU= w = x@ C@Uv Tv=} Q=wwmwD= w B ' w xm QUB + q B q )wt = q (B )wt | "OQ=O O Hw u tR pYi 3 u}ov=}t =@ QO C F w qx xrtHOvJ q HQO R= |= u QO xm CU= Q=QkQ@ |}=DU}= =Pr 'CU= O}iU xiwv CU= x@U=Lt p@=k |oO=U x@ " xt f g Tv=} Q=w w u}ov=}t E (xt ) = E (wt + 1 wt 1 + + q wt q ) = E (wt) + 1 E (wt 1) + + q E (wt q ) =0 ; ; ; ; OvDUy QiY Q@=Q@ =yu}ov=}t " R= l} Qy =Q} R Var(xt ) = Var(wt + 1wt 1 + + q wt q ) = Var(wt) + 12 Var(wt 1) + + q2 Var(wt q ) = w2 (1 + 12 + + q2) ; ; ; " OvDUy pkDUt Qo}Om} " 8 > > > 1 > > > q ;k > < i i+k > > > > > : C x qtH pt=W t;1 w xt Q =Um} Tv=} Q=w CU= Q} R QwYx@ k 0 qtH s=tD =Q} R |=Q=O C Q |oDU@tyOwN `@=D |= @ i i=0 = }R ' u k = 1 : : : q q k>q 0 O}iU xiwv pkDUt w2 R= w k=0 P (k) = > P 2 > i=0 ; k>q CU= QiY Q@=Q@ `@=D Q CU= |= @ " 0 = 1 CU= QiY =yv Tv=} Q=wwm u}vJty " xrtH O |y=vDt=v x@DQt =@ =DU}= w}UQoQwD= Ov}Qi ?UL Q@ uw @ w =} Q} R "O W u @ wD@ Qo = Ov} wo 2 Q}PBuwQ=w =Q u u= x = (1 B )wt x] w x Ov=wD|t t CQ Y @ ; @=Q =@ MA(1) Ov Q =F =Q u QO w xm OvDUy MA Ov Q } i Q CWwv =]N } i 'p t |= @ " wt = (1 B ) 1xt = xt + xt 1 + 2xt 2 + ; ; ; Ovm " OL=w R= QDoQR@ |oty 2. invertible (B ) O j Y ; |}=Qoty Q \ W = xW} Q jr]t QOk Qo = CU= Q}PBuwQ=w Ov}Qi l} | y =D CU= <1 j j MA(q) Ov Q u QO xm |rm Qw]x@ } i ' OvW=@ " 1391 ' |vWwOv|wUwt 32 R | yp |R=Ux}@W w Q=ov|oDU@ty % w xkrL =iDU= =@ |a@=D Q=m u}= R= xO Q wtv |= @ "O R =} xO B w |t QO u= D =Q MA(q) Ov Q = 2 1 3 =Ft Q |oDU@tyOwN `@=D } i |= @ w |t h} QaD "O W Q \ W > rho <{ function(k, beta) f + q <{ length(beta) - 1 + if (k > q) ACF <{ 0 else f + s1 <{ 0 s2 <{ 0 + for (i in 1:(q-k+1)) s1 <- s1 + betai] betai+k] + for (i in 1:(q+1)) s2 <{ s2 + betai]^2 + ACF <{ s1 / s2g + ACFg Ov Q Q Q = O C x@ =L p = MA(q) Ov Q Q |oDU@t w ` = = = O =iD = C pm w x 3 = 0:2 = 0:5 1 = 0:7 = QD = = MA(3) > beta <{ c(1, 0.7, 0.5, 0.2) > rho.k <{ rep(1, 10) > for (k in 1:10) rho.kk] <{ rho(k, beta) > plot(0:10, c(1, rho.k), pch = 4, ylab = expression(rhok]), xlab="lag k") > abline(0, 0) }R | y ) m " U U= 13 t @ k } i |= @ W CQ Y @ yO N w @ D 'q @ | y ) m R= xO ' | y 0.6 0.8 1.0 " U= 0.0 0.2 0.4 ρk } i |= @ 0 2 4 6 8 lag k MA(3) O =ov|oDU@ty V}=tv p t Q %13 pmW 10 t=Q B @ U= @ =DU}= 33 w |v=tR Q | U "O Q}o|t Q=Qk =iDU= xO w =ov|oDU@ty s}UQD OQ t Q w MA(3) Ov Q = O | yp t = x}@W } i |R U 3 Q Q} R |= @ pYi = O | y ) m |oDU@tyOwN `@=D Q=Okt xU u}rw= 'CiQ|t Q=_Dv= xm Qw]u=ty "CU= xOW s}UQD 23 pmW QO Q=ov|oDU@ty O Q " vQ=O Q= k u =v}t]= = xR @ QO CU= " | r 3 =y k Q}O=kt Q}oxvwtv ' Q}}eD C= R= R= QDW}@ = Q}N-=D | y Q |= @ w OvDUy QiY R= |Q=O 4 2 0 −2 x −4 200 400 600 800 1000 0.4 0.0 ACF 0.8 time t 0 5 10 15 20 25 30 Lag u Q =ov|oDU@ty w Cw =iD |=Q=O |W=v xm OW=@ xDW=O OwHw |oORuwQ}@ CU= umtt sy %5 xD@r= > set.seed(1) > b <{ c(0.8, 0.6, 0.4) > x <{ w <{ rnorm(1000) > for (t in 4:1000) f + for (j in 1:3) xt] <{ xt] + bj] wt - j] +g > par(mfrow=c(2,1), mar=c(4,4,2,4)) > plot(x, type = "l", xlab="time t") > acf(x, main="") 0 |vat MA(3) = x}@W Ov}Qi V}=tv |R U %23 pmW 1391 ' |vWwOv|wUwt 34 xDi=} VR=Q@ xOW |R=Ux}@W |QU = w =@ pOt x@DQt xm u t oQ QUm u}ov=}t =Q w OQ=O O Hw Q V}B Z i arima() w x O CQ Y @ x W R = x@ |a@=D s v xDio `@=D ' O= x@ xDi=} Q = ar() ` = qN Q@ Q |t "O W Q 3 <=O@t MA(q) O order=c(0,0,q) p t Q xrtH OQw @ 1 2 3 VR=Q@ pOt w |t s}_vD @ D h 23 |=ypOt Q@ Ov=wD|t QO " @ } VR= @ yxO=O "OO o C MA R= Z a Ovm|tv QO w =a@ Qt `wtHt '=yQDt=Q=B OQwQ@ |=Q@ arima() `@=D "OvwW|t OQwQ@ |OOa sD} Qwor= l} \UwD pOt |=yQDt=Q=B O = " W @ = QDt=Q=B ' y Q} R |=R= w x CQ Y @ x@ xm CU= method=c("CSS") = w x | w w u x MA(q) Ov Q Q Q | Q Q | x@ =L Qm Q wt = O =t} = u t oQ CQ Y w^t |va }= @ DQ Y QO } i VR= @ |= @ yx v } VOQw @ w m k @ "OO o t U xD@r= = |t pk=OL OR U =Q |]QW =a@ Qt `wtHt sD} Qwor= K}wD ] W C t Q w x =yxOv=t}k=@ =a@ Qt `wtHt t Q ] @ C CU= " S (^1 : : : ^q ) = Q =kt R= | }O O '|O a | n X t=1 w^t = 2 n n X wHDUH "OvW=@ QiY =@ Q@=Q@ '=yv Q=QmD pt=W Q Q Q}N= xOW VR= @ = x}@W |R U coeff: 2 s.e. of coeff: =@ Qk , } D O = | yxO=O Q}o|t Q=Qk ; w^0 : : : w^t Q u Q@ \w =a@ Qt `wtHt xm Ovm|t u}at =Q =yQDt=Q=B `w W QO Q pk=OL q=@ = QDt=Q=B "O@=}|t + ^q w^t q ) ; t=1 "OO o | y o2 xt ; (^1w^t 1 + q Q}O=kt xm ; C x.ma %95 =v}t x@ u QLDt u}ov=}t 'l = ]= xR @ QO O Q QWt = O p t ' }R | y ) m QO xt=vQ@ |HwQN O Q QO x W OQw @ =_Dv= xm u=vJty ,=vt "CU= xOW xO=iDU= =yv R= |R=Ux}@W QO xm OwW|t (0.8,0.6,0.4) |=yQDt=Q=B Q}O=kt O QiY =@ "OQ= v include.mean=FALSE = w = u Q C include.mean=TRUE > set.seed(1) > b <{ c(0.8, 0.6, 0.4) > x <{ w <{ rnorm(1000) > for (t in 4:1000) f + for (j in 1:3) xt] <{ xt] + bj] wt - j] +g > x.ma <{ arima(x, order = c(0, 0, 3)) > x.ma `@=D QO u t oQ R= Q m " U= Call: arima(x = x, order = c(0, 0, 3)) 3. Intercept |Q=O |vat Cw =iD wtv s}_vD QiY Q@=Q@ }= |= @ "O Q V}B u}=Q@=v@ Z i <= =Q O@t u}ov=}t Q=Okt w |t "O W Q CiQ|t R= Z a =iDU= xO w |t u= D arima() =DU}= 35 = O | yp t pYi 3 Coefficients: ma1 ma2 ma3 0.7898 0.5665 0.3959 s.e. 0.0307 intercept 0.0351 -0.0322 0.0320 sigma^2 estimated as 1.068: 0.0898 log likelihood = -1452.41, ARMA Ov}Qi aic = 2914.83 33 %|@}mQD |=ypOt 1 3 3 h} QaD CU= Q} R " w x CQ Y @ p x@ Q D t R= w}UQoQwD= Ov}Qi xt = 1 xt 1 + 2xt 2 + ; MA AR Ov Q x |D = O (ARMA) QLD u}o =} w} Q w } i l m v t CU= Q} R w Ov}Qi |=Q=O w x " CQ Y @ u xt = 1xt 1 + 2xt 2 + ; " ; x]@=Q xt f w |t =Wv "O W = QDt=Q=B =y i | y |v=tR |QU g xO=O u w w O}iU xiwv f t g Q |t pY=L 'OvwW|t xOwRi= sy x@ ARMA(p,q) = @ w ; ; w x w |t CQ Y @ u= D xm u QO "OO o CU= + pxt p + wt + 1wt 1 + 2 wt 2 + CWwv wQUB p=kDv= Qorta xm Qw]u=ty ; O}it xDUO "OvDUy pOt U oQ D= g |QU 'OW xOy=Wt ,q@k + pxt p + wt ; kw yp t R= | t xt f (p,q) x@ Q D t R= + q wt ; w x]@=Q "CU= O}iU xiwv =Q j i wt f ; q xm g u QO p(B )xt = q (B )wt " " OvW=@ OL=w OvW=@ OL=w " R= QDoQR@ R= QDoQR@ wYN X QDW}@ |}Q=m ,=@r=e QO | ARMA(p,q) w OQ t QO Q} R 1 = xW} Q s=tD jr]t QOk Qo = CU= Q}PBuwQ=w Ov}Qi 2 | y CU= ARMA(p,0) p t X N CU= ARMA(0,q) p t X N ARMA w OQ= t = xW} Q s=tD jr]t QOk Qo = CU= =DU}= Ov}Qi | y " " =yQDt=Q=B CU= xHwD QwNQO O = Cr=L AR(p) p t 3 O = Cr=L MA(q) p t 4 w |t s=Hv= p t 'O W "OQ=O O |}=yvD x@ O O Q |Dkw %QDt=Q=B pk=OL VR= @ AR = MA } w = O x@ C@Uv | yp t 5 1391 ' |vWwOv|wUwt 36 pOt swO C qtH ?UL Q@ =Q O Q}o@ Q_v " } x OD@= QO xm CU= QDy@ 'f t g |v=tR u = QO =Q ARMA(1,1) O =F ARMA(p,q) Q | U Q OvDUy pkDUt sy p t p t |= @ " xt = xt 1 + wt + wt =Q Q}N= xrO=at "CU= Var(wt) = w2 E (wt ) w O " } QO R= 2 3 3 X=wN swO x@DQt X=wN u}}aD |=Q@ =yv =Q} R "O}U} wv@ O}iU xiwv 1 ; ; Q@ x@DQt u O}iU xiwv Tv=} Q=w w wt u}ov=}t "CU= O}iU xiwv = xirw-t ?UL Q@ xm | y xO wtv ?DQt w |Q ] u QO xt xm = T U= xt = (1 B ) 1(1 + B )wt ; ; CU= Q} R w x " xt = (1 + B + 2B 2 + = 1 X i=0 = 1+ w CU= E (wt i) = 0 = i ; y Q \U@ h ] )(1 + B )wt ! iB i (1 + B )wt 1 X i=0 i+1B i+1 + = wt + ( + ) Tv=} Q=w = x]@=Q CU=Q CQ Y @ q @ =tD s |=R= 1 X 1 X i=0 i 1wt ; ; i=0 ! iB i+1 wt i E (xt ) u}o =} x@ =Q} R 'CU= QiY Q@=Q@ " Var(xt ) = Var wt + ( + ) 1 X = x]@=Q x@ xHwD =@ v t 'q @ # i 1wt ; i ; i=1 = w2 + w2 ( + )(1 + 2) ; 1 w |t xH}Dv "O W k>0 Cov(xt xt+k ) = ( + )k 1w2 + ( + )2w2 k ; Q |= @ 1 X i=0 2i k T = 2 1 ; w |t xH}Dv k |oDU@tyOwN `@=D "O W k = k =0 = Cov(xt xt+k )= Var(xt ) k 1 = ( + )(1 +2 ) 1 + + ; Q ; = ( + )k 1w2 + ( + )2w2 k (1 ; 2) ; ww v } Q=w m D= |= @ Q |= @ =DU}= 37 k = k |@ QHDp}rLD ; CiQo xH}Dv 1 ARMA % = O | yp t 3 w |t Q}N= x]@=Q u= D w |t w |t EL@ u= D c(p,0,q) x@ Q = D t @ Oa@ pYi =Q O W arima() ` = @ D | ARIMA ARMA(p,q) QO \UwD Ov=wD|t xm = Ov}Qi | y O wtv p t "O u R= R= 43 |=ypOt 1 4 3 VR=Q@ w |R=Ux}@W `@=D \UwD pYi ARMA Ov Q R arima.sim() QD|twta = x}@W |R U w } i QO Q "O=O VR= @ O TBU p t w |t 'O W l}ORv xvwtv R= = x}@W |R U w = 0:5 = 0:6 = ARMA(1,1) Ov Q ; w = QDt=Q=B | y @ Q = Q} R } i |= @ yxO=O Q CiQ|t Q=_Dv= xm Qw]u=ty "O@=}|t OQw @ Q =yv Q@ VR= @ = O | y ) m QO ARMA(1,1) CU= q=@ " QO =yv Q}O=kt > set.seed(1) > x <{ arima.sim(n = 10000, list(ar = -0.6, ma = 0.5)) > coef(arima(x, order = c(1, 0, 1))) ar1 ma1 -0.596966371 intercept 0.502703368 -0.006571345 p}O@D x]@= 33 w O@=}|t pmW "OW=@|t =yxO=O CU= lJwm w ' Q p}O@D VR= @ Q Q |=Q=O ARMA(1,1) AR(1) MA(1) =v O ARMA(1,1) Ov Q O Q | x O | =W ARMA(1,1) O Q@ Q ?U |= @ | D = |oDU@tyOwN | y Q Mv | U w t p t m yO } i " vO o t u Ovm|t O}}=D " ' v =Q O u}= =Q p t t 2 4 3 = = O O Q m QO | yp t ' } R | y ) xU}=kt sy =@ =yv AIC O =t}k=@ Q=ov|oDU@ty p t x v R= xO =iDU= w OvDUy O}iU xiwv =@ Q=oR=U > www <{ "http://www.massey.ac.nz/~pscowper/ts/pounds_nz.dat" > x <{ read.table(www, header = T) > x.ts <{ ts(x, st = 1991, fr = 4) > x.ma <{ arima(x.ts, order = c(0, 0, 1)) > x.ar <{ arima(x.ts, order = c(1, 0, 0)) > x.arma <{ arima(x.ts, order = c(1, 0, 1)) > AIC(x.ma) 1] -3.526895 > AIC(x.ar) 1] -37.40417 > AIC(x.arma) 1] -42.27357 > x.arma MQv |QU 1391 ' |vWwOv|wUwt 38 Call: arima(x = x.ts, order = c(1, 0, 1)) Coefficients: ar1 ma1 intercept 0.892 0.532 2.960 s.e. 0.076 0.202 0.244 sigma^2 estimated as 0.0151: log likelihood = 25.1, aic = -42.3 0.4 −0.2 0.0 0.2 ACF 0.6 0.8 1.0 > acf(resid(x.arma)) 0 1 2 3 Lag p}O@D MQv Q Q | U |= @ ARMA(1,1) Q O =t}k=@ Q=ov|oDU@ty | U x v %33 pmW sQ=yJ pYi =DU}==v |=ypOt OvwQ w |rYi Q}eD C= QF-=Dt =Q} R 'OvDUy =DU}==v =y|QU R= u}= QO "OW p}O@D =DU}= |QU x@ p=iD Q=@ l} =@ xm CU= " QLDt u}ov=}t l w w}UQoQwD= w =yv "O @ =}U@ Ot xDWPo R= |Q R= |m} |iO=YD uORs=o p=Ft qtH pt=W xm O@=}|t \U@ |iO=YD C w |t xO}t=v 3 ARIMA Q=YDN= x@ xm 'CU= 2 |oJQ=Bm} =} "O W SARIMA w |t w x CQ Y @ =Q u u= D O = |t |v=tR " W @ `}=W |r=t |v=tR = = Q = |t =DU}==v w OR U =}U@ p}rLD | y| U R= |Q Q | y| U QO = pYi | y =Q u QO | xm CU= |rYi w 1 `}tHD wvax@ "OvW=@|t = O pYi uORs o p t =DLt |r=iD qtH pt=W ARIMA ?r]t u}= "Ovm|t Q}eD Kww Qw]x@ Tv=} Q=w =DU}==v xmQw]u=ty G C Ovtv=wv Q=R@= |rYi u= QO = Q | U ARIMA Ov Q } i = O | yp t "O=O u Q | y| U R= =Wv |a@ QO w}UQoQwD= pOt '=y|QU `wv u}= |R=UpOt |=Q@ =yOQm} wQ R= |m} "OQ=O RwQ@ u=mt= R}v |t}rk= |=yOQwmQ QO "CU= 5 GARCH =YDN= x@ Q u xDi=} s}taD `wv w |t xO}t=v 4 ARCH pOt Q=YDN= x@ "O W w CU= Tv=} Q=w Q |= @ w |t xO}t=v "O W 1. aggregated 2. integrated 3. AutoRegressive Integreted Moving Avrage 4. AutoRegressive Conditional Heteroskedastic 5. Generalised AutoRegressive Conditional Heteroskedastic 39 1391 ' |vWwOv|wUwt 40 |rYi Q}e jQ@ w x= N w |iO=YD p=iD u}rw= = pFt OW=@ |iO=YD x=wN 'Ovm uORs o xt = Xt 1 + wt |va ' } ; |iO=YD P h L =Q = ARIMA O}rwD OvwQ Ov=wD|t |QU w f xt Q@ p=iD =ta= p w pFt OW=@ u}at uORs o QO " |OQ t xt = xt xt 1 = wt xt = a + bt + wt Ov Q p =k O = |t =DU}= xm CU= " W @ 1 1 4 p=iD g |QU CU= |]N OvwQ xm 14 pOt r ; ; xt = xt xt 1 =o C O}i x w = =] = |] O l x Q R arima() ` = =W MA(1) = w | x C =DU QLD u}o =} Ov Q l O} Q R \ w u}a O Q |r =i O O} wN =t Q =t |t =H C = Ok = = O =iD = |r =i Q Q ARMA O w | xD@ w | s}_v Qi u}o =} = |r =i Q =o Q d=0 include.mean=FALSE arima() ` = xt = yt = b + wt + wt 1 u Q =v O = xt = a + bt + wt x O}v Q ARIMA O = =@ Pt Q MA(1) Q O | C x xt = x0 + i=1 yi x] yt = xt wma h Qa =iD = C O = x}@ xt T = u Q =v C -1 Q Q wt 1 ? Q O = Q yt |r =i | = Q r ; VR= @ ' v ' QO U= @ U= U @ D "O=O u yO VR= @ xO x ; U D D | U t vwQ N @ v @ @ =Q i v| y N @ =Q u u= D D p t p t u= D y= t @ @ x W |R U W f t W t UO @ g v } Q=w }= l W D v R Y t t @= @ v t @ F Q= v t @ w t @ t QO } i @ =Q m Z i r T D | U x v @ D R= p t @ \ DQ= QO t } } ' @ } VR= @ f ; } yp t w m U= } i U= t @=Q }= @ @ " m m o = "OQ }= @ @ ' W @ ; o = " } } QO r= "O W "O=O VR= @ r vwQ D R= xO g U= @ " D U= v tR | U Ci=} Oy=wN V}=Ri= s}kDUt \N pwL " O}vm xOy=Wt Q} R " yt = xt = xt xt 1 = a + bt + wt = b + wt + wt QO O}v=wD|t =Q Q}N= r ; ; a + b(t 1) + wt ; f ; 1 ; ) x0 + t X i=1 yi = x0 + t X (b + wi ; wt 1) ; i=1 = x0 + bt + wt = xt ; 1g Q = =} R h= o =Q B C } H =DU}==v 41 Q |t "OO o x0 = a w0 = 0 x xH}D xt 1 Q CU= w w |t "O W xt = xt = xt = xt = xt ... = ; ; ; ; ; ; ; ; ; = x0 + bt + wt + (1 + ) t X i=1 ; ; 3 ; wt CUDQ=@a Tv=} Q=w %R= Q@=Q@ Tv=} Q=w w CQ Y u}= QO QUB |v} Ro}=H =@ |= @ w ; + b + wt + wt 1 2 + b + wt 1 + wt 2 + b + wt + wt 1 2 + 2b + wt + (1 + )wt 1 + wt 2 3 + 3b + wt + (1 + )wt 1 + (1 + )wt 2 + wt 1 ; pYi 4 O}W=@ xDW=O xHwD m v O | yp t xm Var(xt ) = w2 f1 + (1 + )2(t ; 1)g O = = ;1 x u Qo O = | V R R} W @ m }= t ' @ } t }= i= v Vv=} Q=w t Q= Okt V}=Ri= =@ xm 2 CU= w " sD} Q=or Q | U ' = =F Q Q}o|t w | yxO=O p t |= @ "O |v=tR =F |r=iD p t Q | U 14 Q pmW CQ Y di \ R w U D wtv xU Q} R QO p=iD u}rw= 'OW x_Lqt ,q@k xm Qw]u=ty = O O Q}o@ Q_v | y ) m " } Q=O xDU} QDmr= O}rwD x@ QO =Q w |t xOy=Wt xm Qw]u=ty "OyO|t u=Wv | U wO QO O W sD} Q=or |r=iD =Q w Q |a}@] \ @ t Q | U w |r=iD w |tv Qy=_ Qo}O OvwQ xirw-t 'xOW xDio "O W > www <{ "http://www.massey.ac.nz/~pscowper/ts/cbe.dat" > CBE <{ read.table(www, he = T) > Elec.ts <{ ts(CBE, 3], start = 1958, freq = 12) > par(mfrow=c(3,1), mar=c(4,4,2,4)) > plot(Elec.ts) > plot(di(Elec.ts)) > plot(di(log(Elec.ts))) 6 |k}irD pOt =@ w Q Ov} wo d x@ Q D t R= |k}irD pOt O = |t wQUB p=kDv= Qorta | U " W @ =ov =Q u x B u QO wt Q 'OO o f xm CU= g d r O}iU xiwv p=iD u}t=d (1 ; B )d x m s}O}O R= TB w |t "O W Qo = 'CU= xt f 2 1 4 g |QU xO=O u d x@ Q |k}irD D t R= (1 ; B ) = wt di() ` = w | C I (1) = C = | =Y C Q p = di(x, d=2) = di(di(x)) p =Wv Qo = I (d) xt f g d =F wvax@ "CW=O R}v q=@ x@DQt =@ p t u= wva Q} R `@=D u}= u= Qo}O u=twoQ QO | 6. Integrated model =Q " @ D u= D U= mP @ k t " U= X N } w r L iO = O = D uORs o " W @ =iD Q=@ wO Q |= @ |vWwOv|wUwt 42 8000 2000 Elec.ts 14000 1391 ' 1960 1965 1970 1975 1980 1985 1990 1980 1985 1990 1980 1985 1990 1000 0 −1500 diff(Elec.ts) Time 1960 1965 1970 1975 0.00 0.10 0.20 −0.15 diff(log(Elec.ts)) Time 1960 1965 1970 1975 Time |tD} Q=or |r=iD Q | U w u}= "CU= OL=w Q@=Q@ ZQiV}B CQwYx@ xirw-t di(x, lag=12) =F Q |r=iD Q |v=tR Q | U ' Okt "Ovm XNWt u Q= Q |atH pOt p t |= @ "OO o QO | U =Q |rYi V}=tv %14 pmW p=iD Q}N-=D Ov=wD|t xm CU= OwHwt lag Q}}eD xirw-t C= P h L ?@U Ov=wD|t u=twoQ =iD CU= umtt =Hv}= QO "O}=tv|t hPL xv=y=t |=y|QU QO =Q |atH pOt |rYi C=Q}}eD QF= w |]N OvwQ Cw u O)m TBU 'O}vm xHwD wt = vt vt ; ; 3 =F x@ s=y@= `iQ p t lag d Q O = xDW=O s=y@= |= @ " W @ " w CU= Q} R w x CQ Y @ = w u t oQ wO u}@ di() ` = @ D QO > w <{ di(v, lag=2, d=1) =yp=Ft Ov}Qi x@ p}O@D xt f g |QU B )yt = q (B )wt = x Qo = uwvm = "CU= p ( | H @ p=iD u}t=d Qo = 'CU= x =ov w ARIMA(p,d,q) Ov Q O = yt = (1 ; B )d xt Q xt | = Q Q ARMA(p,q) Q} Q xt Q}eD yt } i |=Q=O f ' W @ 3 1 4 h} QaD g v tR | U o = "OO o xm OwW|t xH}Dv 'O o Q= k t p(B )(1 B )dxt = q (B )wt ; ARIMA = O =F OvJ x@ uwvm = "OvDUy q w p x@DQt R= ?}DQD x@ |}=y|=xrtH OvJ q w p | yp t R= p t u QO xm O}vm xHwD " =DU}==v 43 QUB p=kDv= Qorta w x w CQ Y @ u wvm = "CU= pOt QDt=Q=B = O 4 1 Ov}Qi | yp t x = xt 1 + wt + wt xm t u QO ; ; pYi w |t xDWwv "O W xt xt 1 = wt + wt ; ; QLDt u}ov=}t |k}irD pOt l 1 ) ; u x@ CU= w ' ARIMA(0,d,q)IMA(d,q) |r m (1 ; B )xt = (1 + B )wt ARIMA(0,1,1) Cr=L w |t =Wv QO "O W xt Q IMA(1,1) w x g | U 'xU}=kt =@ CQ Y @ f xO=O u u}=Q@=v@ w x xm Ov} wo CQ Y @ CU= " Qorta w x CQ Y @ u wvm = "CU= pOt QDt=Q=B u QO x = xt 1 + xt xm t ; 1 ; ; xt 2 + wt Ov Q } i ; w |t xDWwv wQUB p=kDv= "O W xt xt ; |rm Cr=L 1; ; w |t QO "O W xt 1 + xt 2 = wt ; xO=O u ; =Wv ARI(1,1) ) (1 ; B )(1 ; B )xt = wt w x xm Ov} wo |k}irD w}UQoQwD= CQ Y @ CU= " O p t u x@ ARI(p,d)ARIMA(p,d,0) 4 1 4 VR=Q@ w |R=Ux}@W u}}aD = |R U c(p,d,q) = O x@ Q x O = | Q R arima() ` = x}@ xt = 0:5xt 1 + xt 1 + wt + 0:3wt 1 x w Q = @ p t W D t ; m @ } t VR= @ QO ; ; w |t "O W w @ D =@ =yxO=O Q@ @ \ @ t | yxO=O Q =yv Q@ xO=O VR= @ ARIMA(p,d,q) Ov Q } i Q} R |=yO)m =F Q Q |t QO p t |= @ "OO o ARIMA(1,1,1) O TBU p t O w x W > set.seed(1) > x <{ w <{ rnorm(1000) > for (i in 3:1000) xi] <{ 0.5 xi - 1] + xi - 1] - 0.5 + xi - 2] + wi] + 0.3 wi - 1] > arima(x, order = c(1, 1, 1)) Call: arima(x = x, order = c(1, 1, 1)) Coecients: ar1 ma1 0.4235 0.3308 s.e. 0.0433 0.0450 sigma^2 estimated as 1.067: log likelihood = -1450.13, aic = 2906.26 = "OQ=O s v arima.sim() ` = @ D u}= "OyO|t s=Hv= = O)m u=ty Q=m xm =Q q @ CU= Q} R " w x =N@=Dm `@=D OQ=O O Hw |= v w x O QO xD@r= = x}@W sDU}U uwvm = CQ Y @ x W |R U > x <{ arima.sim(model = list(order = c(1, 1, 1), ar = 0.5, R 1391 ' |vWwOv|wUwt 44 + ma = 0.3), n = 1000) > arima(x, order = c(1, 1, 1)) Call: arima(x = x, order = c(1, 1, 1)) Coecients: ar1 ma1 0.5567 0.2502 s.e. 0.0372 0.0437 sigma^2 estimated as 1.079: log likelihood = -1457.45, aic = 2920.91 ARIMA |rYi 24 |=ypOt 1 2 4 h} QaD |atH pOt |rYi C=Q}}eD QF= =D Ovm|t xO=iDU= (s) pYi xR=Ov= x@ |Q}N-=D =@ p=iD R= ARIMA |rYi pOt s Q} u}ov=}t xrtH Qov=}@ p=iD O s Q} O = |t p t " W @ CWwv Q} R = =@ N-D l = N-D w Ovm|t QLDt u}ov=}t w P OvwQ xirw-t p=iD Qorta OL=w Q}N-=D =@ h L =Q w}UQoQwD= w x QUB p=kDv= Qorta ?UL Q@ w |t CQ Y @ w u= D =Q P ARIMA |rY O C QLD ARIMA(p d q)(P D Q)s |rY qtH pt=W C Q "OO o h L i p t " U= l t i P (B s) p(B )(1 ; B s)D (1 ; B )d xt = Q(B s)q (B )wt |twta Cr=L xrtH OvJ |= OvW=@|t QO " q Qp P w ' qtH xYNWt xrO=at = xrtH OvJ ?}DQD x@ R= | y = xW} Q jr]t QOk C |rYi pOt p=Ft OvJ x@ uwvm = x@DQt ' | y w q Q p P D=d=0Q o= w Oy=wN =DU}= x=ov 'OvW=@ OL=w "O @ R= ' w ' QDoQR@ |oty Q}N= xrO=at AJ O}vm xHwD = = p U x t |wQ w x xm CQ Y @ ARIMA(0 0 0)(1 0 0)12 12 |rY ' xDWPo p=U x=t xm u Q@ O = \w QWt CU= ?U=vt xv=y=t 1=12 " W @ j ; j >1Q o= =v =@ i ?w D = AR = O xO U p t Q |rOt u}vJ "CU= | yxO=O |= @ CU= =DU}= pOt u}= "OW=@ xDW=Po QF= |}=H@=H =@ ' } t "O W ' U= \U@ t ; ; ; ; UO @ t t "O=O } w Y L }= @ }= v p t " W @ ; t W v u= D }= "OQ=O t v r r W o p U QO x t } Q |=Q=O m U= i m @=Q CQ Y @ =Q p t ; } u tR u ; t =Q q @ ; } i ' H D @ " CQ Y @ u= D ; = |Q H y QO H D t W @ @ oQ @ t @ m H D }= m u tR QO J h ] |= @ p t @=Q | } H Q h ] ARIMA x = xt 1 + xt 12 xt 13 + wt w x w | = Ov O O | C x 1 (B 12 )(1 B )xt = wt = (1 B 12 )(1 B )xt = wt x] Q} wD = w | p = ARIMA(0 1 0)(1 0 0)12 Ov Q |rY ARIMA |r x] = xU =k = x ?r] u x x w = C w w | R} xt = xt 12 + wt w x O u x O}v x w C =DU = O u xD P = = |va = =t Q}}e x |oDU t = Q}}e x O = | B = 1 xW x C (1 B ) xrt p = A Q xrt Ov Q w xm =t= "CU= =DU}==v pOt u}= " xt = x12 + wt u QO m i D m m J = }R =DU}==v 45 x = (1 B 4)wt = wt wt u}= "CU= t ; OvW=@ |iO=YD OvwQ ' w x ; x = xt 1 + wt wt w |t w 'CU= t =v ; ; 4 ; O O pYi 4 QLDt u}ov=}t pOt l} CQ Y @ =yxO=O Qo = "CU= ?U=vt OvwQ |=Q=O CQ Y @ u= D ?w D QO w x pYi Q=yJ 4 ; = | yp t l = Q \ki uw @ | yxO=O |= @ CU= =DU}= pOt w xm O}=}|t \U@ pw= x@DQt p=iD CQwYx@ pOt 1 0)(0 0 1)4 p=iD 'OW=@ |iO=YD OvwQ |=Q=O |rYi CqtH Qo = "CWwv R}v ARIMA(0 w x O CQ Y @ =Q u w ' yO |t CUOx@ xt = xt 4 + wt wt =Q ; ; " CW=O l} Q}N-=D =@ p=iD w |t u}=Q@=v@ 'Ovm|t u= D CWwv P 4 ; x]@=Q w |t R}v u= D |]N OvwQ h L =Q Q |t p=ta= R}v |rYi w OO o ARIMA(0 0 0)(0 1 1)4 s Q} = = p=iD xm CW=O xHwD O}=@ N-D @ ' QLDt u}ov=}t CqtH x=ov 'OQ=O OwHw |]N OvwQ xm |r=L QO OOQo p=ta= p=iD QO l} Q}N-=D Qo = #Q}N =} l Q |t |iQat O}iU xiwv CQ Y @ w x =F wvax@ w |atH O =t}k=@ t] x "OO o O l} CQwYx@ O}iU xiwv w |rYi C=Q}}eD w |]N OvwQ p t u QO xm 4 =v = |v=tR |QU x@ 'p t u= ?w D @ " O}vm xHwD OQ=O O Hw xt = a + bt + s t] + wt O}vm xHwD " 4 Q} = = p=iD u}rw= x@ uwvm = N-D @ s 4] = s t 4] ; u}=Q@=v@ "OyO|t u=Wv (1 ; B 4 )xt = xt ; xt 4 = a + bt ; (at + b(t ; 4)) + s t] ; s t = 4b + wt ; wt 4 =Q 4Q t @ x v m ; 4] ; + wt ; wt 4 ; ; u}rw= xm O}vm Q Z i u wvm = wtv u=}@ "O 4b C = @ F =ov x ARIMA(0,0,0)(0,1,1) w x =t 4 Q} = = p =i p@ l Q} = xrtH =@ Q 'OO o p w | t xm CQ Y @ =Q u u= D N-D @ a= D R= k } = p=iD x@DQt N-D @ (1 ; B 4 )(1 ; B )xt = (1 ; B 4)(b + s t] ; s t 1] + wt ; wt 1) = wt ; wt 1 ; wt 4 + wt 5 ; ; ; CU= C@=F Q=Okt Ok=i xm CWwv " ; ; ARIMA(0 1 1)(0 1 1)4 w x w |t xm CQ Y @ =Q u u= D VR=Q@ 2 2 4 x} wQ u}=Q@=v@ "OW=@ CqtH R= |@}mQD w OOaDt |=yQDt=Q=B pt=W Ov=wD|t xwkr=@ CQwYx@ '|rYi ARIMA |=ypOt R= QD?U=vt pOt =NDv= ? Q w =LDt= =yxO=O Q@ |= @ w O W u Q Q O VR= @ |= @ p t R= |a}Uw xOw OLt xm CU= xDU}=W xiwv CQwYx@ xOv=t}k=@ Q=ov|oDU@ty |=Q=O ,=k]vt 'xOW xDi=} VR=Q@ ?U=vt pOt "OOQo xO=iDU= AIC x]@= " xm O w OQ=O O Hw x W seasonal xDiQo Q_v QO wva Q} R |v=twoQ `@=D u}= u= xDU} QDmr= O}rwD = | yxO=O sD} Q=or w |t QO "O W Q | U =iDU= xO Q} R p=Ft Q Q VR= @ |= @ Q |t QO "OO o CU= O}iU arima() ` = GQO u QO R @ D R= ' |rYi QO = xirw-t | y 1391 ' |vWwOv|wUwt QDy@ =Q | Q VR= @ ARI 46 O Ovm|t p t " P h L =Q |]N OvwQ xm CU= d=1 w OQ t wO Qy QDmJwm "OQ=O | QO p=iD QDt=Q=B "CU= AIC Q O = } R ' yO |t u=Wv > www <{ "http://www.massey.ac.nz/~pscowper/ts/cbe.dat" > CBE <{ read.table(www, he = T) > Elec.ts <{ ts(CBE, 3], start = 1958, freq = 12) > AIC (arima(log(Elec.ts), order = c(1,1,0), + seas = list(order = c(1,0,0), 12))) 1] -1764.741 > AIC (arima(log(Elec.ts), order = c(0,1,1), + seas = list(order = c(0,0,1), 12))) 1] -1361.586 `@=D Qt= u}= VwQ QO CrwyU Q w |t |= @ "O W |Dkw OQm} wQ u}= "OyO CUOx@ O}vm xHwD Q} R " xO =Q =iDU= =]N w |aU QD?U=vt pOt = O x@ uwvm = "CU= | y ) m R= QD?U=vt pOt uDi=} AIC x] = = @ T U= Q wDU= sD} Qwor= | DQ= w > www <{ "http://www.massey.ac.nz/~pscowper/ts/cbe.dat" > CBE <{ read.table(www, he = T) > Elec.ts <{ ts(CBE, 3], start = 1958, freq = 12) > get.best.arima <{ function(x.ts, maxord = c(1,1,1,1,1,1)) +f + best.aic <{ 1e8 + n <{ length(x.ts) w =ypOt xvt=O pQDvm Q@ =D CWwv OyO|t + for (p in 0:maxord1]) for(d in 0:maxord2]) for(q in 0:maxord3]) + for (P in 0:maxord4]) for(D in 0:maxord5]) for(Q in 0:maxord6]) +f + t <{ arima(x.ts, order = c(p,d,q), + seas = list(order = c(P,D,Q), + frequency(x.ts)), method = "CSS") + t.aic <{ -2 t$loglik + (log(n) + 1) length(t$coef) + if (t.aic < best.aic) +f + best.aic <{ t.aic + best.t <{ t + best.model <{ c(p,d,q,P,D,Q) +g +g + list(best.aic, best.t, best.model) +g > best.arima.elec <{ get.best.arima( log(Elec.ts), + maxord = c(2,2,2,2,2,2)) > best.t.elec <- best.arima.elec2]] > acf( resid(best.t.elec) ) > best.arima.elec 3]] 1] 0 1 1 2 0 2 w w |t u= D ?= H =Q Q |= @ |mJwm QDy@ OW=@ CSS =DU}==v 47 = O | yp t pYi 4 > ts.plot( cbind( window(Elec.ts,start = 1981), + exp(predict(best.t.elec,12)$pred) ), lty = 1:2) QDq=@ ?D=Qt uwtR "CU= pmW "OvDUy 34 ARIMA(0 1 1)(2 0 2)12 swO pmW O}iU xiwv ,=@} QkD xOW xDio pOt x@DQt R= QDC@U=vt pOt = = O = O =t}k=@ =Q} R 'OUQ|tv Q_v x@ | yx v O |t u=Wv O =Q x W Q =@ O |Qw p t |v}@V}B Q}O=kt 24 8000 10000 12000 14000 " yO Q 'q @ | y ) m |= H= 1982 1984 1986 1988 1990 1992 Time Q O}rwD xv=y=t j @ Q |v}@V}B V}=tv | U %24 pmW ARCH SP500 | y| U = w "OQ=O O Hw R QO MASS x =N =D v @ m QO McGraw-Hill | =Bt v m x@ 34 |=ypOt w Q \ @ t Q SP500 1 3 4 = | yxO=O > library(MASS) > data(SP500) > par(mfrow=c(2,1), mar=c(4,4,2,4)) > plot(SP500, type = 'l') > acf(SP500, main="") =@ "OyO|t =Wv u =Q =DU}= Ov}Qi Okt u} QDoQR@ 'QN ErF Q= =ov pw= x QO u Q= Okt w O |t QO " yO u} QDmJwm Q =Wv u | U O =Q x W \Uw ErF xDio QO = q]= |v=tR C a Q | U 44 pmW Tv=} Q=w xm OwW|t swrat QDW}@ CkO 1391 ' |vWwOv|wUwt 48 0.4 0.0 0.2 ACF 0.6 0.8 1.0 Series resid(best.fit.elec) 0.0 0.5 1.0 1.5 2.0 Lag Q O}rwD xv=y=t j @ w OW=@v C@=F u=tR x@ C@Uv Tv=} Q=w Qo = Q Q}eDt pFt Q = OO o u tR Q | U Q =iDt u=tR Cw x@ xDU@=w w w |tv s=Hv= |t_vt Q}Ut Q O}rwD j @ OW=@ |W}=Ri= Ow} QB w |}=t}B=wy Q xm u}= p}rO x@ CU= =DU}==v |QU =t= 'OQ=Ov O}iU Q u \ W x@ OvDUy Tv=} Q=w =at pO @= @ "O W t i o t UO D v QO } v=S D " R= U= } v= = | yxO=O i v @ |Q=O ?? pm W =a@ Qt u}= "OyO|t u=Wv R= }= @ @ " } R CQ Y @ U= x W Ovv=t =@ x@ CQ a Q}o s=Hv= s_vt 'O "OQ=O =Q Q}}eD C= u | U C 0.048 Q Q 1999 Q@ = 31 = 1900 x w 2 SP500 w | xD Q Q_ 1469 = 360 T O u Q =v C C Q w x SP500 O V}=Ri= Qo}O QO Tv=} Q=w Qo = "Ov} wo `@ Qt Q=ov|oDU@ty x=ov 'OyO|t u=Wv =Q O}iU xiwv Q=ov|oDU@ty u}ov=}t xm pmW heteroskedastic heteroskedastic Q x =o SP500 xw = |va =i SP500 = Ct} |=Q=O | U =ov|oDU@ty xm O}W=@ xDW=O xHwD "Ov} wo |]QW QO %34 "O W x@ x=ov O@=}|t V}=Ri= OvwQ =@ Tv=} Q=w xm xO=O = O =t}k=@ V}=tv | U | yx v xO=O u}ov=}t t Cw @ x v D y k j@=]t Qo = "CU= Q}eDt Tv=} Q=w = =Q u tR x@ C@Uv Q s}_vD QiY "OO o Q}}eD Q}O=kt C= w x =yv CQ Y @ |mJwm Q=Okt Tv=} Q=w =@ xU}=kt QO xm 'CU= K}LYD u}ov=}t =@ `@ Qt Q}O=kt Q=ov|oDU@ty library(MASS) data(SP500) acf((SP500 - mean(SP500))^2) O " yO |t u=Wv O== =Q |Q= } B v w |]QW heteroskedastic w K w x@ 54 pmW =DU}==v −2 −6 SP500 2 4 49 0 500 1000 1500 2000 2500 0.4 0.0 ACF 0.8 Index 0 5 10 15 20 25 30 35 Lag SP500 = Q | yxO=O | U V}=tv %44 pmW 0.0 0.2 0.4 ACF 0.6 0.8 1.0 Series (SP500 − mean(SP500))^2 0 5 10 15 20 25 30 Lag O x W K}LYD u}ov=}t =@ Q}O=kt `@ Qt V}=tv %54 pmW 35 = O | yp t 4 pYi 1391 ' |vWwOv|wUwt 50 ARCH p t h} QaD O x@ uO}UQ Q Ovm u}@D |= @ " =Wv xO=O u Tv=} Q=w =Q ARCH(1) = xm CU= @ QO |]QW Q}}eD xm C= CUOx@ |rOt O}=@ O=O heteroskedastic | =D 'Q iQ u}= Q O f g |QU '?r]t Qo = q t = wt 0 + 1 2t Q uO m p t |= @ w}UQoQwD= x@DQt u}rw= Q ] W 2 3 4 %|Q=O}=B=v uOQm pOt u}= w |t 'O W 1 ; OvDUy pOt " = QDt=Q=B | y 1 0 ' w w CU= OL=w Tv=} Q=w w QiY u}ov=}t =@ O}iU xiwv f t g q=@ x]@=Q O Q}o@ Tv=} Q=w Q}N= x]@=Q " } R= O = QO " W @ volality =} Q u @ |= @ Var(t ) = E (2t ) = E (2t )E (0 + 1 2t 1 ) = E (0 + 1 2t 1 ) = 0 + 1 Var(t 1 ) ; ; ; AR(1) Ov Q = } i @ =Q Q}N= xrO=at Qo = 'CU= QiY u}ov=}t |=Q=O f w OL=w Tv=} Q=w |=Q=O f t g xm u}= x@ Q_v g w O}vm xU}=kt xt = 0 + 1 xt 1 + wt ARCH(1) O v Q T = x O } v | x _ q ARCH O Q x Ov | XNW = =] ` Q ; O v m| t Q= D iQ " AR(1) p F # t C UQO CU= ?U=vt } i p t VR= @ v } Q=w m m m m t t y GARCH | yp t = w x CQ Y @ ARCH(p) Ov Q t O x@ L N w | t p Y= L t "O W = |oDU@tyOwN @ t | y 3 3 4 \w@ Qt |=y\U@ O = \U@ q=@ |=yQ}N-=D =@ p x@DQt Ov}Qi l} x@ Ov=wD|t ARCH pOt x@DQt u}rw= } i " @ } CU= Q} R " v u p X u t t = wt 0 + p2t;i i=1 " ARCH(p) x CU= GARCH(q,p) m ' Qo = 'OW=@|t CU= OL=w Tv=} Q=w ARCH w x CQ Y @ GARCH(q,p) O QiY u}ov=}t =@ O}iU xiwv O p t R= t p t |=Q=O f p w wt f g u QO xm |r=t |=yxO=O OQ@ Q=m =@ QD`}Uw |=y\U@ g |QU "CU= GARCH(0,p) = X N Cr=L t = wt ht ht = 0 + OvDUy pOt " p X i2t i + i=1 u QO j ht xm j ; ; j =1 (j = 0 1 : : : q) i (i = 0 1 : : : p) = QDt=Q=B j | y q X w w CU= =DU}==v 51 xDi=} ht = 0 + t 1 + t ; CU= 64 pmW " 1 ; a = wt ht p xm t O 4 GARCH p t w |R U O GARCH(1,1) 1 + 1 < 1 O = O = w x CQ Y @ w x =ov|oDU@ty w OW=@ CQ Y @ Q VR=Q@ = | yp t = 4 3 4 x}@W O =@ |}=yxO=O Q} R p t Q w |t } @ |Q= } B |= @ "O W pYi = O | y ) m QO = x}@W CU= |R U > set.seed(1) > alpha0 <{ 0.1 > alpha1 <{ 0.4 > beta1 <{ 0.2 > w <{ rnorm(10000) > a <{ rep(0, 10000) > h <{ rep(0, 10000) > for (i in 2:10000) f + hi] <{ alpha0 + alpha1 (ai - 1]^2) + beta1 hi -1] + ai] <{ wi] sqrt(hi]) +g > par(mfrow=c(2,1), mar=c(4,4,2,4)) > acf(a) > acf(a^2, main="") 0.4 0.0 ACF 0.8 Series a 0 10 20 30 40 30 40 0.4 0.0 ACF 0.8 Lag 0 10 20 Lag =yv `@ Qt Qy=_ |oDU@ty Q}O=kt `@ Qt QO xm w OQ=O Q}O=kt Q=ov|oDU@ty V}=tv %64 xDU@ty=v Q}O=kt xm OyO|t u=Wv pmW =Q GARCH O w p t X= N a Q | U Q |t "OO o 1391 ' |vWwOv|wUwt garch() ` = 52 =iDU= =@ xm O@=}|t Q O @ D R= xO = x}@W VR= @ x W |R U = | yxO=O |wQ |@=} R=@ xQ=@ wO pOt |=yQDt=Q=B xm OOQo|t x_Lqt "OwW|t Ci=} tseries = w xm CU= GARCH(1,1) Q@=Q@ Q}N= `@=D ,a v w |t "O W =iDU= xO GARCH Q@ R = w =F Q xDU@ QO xm OwW|t s=Hv= Q V}B "OQ}o|t Q=Qk %95 u=v}t]= u t oQ R= Q |Q= i=s v Z i order=c(p,q) O p t ' } R p t QO QDq=@ = xR @ xOw = x@DQ OLt w |t QO w O W Q =t= 'CU= woNU=B | y |= @ > set.seed(1) > alpha0 <{ 0.1 > alpha1 <{ 0.4 > beta1 <{ 0.2 > w <{ rnorm(10000) > a <{ rep(0, 10000) > h <{ rep(0, 10000) > for (i in 2:10000) f + hi] <{ alpha0 + alpha1 (ai - 1]^2) + beta1 hi -1] + ai] <{ wi] sqrt(hi]) +g > library(tseries) > library(quadprog) > library(zoo) > a.garch <{ garch(a, grad = "numerical", trace = FALSE) > connt(a.garch) Q |t pY=L Q} R G}=Dv "OO o = = O Q 'q @ | y ) m |= H= =@ 2.5 % 97.5 % a0 0.0882393 0.1092903 a1 0.3307897 0.4023932 b1 0.1928344 0.2954660 w x O =@ =Lt pL=Qt CQ Y @ =Q |O a C U O " yO |t CUOx@ w Q wDU= =Q | DQ= OyO|t CUOx@ O |O a VwQ =@ =Lt xYqN =Q C U grad="numerical" trace=F = w O Q wt R= f g |va} GARCH O O =t}k=@ p t x v Q O = |t | U " @ } Q VR= @ SP500 Q | U VR=Q@ Q@ 5 3 4 GARCH O p t w |t x@U=Lt "O W w x O}=@ xH}Dv x=ov 'OW=@ ?U=vt =yxOv=t}k=@ |QU CQ Y @ GARCH(1,1) C = h^ t = ^0 + ^12t 1 + ^h^ t ; 1 Q |= @ GARCH O Qo = p t w |t Qy=_ OL=w Tv=} Q=w r L QO "O W ; |tv u=Wv |r}iD Q@ w^t = pt h^ t QiY u}ov=}t =@ O}iU xiwv =F u t oQ " yO SP500 | U Q} R x]@=Q = w u t oQ p t QO w =DU}==v 53 =@ Q= Okt u u}=Q@=v@ "CU}v OwHwt xOv=t}k=@ O |t CUOx@ =yxOv=t}k=@ " } =a@ Qt C Q | U Q= Q Okt u}rw= O =t}k=@ | U w x v Q "O | U Q |=R= o t s v v= =k}kLD OL=w x@ O s}UQD x W 74 w Q 1850-2007 \ @ t pmW O = CU= xOW s=Hv= |D=ar=]t s}rk= O w QO w x W x v= N Q_v w Q CU= xDiQo Q=Qk pta OQ t | U " l " CU= xOW p}O@D |vwDU x@ Q]U Cr=L | R= t() ` = =iDU= =@ pOt @ D R= xO =@ =Lt U D C U t h L =iDU= R= xO 6 3 4 O = = x@ `H=Q ,=Q}N= QO |Q= } B v East Anglia =oW =v ARIMA O C qt CUOx@ 'CU= xOt 224 CtUk |=yO)m QO xm get.best.arima `@=D \UwD ?U = QDt=Q=B | y xm u QO |QU QO |Q=O}=B=v | yxO=O " pYi 4 @ @ D y w O W s}rk= C O t = 2 : : : n x h^ 1 = 0 Q} | =H garch ` = \ w =o |oDU@t w | P -1] CU= " = | yp t x t p t " Q =v}t]= |= @ u v=O U= = O |t xR @ " } > stemp <{ scan("http://www.massey.ac.nz/~pscowper/ts/stemp.dat") > stemp.ts <{ ts(stemp, start = 1850, freq = 12) > plot(stemp.ts) > stemp.best <{ get.best.arima(stemp.ts, maxord = rep(2,6)) > stemp.best3]] 0.0 −0.5 −1.0 stemp.ts 0.5 1] 1 1 2 2 0 1 1850 1900 1950 2000 Time s}rk= O== Q |Q= } B v | U V}=tv %74 Q |t "OO o pmW Q O = QDt=Q=B OQw @ p t | y w = O xt=O= j i | y ) m QO 1391 ' |vWwOv|wUwt 54 > stemp.arima <{ arima(stemp.ts, order = c(1,1,2), + seas = list(order = c(2,0,1), 12)) > t( connt(stemp.arima) ) ar1 ma1 ma2 sar1 sar2 sma1 2.5 % 0.8317389 -1.447400 0.3256699 0.8576802 -0.02501886 -0.9690530 97.5 % 0.9127947 -1.312553 0.4530474 1.0041394 0.07413434 -0.8507036 Q VR= @ ,=O OHt Q} R = O =@ | y ) m O P O QiY =@ p t = r 'OQ= v |vat |Q=O =iD Cw sar2 |va AR |rY } i xirw-t u}twO O = |t " @ } > stemp.arima <{ arima(stemp.ts, order = c(1,1,2), + seas = list(order = c(1,0,1), 12)) > t( connt(stemp.arima) ) ar1 ma1 ma2 sar1 sma1 2.5 % 0.8304007 -1.445057 0.3242728 0.9243495 -0.9694897 97.5 % 0.9108115 -1.311246 0.4508999 0.9956639 -0.8679223 ARIMA =vt "CU= xOW s}UQD 84 pmW QO , O = O =t}k=@ Q=ov|oDU@ty 'VR=Q@ |} wmv pQDvm |=Q@ p t | yx v w |t x_Lqt Q}N= pmW "O W > stemp.res <- resid(stemp.arima) > par(mfrow=c(2,1), mar=c(4,4,2,4)) > acf(stemp.res) > acf(stemp.res^2, main="") O=| Q = O =t} = Q Q GARCH " @ } t VR= @ yx v k @ | U @ QO R}v =yxOv=t}k=@ `@ Qt Q=ov|oDU@ty |UQQ@ O u}=Q@=v@ p t O w |t u=Wv =yxOv=t}k=@ xt}@ '|r=t |v=tR = QO Q |v=tR | y| U C Q | U =ar=]t p}rLD w QO =Q O N QF= |v}@V}B GARCH O u}= |rY= OQ@ Q=m u}=Q@=v@ QO p t O = = xm CU= uWwQ ,qt=m 'OQ=O O Hw |Q= } B v |R=Ux}@W w " yO w Q |= @ QO GARCH 7 3 4 O OW x_Lqt ,q@k xm Qw]u=ty p t O =kv |v}@V}B "OQ= v \ CU= " QO | = x}@W Ov}Qi |R U Q}F-=D =Pr Q s}rk= |= @ =DU}==v 55 0.4 0.0 ACF 0.8 Series stemp.res 0.0 0.5 1.0 1.5 2.0 2.5 2.0 2.5 0.4 0.0 ACF 0.8 Lag 0.0 0.5 1.0 1.5 Lag =a@ Qt u C w =yxOv=t}k=@ Q=ov|oDU@ty V}=tv %84 pmW = O | yp t 4 pYi 1391 ' |vWwOv|wUwt 56 `H=Qt 1] Cowpertwait, Paul S.P., Metcalf Andrew V. (2009) Introductory Time Series with R, Springer, 254p. 2] Ihaka Ross, (2005) Time Series Analysis, University of Auckland, 105p. 3] Shumway Robert H., Stoer David S., (2011) Time Series Analysis and Its Applications (With R Examples), Third edition, Spriger, 596p.