### Airline passenger data Splus # read the data x <- scan("E:\\Stat207\\Midterm\\Airpass.dat") # you can make x a regular time series object x <- rts(x, start=c(1949,1), freq=12, units="years") # plot the data par(mfrow=c(1,1)) ts.plot(x, xlab="Year", ylab="Airline Passengers") # log x.log <- log(x) # plot the data par(mfrow=c(1,1)) ts.plot(x.log, xlab="Year", ylab="log Airline Passengers") # differecne x.log.diff <- diff(x.log) # plot the data par(mfrow=c(1,1)) ts.plot(x.log.diff, xlab="Year", ylab="differenced log Airline Passengers") # ACF and PACF 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 par(mfrow=c(1,1)) ts.plot(x.log.diff.diff12, xlab="Year", ylab="seasonal differenced log Airline Passengers") # ACF and PACF par(mfrow=c(2,2)) acf(x.log.diff.diff12,48) acf(x.log.diff.diff12,48,type="partial") # x.log.model <- list(list(order=c(0,1,1)), list(order=c(0,1,1), period=12)) x.log.sarima <- arima.mle(x.log, model=x.log.model) x.log.sarima x.log.sarima$model par(mfrow=c(1,1)) arima.diag(x.log.sarima,lag=48)