Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Eviews5 / EViews5 / Example Files / docs / x12tramo

.htm
Скачиваний:
18
Добавлен:
23.03.2015
Размер:
13.2 Кб
Скачать

Comparison of X12 and Tramo/Seats Comparison of X12 and Tramo/Seats Airline model 1 (x12ts1.prg) Airline model 2 (x12ts2.prg) Outlier detection (x12ts3.prg) Forecasts (x12ts4.prg) Airline model 1 This program estimates the airline model in X12 and TRAMO/SEATS. The program compares the seasonal factors and irregular components from TRAMO/SEATS with log transformation, X12 with log-additive mode in levels, and X12 with additive mode and log transformation. 'compare x12 and tramo/seats 'airline model (log) wfcreate x12ts1 m 1949:01 1970:4 series x x.fill 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 smpl 1949:01 1960:12 table str 'TRAMO no constant with log transformation str(1,1) = "TRAMO in logs" freeze(tab1) x.tramoseats(runtype=ts, opt="imean=0 lam=0 noadmiss=1 seats=2", save="sa sf trd cyc ir hat") x1 show tab1 'X12 log-additive mode with no transformation str(2,1) = "X12 log-additive in levels" freeze(tab2) x.x12(mode=l, arima="(0 1 1)(0 1 1)", save="d10 d11 d12 d13") x2 show tab2 'X12 additive mode with log transformation str(3,1) = "X12 additive in logs" freeze(tab3) x.x12(mode=a, tf=0, arima="(0 1 1)(0 1 1)", save="d10 d11 d12 d13") x3 show tab3 'compare seasonal factors group g1 x1_sf x2_sf*100 x3_sf+100 freeze(graph1) g1.line for !i=1 to 3 %text = "seasonal factor---" + str(!i,1) graph1.elem(!i) legend({%text}) next show graph1 'compare irregular group g2 x1_ir x2_ir*100 x3_ir+100 freeze(graph2) g2.line for !i=1 to 3 %text = "irregular---" + str(!i,1) graph2.elem(!i) legend({%text}) next show graph2 ^top

Airline model 2 This program estimates the airline model in X12 and TRAMO/SEATS. The series is log transformed before it is passed on to X12 and TRAMO/SEATS. The program compares the seasonal factors and irregular components from TRAMO/SEATS in levels and X12 with additive mode in levels. 'compare x12 and tramo/seats 'airline model (level) 'last checked 3/26/2004 wfcreate x12ts2 m 1949:01 1970:4 series x x.fill 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 'do log transform x = log(x) smpl 1949:01 1960:12 table str 'TRAMO no constant str(1,1) = "TRAMO in levels" freeze(tab1) x.tramoseats(runtype=ts, opt="imean=0 lam=1 noadmiss=1 seats=2", save="sa sf trd cyc ir hat") x1 show tab1 'X12 additive mode with no transformation str(2,1) = "X12 additive in levels" freeze(tab2) x.x12(mode=a, arima="(0 1 1)(0 1 1)", save="d10 d11 d12 d13") x2 show tab2 'read seasonal factors %seatspath = @temppath + "\seats\graph\series\" %filename = %seatspath + "seas.t" read(skiprow=6) %filename x1_sf 'read irregular %filename = %seatspath + "irreg.t" read(skiprow=6) %filename x1_ir 'compare seasonal factors group g1 x1_sf x2_sf freeze(graph1) g1.line for !i=1 to 2 %text = "seasonal factor---" + str(!i,1) graph1.elem(!i) legend({%text}) next show graph1 'compare irregular group g2 x1_ir x2_ir freeze(graph2) g2.line for !i=1 to 2 %text = "irregular---" + str(!i,1) graph2.elem(!i) legend({%text}) next show graph2 ^top

Outlier detection This program compares the automatic outlier detection routines in X12 and TRAMO/SEATS. See the output files stored as text objects tab1 and tab2 in the workfile. 'compare x12 and tramo/seats outliers wfcreate x12ts3 m 1980:1 1998:1 series x x.fill 88.0, 97.7, 102.5, 96.9, 101.1, 102.7, 93.6, 87.0, 92.1, 89.3, 103.9, 131.0, 78.0, 93.0, 80.6, 109.0, 91.3, 118.0, 113.8, 88.9, 117.4, 122.1, 112.3, 126.6, 100.8, 98.6, 114.9, 113.6, 103.1, 112.9, 109.8, 86.7, 94.4, 97.8, 119.4, 104.9, 107.8, 89.4, 105.4, 117.2, 95.0, 115.3, 112.3, 82.4, 109.6, 113.9, 127.6, 125.3, 112.4, 100.5, 120.3, 111.5, 106.3, 98.8, 129.2, 98.6, 116.4, 130.8, 112.5, 149.4, 103.2, 114.3, 129.4, 109.4, 125.5, 121.3, 127.6, 107.0, 122.6, 134.5, 120.6, 175.0, 108.6, 130.5, 127.5, 133.0, 123.1, 130.9, 144.7, 100.6, 122.9, 143.8, 122.6, 129.3, 106.1, 110.2, 142.4, 123.5, 122.2, 122.4, 160.2, 101.5, 137.5, 144.6, 138.1, 145.1, 97.6, 124.5, 131.9, 138.7, 148.4, 148.9, 157.8, 97.8, 134.2, 154.8, 149.0, 151.0, 118.1, 138.0, 145.2, 144.7, 154.8, 169.8, 173.8, 101.0, 151.3, 172.9, 153.0, 159.4, 135.7, 140.8, 150.6, 152.1, 159.4, 180.6, 178.9, 104.0, 148.8, 171.7, 150.0, 171.0, 135.1, 151.9, 149.9, 153.9, 153.5, 172.3, 176.7, 100.7, 148.1, 175.5, 150.6, 177.5, 144.9, 153.3, 162.3, 158.2, 156.6, 174.3, 188.7, 106.5, 160.8, 184.0, 153.8, 171.8, 146.6, 162.6, 180.3, 178.8, 172.4, 177.7, 203.7, 106.5, 182.6, 189.9, 191.9, 192.9, 160.4, 185.0, 211.2, 182.9, 197.8, 205.5, 214.3, 138.7, 203.9, 208.3, 211.3, 209.9, 187.0, 200.4, 238.1, 208.8, 234.6, 244.6, 243.0, 160.9, 222.4, 233.1, 227.9, 205.8, 178.7, 211.9, 227.6, 210.6, 232.2, 221.8, 256.7, 155.4, 202.7, 246.7 table str smpl @first 1996:10 'TRAMO with automatic outlier detection str(1,1) = "TRAMO with automatic outlier detection" freeze(tab1) x.tramoseats(runtype=ts, opt="lam=1 inic=3 idif=3 iatip=1 aio=0 noadmiss=1 seats=2", save="sa sf trd cyc ir hat") x1 show tab1 'use same model as selected by TRAMO (1,1,1)(0,1,1) 'X12 str(2,1) = "X12 with automatic outlier detection" freeze(tab2) x.x12(mode=a, arima="(1,1,1)(0,1,1)", o, save="d10 d11 d12 d13") x2 show tab2 'compare seasonal factors group g1 x1_sf x2_sf freeze(graph1) g1.line for !i=1 to 2 %text = "seasonal factor---" + str(!i,1) graph1.elem(!i) legend({%text}) next show graph1 'compare irregular group g2 x1_ir x2_ir freeze(graph2) g2.line for !i=1 to 2 %text = "irregular---" + str(!i,1) graph2.elem(!i) legend({%text}) next show graph2 ^top

Forecasts This program compares the forecasts from the airline model in X12 and TRAMO/SEATS. The program illustrates how to read forecasts from data stored in external files by X12 and TRAMO/SEATS. (The number of rows/cols to skip to read in the data correctly may depend on the data length.You should also note that the path where the data files are dumped by each program may differ on your machine, especially if you are using a network version.) 'compare x12 and tramo/seats 'forecasts from airline model (log) 'last revised on 3/26/2004 include sub_plotForecast.prg wfcreate x12ts4 m 1949:01 1970:4 series x x.fill 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 'set paths to read output data files %path_tramo = @temppath + "\seats\graph\forecast" %path_x12 = @temppath + "\x12graphs\" table str '------------------------------------------------------------------------------ 'TRAMO no constant with log transformation '------------------------------------------------------------------------------ str(1,1) = "TRAMO in logs" smpl 1949:01 1960:12 freeze(tab1) x.tramoseats(runtype=ts, opt="imean=0 lam=0 noadmiss=1 seats=2", save="sa sf trd cyc ir hat") x1 show tab1 'get forecasts smpl 58:12 62:12 %filename= %path_tramo +"\forx.t5" read(skiprow=6) %filename x1f_upp read(skiprow=55) %filename x1f_low read(skiprow=104) %filename x1f 'remove actuals from forecast interval (should not be necessary) smpl 58:12 60:12 x1f_upp = na x1f_low = na 'plot smpl 58:12 62:12 call sub_plotForecast("g1", x1f, x1f_upp, x1f_low) g1.addtext(t) Forecasts from TRAMO show g1 '------------------------------------------------------------------------------ 'X12 log-additive mode with no transformation '------------------------------------------------------------------------------ str(2,1) = "X12 log-additive in levels" smpl 1949:01 1960:12 freeze(tab2) x.x12(gdir=%path_x12, mode=l, arima="(0 1 1)(0 1 1)", f, flead=24, save="b1 d10 d11 d12 d13") x2 show tab2 'get forecasts smpl 61:01 62:12 %filename= %path_x12+"evx12tmp.fct" read(skiprow=2,skipcol=1) %filename x2f x2f_low x2f_upp 'add actuals to forecast smpl 58:12 60:12 x2f = x 'plot smpl 58:12 62:12 call sub_plotForecast("g2", x2f, x2f_upp, x2f_low) g2.addtext(t) Forecasts from X12 (log-additive in levels) show g2 '------------------------------------------------------------------------------ 'X12 additive mode with log transformation '------------------------------------------------------------------------------ str(3,1) = "X12 additive in logs" smpl 1949:01 1960:12 freeze(tab3) x.x12(gdir=%path_x12, f, flead=24, mode=a, tf=0, arima="(0 1 1)(0 1 1)", save="d10 d11 d12 d13") x3 show tab3 'get forecasts smpl 61:01 62:12 read(skiprow=2,skipcol=1) %filename x3f x3f_low x3f_upp 'add actuals to forecast smpl 58:12 60:12 x3f = x 'plot smpl 58:12 62:12 call sub_plotForecast("g3", x3f, x3f_upp, x3f_low) g3.addtext(t) Forecasts from X12 (additive in logs) show g3 '------------------------------------------------------------------------------ 'plot forecasts in one graph '------------------------------------------------------------------------------ smpl 60:01 62:12 graph gra1.line x1f x2f x3f gra1.elem(1) legend(TRAMO) gra1.elem(2) legend(X12 (log-additive in levels)) gra1.elem(3) legend(X12 (additive in logs)) gra1.legend position(0,0) -inbox gra1.addtext(t) Forecast Comparisons show gra1 ^top

Соседние файлы в папке docs