library(forecast)
par(mfrow=c(1,2))
Acf(AirPassengers)
Pacf(AirPassengers)
Its difficult to figure the optimal model from the correlation plots.
We will therefore try multiple approachhes to finding the optimal mode. First we try the stepwise approach which is the default approach in auto.arima.
summary(auto.arima(AirPassengers))
## Series: AirPassengers
## ARIMA(2,1,1)(0,1,0)[12]
##
## Coefficients:
## ar1 ar2 ma1
## 0.5960 0.2143 -0.9819
## s.e. 0.0888 0.0880 0.0292
##
## sigma^2 estimated as 132.3: log likelihood=-504.92
## AIC=1017.85 AICc=1018.17 BIC=1029.35
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 1.3423 10.84619 7.86754 0.420698 2.800458 0.245628
## ACF1
## Training set -0.00124847
Next we try the exhaustive search using auto.arima by setting the stepwise to “False”
summary(auto.arima(AirPassengers,stepwise = FALSE))
## Series: AirPassengers
## ARIMA(2,1,1)(0,1,0)[12]
##
## Coefficients:
## ar1 ar2 ma1
## 0.5960 0.2143 -0.9819
## s.e. 0.0888 0.0880 0.0292
##
## sigma^2 estimated as 132.3: log likelihood=-504.92
## AIC=1017.85 AICc=1018.17 BIC=1029.35
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 1.3423 10.84619 7.86754 0.420698 2.800458 0.245628
## ACF1
## Training set -0.00124847
Next we manually search through multiple combinations of p and q assuming that we need just one differencing.
Res=data.frame(Model=0,AIC=0)
n=0
for (i in 0:5){
for (j in 0:9){
n=n+1
temp=Arima(AirPassengers,c(i,1,j),seasonal = c(0,1,0))
Res[n,]=c(i+j/10,temp$aic)
}
}
plot(Res[c(1:60),],col=c(1,2,3,4),pch=20)
Res[which.min(Res$AIC),]
## Model AIC
## 34 3.3 1015.581
The best model is identified by the least AIC and is 3.3 i.e 3 AR and 3 MA model.
So we build our Arima model based on this p=3,q=3
Arima(AirPassengers,c(3,1,3),seasonal=c(0,1,0))
## Series: AirPassengers
## ARIMA(3,1,3)(0,1,0)[12]
##
## Coefficients:
## ar1 ar2 ar3 ma1 ma2 ma3
## -0.1986 -0.1510 0.7142 -0.0788 0.1258 -0.9750
## s.e. 0.0759 0.0768 0.0759 0.0424 0.0435 0.0565
##
## sigma^2 estimated as 122.6: log likelihood=-500.79
## AIC=1015.58 AICc=1016.49 BIC=1035.71
A comparison of the Three Approaches.
As can be observed, the manual approach gave us the least AIC of 1015. The stepwise (default auto.arima) and exhaustive auto.arima gave the same model but at an AIC of 1017.