### Airline passenger data R library(ts) # read the data x <- scan("E:\\Stat207\\Midterm\\Airpass.dat") # you can make x a regular time series object x <- ts(x, start=c(1949,1), freq=12) # plot the data win.graph() par(mfrow=c(1,1)) ts.plot(x, gpars=list(xlab="Year", ylab="Airline Passengers")) # log x.log <- log(x) # plot the data win.graph() par(mfrow=c(1,1)) ts.plot(x.log, gpars=list(xlab="Year", ylab="log Airline Passengers")) # difference x.log.diff <- diff(x.log) # plot the data win.graph() par(mfrow=c(1,1)) ts.plot(x.log.diff, gpars=list(xlab="Year", ylab="differenced log Airline Passengers")) # ACF and PACF win.graph() par(mfrow=c(2,2)) acf(x.log.diff,48) acf(x.log.diff,48,type="partial") # seasonal difference x.log.diff.diff12 <- diff(x.log.diff,12) # plot the data win.graph() par(mfrow=c(1,1)) ts.plot(x.log.diff.diff12, gpars=list(xlab="Year", ylab="seasonal differenced log Airline Passengers")) # ACF and PACF win.graph() par(mfrow=c(2,2)) acf(x.log.diff.diff12,48) acf(x.log.diff.diff12,48,type="partial") # Fit model x.log.sarima <- arima0(x.log, order=c(0,1,1), seasonal = list(order=c(0,1,1), period=12)) x.log.sarima win.graph() par(mfrow=c(3,1)) ts.plot(x.log.sarima$resid) acf(x.log.sarima$resid,48) acf(x.log.sarima$resid,48,type="partial")