#PROGRAM 6 - SIMULATING AND FORECASTING EWMA # # K. Ensor, ensor@rice.edu # Rice University # # Let's first create a time series of length # Change the model as you would like by changing the # set of specifications below. The final list, kmodel # is the one that feeds into the other routines. # Plotting function used later prettyplot<-function(nrow,ncol){ par(mfrow=c(nrow,ncol),omi=c(.5,1,.5,1)) } kmodel<-list(ma=c(.2),ndiff=1,period=1) x<-rts(arima.sim(200,model=kmodel)) kdescripb(x,"Simulated ARIMA(0,1,1) Realization") # Construct the one step ahead forecast throughout the series kmodel.filt<-arima.filt(x,model=kmodel) #Plot prettyplot(1,1) tsplot(1.1x, kmodel.filt$pred) title(main="EWMA Prediction") tsplot(x-kmodel.filt$pred) title(main="One Step Ahead Residuals") # How would you standardize the residuals?