goptions reset=all; proc greplay nofs; igout=work.gseg; delete _all_; ** clear out the existing graphics catalog ***; goptions lfactor=2 ftext=triplex; /* Source METAL STATISTICS */ DATA SILVER; INPUT SILVER @@; DEL = SILVER-LAG(SILVER); TITLE 'MONTH END STOCKS OF SILVER'; RETAIN DATE '01DEC75'D; DATE=INTNX('MONTH',DATE,1); FORMAT DATE MONYY.; part=1; if date > '01apr80'd then part=2; if part=1 then silv=silver; else silv=.; OUTPUT; RETAIN; DEL4=DEL3; DEL3=DEL2; DEL2=DEL1; DEL1=DEL; LSILVER=SILVER; * SAS dataset up to 845. Some errors found and corrected ; CARDS; 846 827 799 768 719 652 580 546 500 493 530 548 565 572 632 645 674 693 706 661 648 604 647 684 700 723 741 734 708 728 737 729 678 651 627 582 521 519 496 501 555 541 485 476 515 606 694 748 761 794 836 845 822 820 826 826 821 871 858 866 859 854 854 853 848 867 856 785 774 758 773 776 769 783 771 814 780 729 662 606 615 579 800 907 904 1064 972 914 899 909 921 1136 1293 1279 1298 1274 1238 1174 1168 1153 1136 1209 1205 1151 1150 1145 1149 1185 1215 1233 1066 1068 1042 1324 1393 1434 1440 1492 1537 1553 1432 1453 1482 1552 1479 1519 1502 1587 1568 1377 1449 1454 1502 1600 1573 1577 1561 1522 1521 1601 1564 1548 1558 1563 ; proc print data=silver; var date silver part; proc arima DATA=SILVER; i var=silv noprint center; e p=2 ml; f lead=72 out=outs ID=DATE INTERVAL=MONTH NOOUTALL; proc print; run; proc arima data=silver; i var=silv(1) noprint; e p=1 ml noconstant; f lead=72 out=outn ID=DATE INTERVAL=MONTH NOOUTALL; proc print; run; data silver2; merge SILVER outs(rename= (forecast=fors u95=us l95=ls)) outn(rename= (forecast=forn u95=un l95=ln)) ; BY DATE; label silv="Stocks of Silver"; if date > '01jan82'd then do; un=.; ln=.; end; if date > '01jan84'd then do; us=.; ls=.; end; axis1 label=(angle=90 font=centb h=1.2); PROC GPLOT data=silver2; PLOT (SILV fors us ls forn ln un)*date/overlay vaxis=axis1; symbol1 v=none i=join c=red L=1 r=1 w=3; SYMBOL2 V=NONE I=JOIN c=green L=1 R=3 w=3; SYMBOL3 V=NONE I=JOIN C=blue L=4 r=3 w=3; title c=red h=1.4 'Silver Series: Forecasts from 4 1/2 years'; PROC GPLOT data=silver2; PLOT (SILVER fors us ls forn ln un)*date/overlay vaxis=axis1; TITLE2 "plus actual future values"; RUN; PROC REG data=silver; MODEL DEL=LSILVER DEL1 DEL2 DEL3 DEL4; TEST DEL2=0, DEL3=0, DEL4=0; title ' '; where part=1; PROC REG data=silver; MODEL DEL=LSILVER DEL1; where part=1; title 'Part 1'; PROC REG data=silver; MODEL DEL=LSILVER DEL1 DEL2 DEL3 DEL4; TEST DEL2=0, DEL3=0, DEL4=0; title ' '; PROC REG; MODEL DEL=LSILVER DEL1; title 'Full series'; proc arima; i var = silver stationarity=(Dickey) outcov=acf; e p=2; where part=1; proc print data=acf; ***************** * GRAPHICS * *****************; proc gplot uniform; plot corr*lag invcorr*lag partcorr*lag/hminor=0 vminor=0 vaxis = -.5 to 1 by .5; symbol1 v=diamond h=2 w=6 i=needle c=orange; label corr = 'ACF'; label invcorr = "IACF"; label partcorr = "PACF"; title ' '; *********************************************************************; PROC GPLOT data=silver; PLOT SILVER*DATE = part; SYMBOL1 V=NONE I=JOIN c=green w=1; SYMBOL2 V=NONE I=JOIN c=red w=1; title c=red h=1.4 'Silver Series 12 years'; proc arima data=silver; i var = silver stationarity=(Dickey) outcov=acf; e p=2; proc print data=acf; ***************** * GRAPHICS * *****************; proc gplot uniform; plot corr*lag invcorr*lag partcorr*lag/hminor=0 vminor=0 vaxis = -.5 to 1 by .5; symbol1 v=diamond h=2 w=6 i=needle c=blue; label corr = 'ACF'; label invcorr = "IACF"; label partcorr = "PACF"; title ' '; proc gslide; title h=1 c=cyan "4 1/2 years"; note h=2 j=left ' F = 1.32 for lag differences 2 through 4'; note h=2 ' '; note h=2 j=left 'D_S = 75.58 -0.1170 S(t-1) + 0.6712 D_S(t-1) '; note h=2 j=left '. Tau=-2.776 t=6.211 '; proc gslide; title h=1 c=cyan "12 years"; note h=2 j=left ' F = 1.31 for lag differences 2 through 4'; note h=2 ' '; note h=2 j=left 'D_S = 12.95 -0.0090 S(t-1) + 0.1754 D_S(t-1) '; note h=2 j=left ' Tau=-0.622 t=2.079 '; proc greplay tc=tempcat nofs igout=work.gseg; tdef one3 des='Three under one' 1/ llx = 0 lly = 55 ulx = 0 uly = 96 urx = 98 ury = 96 lrx = 98 lry = 55 2/llx = 0 lly = 30 ulx = 0 uly = 50 urx = 30 ury = 50 lrx = 30 lry = 30 3/llx = 35 lly = 30 ulx = 35 uly = 50 urx = 65 ury = 50 lrx = 65 lry = 30 4/llx = 70 lly = 30 ulx = 70 uly = 50 urx = 99 ury = 50 lrx = 99 lry = 30 5/llx = 0 lly = 0 ulx = 0 uly = 25 urx = 100 ury = 25 lrx = 100 lry = 0 ; template = one3; treplay 1:gplot 2:gplot1 3:gplot2 4:gplot3 5:gslide; replay template; treplay 1:gplot4 2:gplot5 3:gplot6 4:gplot7 5:gslide1; replay template; proc print; run;