### short-term Goverment Securities Splus # to read the data x <- scan("E:\\Stat207\\Midterm\\Securities.dat") # you can make x a regular time series object x <- rts(x, freq=12) # plot the data par(mfrow=c(1,1)) ts.plot(x, xlab="Month", ylab="short-term Goverment Securities") # plot the ACF and PACF par(mfrow=c(2,2)) acf(x) acf(x, type="partial") # note the nonstationarity, difference the data x.diff <- diff(x) # plot the differenced data par(mfrow=c(1,1)) ts.plot(x.diff, xlab="Month", ylab="differenced short-term Goverment Securities") # plot the ACF and PACF par(mfrow=c(2,2)) acf(x.diff) acf(x.diff, type="partial") # ARIMA # now the ARMA(0,1,1) fit x.arima <- arima.mle(x, model=list(order=c(0,1,1)), n.cond = 2) x.arima$model x.arima$var.coef x.arima$aic par(mfrow=c(1,1)) arima.diag(x.arima) # Forecast 12 time units ahead for ARIMA(0,1,1) model x.arima.fore <- arima.forecast(x,n=12,model=x.arima$model) cbind(x.arima.fore$mean,x.arima.fore$std.err) par(mfrow=c(1,1)) ts.plot(x,x.arima.fore$mean,x.arima.fore$mean+2*x.arima.fore$std.err, x.arima.fore$mean-2*x.arima.fore$std.err)