/* This program generates the Covariance Switching model */ data mc; x1 = 0; iseed = 246; do t = 0 to 50; a = rannor(iseed); x2 = -0.50*x1 + a; if t > 0 then output; x1 = x2; end; x1 = 0; iseed = 624; do t = 50 to 100; a = rannor(iseed); x2 = 0.50*x1 + a; if t > 50 then output; x1 = x2; end; keep t x2; data mc; set mc; y = x2; time=_N_; run; proc gplot data=mc; symbol v=dot c=black i=join h=.8; title1 'Monte Carlo Covariance Switching Data'; title2 'X=Time Y=Cov. Switching Series'; axis1 order=(0 to 100 by 10) label=(f=duplex 'Obs'); axis2 order=(-6 to 6 by 1) label=(f=duplex 'y'); plot y*time / haxis=axis1 vaxis=axis2; run; title; proc arima data=mc; identify var=y; estimate p = 1; run; proc arima data=mc; identify var = y; estimate p = 0; forecast lead=20 id=time out=pred1; run; data pred1; set pred1; fore1 = forecast; drop forecast; run; proc gplot data=pred1; title1 'Forecasts Based on AR(0) Model based on ALL of the data'; title2 'X=Time Y=Forecasting While Ignoring the Change in Covariance'; symbol1 i=none v=star h=0.5; symbol2 i=spline v=circle h=0.5; symbol3 i=spline l=5; plot y * time = 1 fore1 * time = 2 ( l95 u95 ) * time = 3 / overlay href = 100.5; run; title; proc arima data=mc(where = (time > 50)); identify var = y; estimate p = 1; forecast lead=20 id=time out=pred2; run; data pred2; set pred2; fore2 = forecast; drop forecast; run; data combine; merge pred1 pred2; by time; run; proc print data=combine; run; proc gplot data=combine; title1 'Forecasts Based on AR(1) rather than ARMA(0,0) Model'; title2 'X=Time Y=Second Half of Positively Correlated Time Series'; symbol1 i=none v=star h=0.5; symbol2 i=spline v=circle h=0.5; symbol3 i = spline v=diamond h=0.5; symbol4 i=spline l=5; plot y * time = 1 fore1 * time = 2 fore2 * time = 3 ( l95 u95 ) * time = 4 / overlay href = 100.5; where time > 50; run;