PROC GREPLAY nofs; igout=work.gseg; delete _all_; ** clear out the existing graphics catalog ***; Goptions targetdevice=dj660c; Title "Import and Export Indices"; title2 "Bureau of Labor Statistics"; /* From Bureau of Labor Statistics home page [Bureau of Labor Statistics Data] Data extracted on: February 05, 2001 (01:25 PM) ------------------------------------------------------------------------ International Price Index Series Catalog: Series ID : EIUIL (N) Index : BEA END USE IMPORT INDEXES Series Name : ALL COMMODITIES Data: */ data part1; * Data assembly *; input year @; do mon=1 to 4; input import @@; output; end; cards; 1989 90.6 90.1 90.8 91.4 1990 92.0 92.2 91.9 91.1 1991 96.4 94.5 94.5 93.7 1992 93.4 93.5 93.4 93.0 1993 93.7 93.7 94.2 94.6 1994 93.0 93.3 93.5 94.2 1995 98.2 98.8 99.4 100.3 1996 100.6 100.4 101.0 101.9 1997 101.6 100.7 99.4 98.3 1998 95.3 94.4 93.6 93.3 1999 90.8 90.7 90.9 91.9 2000 97.2 99.2 99.3 97.9 ; data part2; input year @; do mon=5 to 8; input import @@; output; end; cards; 1989 92.1 91.0 90.0 89.5 1990 90.6 90.3 90.0 92.8 1991 93.5 92.8 92.3 92.6 1992 93.5 94.3 94.7 95.1 1993 94.9 94.4 93.9 93.9 1994 95.0 95.8 96.6 97.1 1995 101.3 100.8 100.5 100.3 1996 101.2 100.1 100.0 100.1 1997 98.3 98.2 98.0 97.9 1998 93.2 92.6 91.8 91.4 1999 92.5 92.4 93.3 94.3 2000 98.3 99.6 99.7 99.9 ; data part3; input year @; do mon=9 to 12; input import @@; output; end; cards; 1989 89.8 90.4 90.6 91.1 1990 95.9 98.7 98.2 97.8 1991 92.8 93.5 93.9 93.7 1992 95.4 96.0 95.5 93.9 1993 93.9 94.4 93.9 93.0 1994 96.7 97.3 98.0 97.9 1995 100.3 99.8 100.0 100.4 1996 101.3 101.8 101.6 101.9 1997 97.8 98.0 97.6 96.6 1998 91.6 91.8 91.3 90.4 1999 95.2 95.4 96.2 96.8 2000 101.0 100.6 100.7 100.2 ; data import; set part1 part2 part3; proc sort; by year mon; /* Series Catalog: Series ID : EIUIK (N) Index : BEA END USE EXPORT INDEXES Series Name : ALL COMMODITIES Data: Year Jan Feb Mar Apr */ data part1; input year @; do mon=1 to 4; input export @@; output; end; cards; 1989 91.3 91.0 91.6 91.4 1990 91.6 91.0 91.2 91.5 1991 93.1 93.1 92.8 93.0 1992 92.0 92.7 92.5 92.7 1993 92.8 93.0 92.9 93.1 1994 94.3 94.3 94.5 94.5 1995 98.0 98.6 99.1 100.0 1996 101.0 100.8 100.6 101.2 1997 99.4 99.6 99.7 99.7 1998 97.5 97.2 96.9 96.5 1999 94.8 94.6 94.2 94.4 2000 95.4 95.8 96.3 96.2 ; data part2; input year @; do mon=5 to 8; input export @@; output; end; cards; 1989 91.7 91.6 91.1 90.4 1990 91.7 91.5 91.7 91.8 1991 92.7 92.5 92.0 92.3 1992 93.0 92.8 92.9 92.7 1993 93.4 93.2 93.4 93.3 1994 94.8 94.8 95.0 95.2 1995 100.3 100.5 100.8 100.3 1996 101.6 101.4 100.9 100.7 1997 99.4 99.3 99.3 99.3 1998 96.6 96.1 95.8 95.3 1999 94.5 94.5 94.4 94.7 2000 96.4 96.3 96.2 96.0 ; data part3; input year @; do mon=9 to 12; input export @@; output; end; cards; 1989 90.9 91.0 90.6 90.8 1990 92.2 92.9 93.1 92.7 1991 92.0 92.9 93.0 92.1 1992 93.0 92.6 92.5 92.7 1993 93.2 93.2 93.4 93.7 1994 95.4 95.9 96.6 97.2 1995 100.5 100.6 100.6 100.5 1996 99.9 99.7 99.3 99.3 1997 99.0 98.6 98.6 98.2 1998 94.8 94.7 94.9 94.8 1999 94.8 95.1 95.3 95.2 2000 96.6 96.5 96.5 96.4 ; data export; set part1 part2 part3; output; proc sort; by year mon; data inout; merge import export; by year mon; dexp=dif(export); dimp=dif(import); date = intnx('month','01dec88'd,_n_); format date monyy.; ratio=export/import; lratio = log(ratio); label lratio="log(OUT/IN)"; proc print; var year mon export import lratio; run; data coint; set inout; d=lratio-r1; retain; output; r1=lratio; d6=d5;d5=d4; d4=d3;d3=d2;d2=d1; d1=d; proc reg; model d=date r1 d1 d2 d3 d4 d5 d6/ss1; * Cointegration *; test d2=0, d3=0, d4=0,d5=0, d6=0; proc reg; model d= r1 d1; run; proc arima data=inout; i var=export(1) crosscor=(import(1)); e input=( /(1) import ) p=(13) q=(3,5) ml plot; i var=lratio stationarity = (adf=(1,2)) ; e p=2 ml; f lead=1 out=out1 id=date interval = month intper=1; proc statespace data=inout cancorr; var import(1) export(1); run; proc statespace data=inout; var import(1) export(1); restrict g(4,2)=0 g(3,2)=0 f(1,2)=0 f(1,1)=0 g(4,1)=0 f(4,3)=0; run; quit; proc gplot data=inout; * Plots *; plot (import export)*date/overlay legend; symbol1 v=none i=join c=red w=3; symbol2 v=none i=join c=blue w=3; plot (dimp dexp)*date/overlay legend; plot ratio*date lratio*date; run; data anno; set out1; xsys="2"; ysys="2"; if _n_=1 then function="move"; x=date; retain; size = 3; if _n_ >1 then function ="draw"; output; function="move"; y=lratio; output; y=lratio -(1-1.32309+.41828)*(lratio+.00365); ** Error Correction **; data anno; set anno; if '01jan95'd target then color = "black"; else color = "gray"; NegL_in = -1*l_in; data part1; set plane; size=2; set plane; retain; xsys="2"; ysys="2"; zsys="2"; x=date; if _n_=1 then function="move"; Y=L_in; Z=L_out; output; function = "draw"; Z = target; output; Z=L_out; function = "move"; output; /* Y = Z - .00365; function = "draw"; output; Y = L_in; function = "move"; color = " red"; output; */ function = "draw"; data part2; size=1; set plane; t+1; if mod(t,4)=1 then do; xsys="2"; ysys="2"; zsys="2"; x=date; function="move"; color="cyan"; Y=4.5; Z = Y + .00365; output; function = "draw"; Y = 4.62; Z = Y + .00365; output; end; data part3; set plane; keep date target L_in; proc sort; by target; data part3; set part3; size=1; xsys="2"; ysys="2"; zsys="2"; z=target; Y=L_in; function="move"; color="cyan"; x = '01jan89'd; if Y>4.499 and Y<4.6201 then output; function = "draw"; x = intnx('month',x,140); if Y>4.499 and Y<4.6201 then output; data annoplane; set part1 part2 part3; when = "before"; * proc print data=annoplane; var x y z function color; proc gplot data=plane; plot (L_out target)*NegL_in/overlay; symbol1 v=dot i=join c=cyan w=3; symbol2 v=none i=join w=3 c=black; title "Side view of cointegrating plane"; proc g3d data=plane annotate=annoplane; title "3-d view of cointegrating plane"; scatter L_in*date=L_out/ shape="balloon" color=color size=.5 noneedle tilt = 85 rotate = 45; scatter L_in*date=L_out/ shape="balloon" color=color size=.5 noneedle tilt = 85 rotate = 85; run; quit; PROC GREPLAY tc=tempcat nofs igout=work.gseg; tdef six des='Six Panels' 1/ llx = 6 lly = 67 ulx = 6 uly = 99 urx = 51 ury = 99 lrx = 51 lry = 67 2/ llx = 6 lly = 34 ulx = 6 uly = 66 urx = 51 ury = 66 lrx = 51 lry = 34 3/ llx = 6 lly = 1 ulx = 6 uly = 33 urx = 51 ury = 33 lrx = 51 lry = 1 4/ llx = 55 lly = 67 ulx = 55 uly = 99 urx = 98 ury = 99 lrx = 98 lry = 67 5/ llx = 55 lly = 34 ulx = 55 uly = 66 urx = 98 ury = 66 lrx = 98 lry = 34 6/ llx = 55 lly = 1 ulx = 55 uly = 33 urx = 98 ury = 33 lrx = 98 lry = 1 ; template = six; treplay 1:gplot 2:gplot3 3:g3d 4:gplot1 5:gplot4 6:gplot5 ; * replay template; run; quit;