5. 평활법 (FORECAST procedure) 일변량시계열자료의예측값과예측구간을구할때사용한다. 주로시간과자기자신의과거의관측값의함수를이용하여구하며, 다른시계열예측방법에비해빠르고쉬우며자동적이라는장점이있으나, 시계열의특성을고려하지못한다는단점도있다. 결과물은 output창에출력되는것이아니라하나의 dataset에저장된다. 5.1 예측방법 1 STEPAR(STEPwise AutoRegressive model) 방법 시간추세와자기회귀모형을결합한방법 => AUTOREG 절차와동일 default 로사용되는방법 2 EXPO (EXPOnential smoothing) 방법시간추세모형을가정하여예측값을구하나, 추세모수가서서히변화가능하다고생각하여과거의관측값들을지수적으로가중평균하여예측값을구한다. 단순지수평활, 이중지수평활, 삼중지수평활, Holt의 two-parameter 평활법 default로이용되는지수평활상수 trend=1 : weight=0.2 trend=2 : weight=0.10557 trend=3 : weight=0.07168 3 WINTERS 방법 시간추세와승법계절요인을이용하여계절적변동에대처하며, EXPO 방법과같이과거의관측값들 에지수적으로감소하는가중값을주어예측한다. 4 ADDWINTERS 방법 WINTERS 방법과동일하나가법계절요인을이용한다. 5.2 FORECAST 절차 PROC FORECAST options; BY variables; ID variables; VAR variables; 1 PROC FORECAST 문 options; ASTART = value : 단순지수평활법, Winters 방법, ADDWinters에서상수항에해당하는초기평활값을지정한다. BSTART = value : 이중지수평활법, Winters방법, ADDWinters에서 linear trend에해당하는초기평활값을지정한다 CSTART = value : 삼중지수평활법, Winters방법, ADDWinters에서 quadratic trend에해당하는초기평활값을지정한다.. DATA = SAS dsn : 분석에사용될데이터자료명을지정한다. - 23 -
INTERVAL = interval : 분석에사용될시계열자료의관측주기형태를지정 YEAR, SEMIYEAR, QTR, MONTH, SEMINONTH, WEEK, DAY, HOUR, MINUTE, SECOND LEAD = n : 예측할값의개수를지정. 디폴트 12 METHOD = STEPAR 또는 EXPO, WINTERS, ADDWINTERS : 예측값을구하는데사용될모형또는방법을지정. 디폴트값은 METHOD=STEPAR OUT = SAS dsn : FORECAST 절차에의해출력될결과를저장할 data set 지정 - ACTUAL, FORECAST, RESIDUAL, Lnn, Unn, STD - OUTEST = SAS dsn : FORECAST 절차에의해추정된모수의추정값을저장할 data ser 지정 - AR1-ARn, CONSTANT, LINEAR, N, QUAD, SIGMA, S1-S3, S_name, WEIGHT, EIGHT1-WEIGHT3 - WEIGHT = 또는 (,[ [ ]]) : EXPO, WINTERS, ADDWINTERS 방법에서사용될평활계수의값을지정. EXPO - 1개의평활계수만이지정 WINTERS와 ADDWINTERS - :constant, : linear, : seasonal component SEASONS = interval N : 계절모형의계절형태지정. N : 주기 OUTFULL : 예측값과함께 OUTACTUAL, OUT1STEP, OUTLIMIT에의한모든결과를 OUT = 에의해지정된 data set 에출력 OUTLIMIT : 예측값에대한 confidence limit을 OUT = 에의해지정된 data set 에출력 OUTRESID : 계산된잔차를 OUT= 에의해지정된 data set에출력한다. TREND =n : 추세모형의추세의종류결정한다. 상수모형은 TREND=1, 선형추세모형은 TREND=2, 이차추세모형은 TREND=3이다. 2 BY 문 : 지정된변수들각각에대해자료분석을한다. 3 ID 문 : 지정된변수중첫번째변수가입출력자료명의관측값을구별하는데사용. 일반적으로 SAS date 변수가사용 4 VAR 문 : 입력자료중예측하고자하는변수를지정 5.3 예제 1 SASHELP 라이브러리안에있는 USECON data set 을이용한다. - monthly U.S sale of passenger cars series 2 시계열그림을그린다. 프로그램 title1 "Sales of Passenger Cars"; symbol1 i=spline v=dot; axis2 label=(a=-90 r=90 "Vehicles and Parts") order=(6000 to 24000 by 3000) ; proc gplot data=sashelp.usecon; plot vehicles * date = 1 / haxis= '1jan80'd to '1jan92'd by year vaxis=axis2; where date >= '1jan80'd; format date year4.; - 24 -
결과 3 Estimate 프로그램 proc forecast data=sashelp.usecon interval=month method=winters seasons=month lead=12 out=out outfull outresid outest=est; id date; var vehicles; where date >= '1jan80'd; SAS data set out : 실제값, 예측값과잔차및신뢰구간이저장되어있다 est : 모수의추정값과여러가지적합도통계량들이저장되어있다 4 Plotting Forecasts 프로그램 title2 'Plot of Forecast from WINTERS Method'; symbol1 i=none c=black v=star; /* for _type_=actual */ symbol2 i=spline c=blue v=circle; /* for _type_=forecast */ symbol3 i=spline c=yellow l=3; /* for _type_=l95 */ symbol4 i=spline c=red l=3; /* for _type_=u95 */ axis2 label=( a=-90 r=90 "Vehicles and Parts" ) order=(6000 to 24000 by 3000) ; proc gplot data=out; plot vehicles * date = _type_ / HREF='15dec91'd haxis= '1jan90'd to '1jan93'd by qtr vaxis=axis2; where _type_ ^= 'RESIDUAL' & date >= '1jan90'd; 결과 5 Plotting Residuals - 25 -
프로그램 title2 'Plot of Residuals'; symbol1 i=needle; axis2 label=( a=-90 r=90 "Vehicles and Parts" ); proc gplot data=out; plot vehicles * date = 1 / vref=0 haxis= '1jan80'd to '1jan92'd by year vaxis=axis2; where _type_ = 'RESIDUAL'; format date year4.; 결과 5.4 시계열예측시스템을이용한분석 (Time Series Forecasting System) (1) female data set 을생성한다 프로그램 data female; input y@@; date= intnx('month', '1dec82'd, _n_); format date monyy.; cards; 216 223 229 235 227 236 232 234 237 238 244 270 278 277 274 285 262 243 241 238 259 267 272 269 262 276 297 327 341 323 317 322 337 330 329 342 349 346 345 354 345 354 343 355 362 366 367 348 355 362 373 370 375 395 405 408 399 402 403 402 398 408 427 427 433 442 397 416 425 424 434 434 432 440 469 486 495 506 514 529 528 529 521 537 537 544 557 556 561 569 578 589 570 563 566 571 574 569 596 610 627 655 670 663 664 668 664 667 ; (2) 시계열예측시스템을활성화시킨다. 4.1 절참고 : 솔루션 (S) -> 분석 (S) -> 시계열예측시스템 (F) or 명령어입력창 : forecast 이용 - 26 -
Project : SASUSER(library name).fmsproj(catalog name).proj(project name) Description : project에대한설명을기입한다. Data Set : 분석에이용할 data set을선택한다. Time ID : 시계열분석에이용할시간변수를선택한다. Interval : 관측값이입력된주기를입력한다. : 시계열그림과자료를보여준다. 추세및계절성을확인할수있다. : 분석에이용될 Data Set 과변수를선택한후 Develop Models 를클릭하여나타나는대화상자에서 마우스오른쪽버튼을클릭하거나, 메뉴바에서편집 -> 모형적합을선택한후나타나는방법중에서 분석에사용될방법을선택한다. 평활법을이용하기위해서는 Fit Smoothing Model... 을클릭한뒤, 원하는평활법을선택한다. - Smoothing Method 의설명 - 27 -
Smoothing Method 설명 Simple Smoothing 단순지수평활법 Double <Brown> Smoothing 이중지수평활법 ( 평활상수가하나인경우 ) Seasonal Smoothing 추세가없는 Winters Method Linear <Holt > Smoothing 이모수이중지수평활법 Damped-Trend Smoothing Winters Method-Additive 가법계절지수평활법 Winters Method-Multiplicative 승법계절지수평활법 - Transformation : 모형이적합하도록시계열을변환시켜준다. => Log, Logistic, Square Root, Box-Cox, or None - Smoothing Weights : Level : 시계열의 level에해당하는평활상수값 Trend : 시계열의추세에해당하는평활상수값 Damping : damped-trend smoothing에사용되는평활상수값 Season : Winters method와 Seasonal exponential smoothing에사용되는평활상수값 - Bounds Zero-One/Additive : Zero-One Boundaries : Additive Invertible : Unrestricted : Custom : : 모형을적합시킨뒤의를이용하여예측값들과모수및여러가지통계량들을확인한다. - 28 -
6. 분해법 (EXPAND Procedure) 6.1 분해법 ( 승법모형 ) 또는 ( 가법모형 ) 는추세, 순환성분, 는계절성분, 는불규칙성분 6.2 modelling (1) 가법모형 step 1 : 계절성분의주기에적절한항의이동평균을이용하여계절성분과불규칙성분이제거된추세순환성분 를구한다. step 2 : 계절성분과불규칙성분을구해낸다. step 3 : 에계절성분의주기와일치하지않는개수항의이동평균을적용시켜불규칙성분을제거한다. 이때생성된부분이 가됨. (2) 승법모형 step 1 : 계절성분의주기에적절한항의이동평균을이용하여계절성분과불규칙성분이제거된추세순환성분 를구한다. step 2 : 계절성분과불규칙성분을구해낸다. step 3 : 에계절성분의주기와일치하지않는개수항의이동평균을적용시켜불규칙성분을제거한다. 이때생성된부분이 가됨. 6.3 Expand procedure PROC EXPAND options; BY variables; CONVERT variables; ID variables; - convert x=y /transformout=(movave 5); - convert x=y/ transformout=(cmovave 5); - Transformation operation syntax CD_Is CD_Ss CD_SAs CD_TCs CDA_Is CDA_Ss CDA_SAs CMOVAVE window TRIM n 내용승법모형에서의불규칙성분승법모형에서의계절성분승법모형에서의계절조정한성분승법모형에서의추세성분가법모형에서의불규칙성분가법모형에서의계절성분가법모형에서의계절조정한성분중심이동평균법 또는 인경우 를결측치로생성 - 29 -
6.4 예제프로그램 proc expand data=mindex out=mindex0; convert mindex=m3/transformout=(cmovave 3 trim 1); convert mindex=m5/transformout=(cmovave 5 trim 2); convert mindex=m7/transformout=(cmovave 7 trim 3); 프로그램 proc expand data=mindex out=mindex1; convert mindex=tc/transformout=(cd_tc 12); convert mindex=s/transformout=(cd_s 12); convert mindex=i/transformout=(cd_i 12); convert mindex=sa/transformout=(cd_sa 12); 프로그램 proc expand data=mindex out=mindex2; convert mindex=tc/transformout=(cd_tc 4); convert mindex=s/transformout=(cda_s 4); convert mindex=i/transformout=(cda_i 4); convert mindex=sa/transformout=(cda_sa 4); - 30 -
7. 계절조정 (X11 procedure, X12 procedure) 계절성분으로장기적인추세나경기순환의움직임을알기어려운경우계절성분을시계열에서제거할 때사용한다. 7.1 X11 절차 PROC X11 options; ARIMA options; BY variables; ID variables; MONTHLY options; QUARTERLY options; OUTPUT OUT=dataset options; TABLES tablenames; VAR variables; 1 PROC X11 문 options DATA = SAS dsn : 분석에사용될데이터자료명을지정한다. 2 ARIMA 문 : X-11-ARIMA 방법을적용하기위해이용한다. option문에정확한모형을적어주지않으면최적의모형을자동적으로찾아적합시켜준다. MODEL=(P=n1 Q=n2 SP=n3 SQ=n4 DIF=n5 SDIF=n6 <noint> <center>) 3 BY 문 : 여기서지정된변수들각각에대해자료분석을한다. 4 ID 문 : 여기서지정된변수중첫번째변수가입출력자료명의관측값을구별하는데사용. 일반적으로 SAS date 변수가사용 5 MONTHLY 문 : 월별자료인경우 DATE = variable : date 변수를지정 6 QUARTERLY 문 : 분기자료인경우 DATE = variable : date 변수를지정 7 VAR 문 : 입력자료중예측하고자하는변수를지정 8 TABLES 문 : 명시한테이블을출력한다. 9 OUTPUT OUT = dataset options : 특별한표를포함하는 output data set 생성예 ) var z1 z2 z3; output out=out_x11 b1=s d11=w x y; variable s에 z1에해당하는 B1 값이할당 z1, z2, z3에해당하는 table D11의값이변수 w,x,y에각각할당 7.2 X-12 절차 PROC X12 options; X11 options; VAR variables; OUTPUT options; 1 PROC X12 options ; options - 31 -
NOPRINT : 모든결과물을출력하지않는다 DATE = variable : 날짜변수를입력한다 INTERVAL = month or qtr : 월별자료인지분기자료인지적어준다 2 X11 : Census Bureau X-11 and X-11Q 프로그램의강화된버전으로계절조정을해준다. 다음의옵션으로계절조정에이용할형태를결정한다. options MODE = ADD MODE = MULT MODE = LOGADD MODE = PSEUDOADD value of mode option name model for O model for SA MULT Multiplicative O = C S I SA = C I ADD Additive O = C + S + I SA = C + I LOGADD Log-Additive Log(O) = C + S + I SA = exp(c + I) PSEUDOADD Pseudo-Additive O = C [ S + I - 1 ] SA = C I 7.3 예제 프로그램 data sales; input sales @@; date = intnx( 'month', '01sep1978'd, _n_-1 ); format date monyy7.; cards; 112 118 132 129 121 135 148 148 136 119 104 118 115 126 141 135 125 149 170 170 158 133 114 140 145 150 178 163 172 178 199 199 184 162 146 166 171 180 193 181 183 218 230 242 209 191 172 194 196 196 236 235 229 243 264 272 237 211 180 201 204 188 235 227 234 264 302 293 259 229 203 229 242 233 267 269 270 315 364 347 312 274 237 278 284 277 317 313 318 374 413 405 355 306 271 306 315 301 356 348 355 422 465 467 404 347 305 336 340 318 362 348 363 435 491 505 404 359 310 337 360 342 406 396 420 472 548 559 463 407 362 405 417 391 419 461 472 535 622 606 508 461 390 432 ; symbol1 i=join v=star; proc gplot data=sales ; plot sales*date; 프로그램 proc x11 data=sales noprint; monthly date=date; var sales; tables a1 d11; output out=out1 a1=series d10=d10 d11=d11 d12=d12 d13=d13; 프로그램 symbol1 i=join v='star'; symbol2 i=join v='circle'; legend1 label=none value=('original' 'adjusted'); proc gplot data=out1; plot series * date = 1 d11 * date = 2 / overlay legend=lengend1; - 32 -
프로그램 symbol1 i=join v=dot; proc gplot data=out1; plot ( d10 d12 d13 ) * date; 프로그램 /* X12 procedure 를이용한계절조정 */ proc x12 data=sales date=date; var sales; x11; output out=out2 a1 d11; symbol1 i=join v='star'; symbol2 i=join v='circle'; legend1 label=none value=('original' 'adjusted'); proc gplot data=out2; plot sales_a1* date=1 sales_d11*date=2 / overlay legend=legend1; - 33 -
Appendix: Table Names and Descriptions for X11 procedure Table A1 A2 A3 A4 A5 A13 A14 A15 B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B13 B14 B15 B16 B17 B18 B19 C1 C2 C4 C5 C6 C7 C9 C10 C11 C13 C14 C15 C16 C17 C18 C19 Description (Notes) original series (M) prior monthly adjustment factors (M) original series adjusted for prior monthly factors (M) prior trading-day adjustments (M) prior adjusted or original series (M) ARIMA forecasts ARIMA backcasts prior adjusted or original series extended by arima backcasts, forecasts prior adjusted or original series trend cycle unmodified seasonal-irregular (S-I) ratios replacement values for extreme S-I ratios seasonal factors seasonally adjusted series trend cycle unmodified S-I ratios replacement values for extreme S-I ratios seasonal factors seasonally adjusted series irregular series extreme irregular values excluded from trading-day regression (M) preliminary trading-day regression (M,P) trading-day adjustment factors (M) preliminary weights for irregular components trading-day factors derived from combined daily weights (M) original series adjusted for trading-day and prior variation (M) original series modified by preliminary weights and adjusted for trading-day and prior variation trend cycle modified S-I ratios seasonal factors seasonally adjusted series trend cycle modified S-I ratios seasonal factors seasonally adjusted series irregular series extreme irregular values excluded from trading-day regression (M) final trading-day regression (M,P) final trading-day adjustment factors derived from regression coefficients (M) final weight for irregular components final trading-day factors derived from combined daily weights (M) original series adjusted for trading-day and prior variation (M) - 34 -
Table Description (Notes) D1 original series modified for final weights and adjusted for trading-day and prior variation D2 trend cycle D4 modified S-I ratios D5 seasonal factors D6 seasonally adjusted series D7 trend cycle D8 final unmodified S-I ratios D9 final replacement values for extreme S-I ratios D10 final seasonal factors D11 final seasonally adjusted series D12 final trend cycle D13 final irregular series E1 original series with outliers replaced E2 modified seasonally adjusted series E3 modified irregular series E4 ratios of annual totals (P) E5 percent changes in original series E6 percent changes in final seasonally adjusted series F1 MCD moving average F2 summary measures (P) G1 chart of final seasonally adjusted series and trend cycle (P) G2 chart of S-I ratios with extremes, S-I ratios without extremes, and final seasonal factors (P) G3 chart of S-I ratios with extremes, S-I ratios without extremes, and final seasonal factors in calendar order (P) G4 chart of final irregular and final modified irregular series (P) A,B,C : 중간계산과정에서생성된표들 D : 계절조정으로생성된최종표들 - 35 -
Tables Related to X11 seasonal adjustment for X12 procedure Table Description (Notes) B1 original series, adjusted for prior effects and forecast extended C17 final weights for the irregular component D8 final unmodified SI ratios (differences) D8A F tests for stable and moving seasonality, D8 D9 final replacement values for extreme SI ratios (differences), D iteration D9A moving seasonality ratios for each period D10 final seasonal factors D10D final seasonal difference D11 final seasonally adjusted series D12 final trend-cycle D13 combined seasonal and trading day factors D16 final adjustment difference D18 combined calendar adjustment factors E4 ratio of yearly totals of original and seasonally adjusted series E5 percent changes (differences) in original series E6 percent changes (differences) in seasonally adjusted series E7 percent changes (differences) in final trend component series F2A-F2I X11 diagnostic summary F3 monitoring and quality assessment statistics G spectral plots - 36 -