In this example, a pure autoregressive error model with no regressors is used to generate 50 values of a time series. Approximately 15% of the values are randomly chosen and set to missing. The following statements generate the data:
title 'Simulated Time Series with Roots:'; title2 ' (X-1.25)(X**4-1.25)'; title3 'With 15% Missing Values'; data ar; do i=1 to 550; e = rannor(12345); n = sum( e, .8*n1, .8*n4, -.64*n5 ); /* ar process */ y = n; if ranuni(12345) > .85 then y = .; /* 15% missing */ n5=n4; n4=n3; n3=n2; n2=n1; n1=n; /* set lags */ if i>500 then output; end; run;
The model is estimated using maximum likelihood, and the residuals are plotted with 99% confidence limits. The PARTIAL option prints the partial autocorrelations. The following statements fit the model:
proc autoreg data=ar partial; model y = / nlag=(1 4 5) method=ml; output out=a predicted=p residual=r ucl=u lcl=l alphacli=.01; run;
The printed output produced by the AUTOREG procedure is shown in Output 8.4.1 and Output 8.4.2. Note: the plot Output 8.4.2 can be viewed in the Autoreg.Model.FitDiagnosticPlots category by selecting → .
The following statements plot the residuals and confidence limits:
data reshape1; set a; miss = .; if r=. then do; miss = p; p = .; end; run; title 'Predicted Values and Confidence Limits'; proc sgplot data=reshape1 NOAUTOLEGEND; band x=i upper=u lower=l; scatter y=miss x=i/ MARKERATTRS =(symbol=x color=red); series y=p x=i/markers MARKERATTRS =(color=blue) lineattrs=(color=blue); run;
The plot of the predicted values and the upper and lower confidence limits is shown in Output 8.4.3. Note that the confidence interval is wider at the beginning of the series (when there are no past noise values to use in the forecast equation) and after missing values where, again, there is an incomplete set of past residuals.