#Fitting ARIMA Models to US Savings Rate 1955-1980 (as % of disposable income) sr <- scan("https://edoras.sdsu.edu/~babailey/stat673/savings_rate.txt", skip=1) sr <- ts(sr, start=1955) # Graph the data. par(mfrow=c(3,2)) plot(sr) title("US Saving Rate Data") plot(diff(sr)) title("Differenced") acf(sr) acf(diff(sr)) acf(sr, type="partial") acf(diff(sr), type="partial") #Fit Some models fit1 <- arima(sr, order=c(1,0,2)) fit2 <- arima(sr, order=c(0,1,1)) fit3 <- arima(sr, order=c(0,1,2)) # forecast pred <- predict(fit1,n.ahead=16) # graph the forecasts par(mfrow=c(1,1)) plot(c(sr,pred$pred), ylim=c(0,10), type="n") lines(1:104, sr, lty=1) lines(105:120, pred$pred + 2*pred$se, lty=2) lines(105:120, pred$pred - 2*pred$se, lty=2) points(105:120, pred$pred, pch=3) title("95% Forecast intervals")