/* ma1_blackman_tukey.sas */ TITLE1 'Spectral density and Blackman-Tukey estimator'; TITLE2 'of MA(1)-process'; /* Generate MA(1)-process */ DATA data1; DO t=0 TO 160; e=RANNOR(1); y=e-.6*LAG(e); OUTPUT; END; /* Estimation of spectral density */ PROC SPECTRA DATA=data1(FIRSTOBS=2) S OUT=data2; VAR y; WEIGHTS TUKEY 10 0; RUN; /* Adjusting different definitions */ DATA data3; SET data2; lambda=FREQ/(2*CONSTANT('PI')); s=S_01/2*4*CONSTANT('PI'); /* Compute underlying spectral density */ DATA data4; DO l=0 TO .5 BY .01; f=1-1.2*COS(2*CONSTANT('PI')*l)+.36; OUTPUT; END; /* Merge the data sets */ DATA data5; MERGE data3(KEEP=s lambda) data4; /* Graphical options */ AXIS1 LABEL=NONE; AXIS2 LABEL=(F=CGREEK 'l') ORDER=(0 TO .5 BY .1); SYMBOL1 I=JOIN C=BLUE V=NONE L=1; SYMBOL2 I=JOIN C=RED V=NONE L=3; /* Plot underlying and estimated spectral density */ PROC GPLOT DATA=data5; PLOT f*l=1 s*lambda=2 / OVERLAY VAXIS=AXIS1 HAXIS=AXIS2; RUN; QUIT;