#8.8 Consider austa, the total international visitors to Australia (in millions) for the period 1980-2015.
library(fpp2)
## Loading required package: ggplot2
## Loading required package: forecast
## Registered S3 method overwritten by 'xts':
## method from
## as.zoo.xts zoo
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## Registered S3 methods overwritten by 'forecast':
## method from
## fitted.fracdiff fracdiff
## residuals.fracdiff fracdiff
## Loading required package: fma
## Loading required package: expsmooth
data(austa)
length(austa)
## [1] 36
autoplot(austa)
Since there is not a seasonal time series, we can set seasonal = FALSE.
ARIMA(0,1,1) is given by auto funciton. It is a random walk and a moving average sequence combination. The model is y(t) = 0.1735 + 0.3006 y(t-1)
fita<-auto.arima(austa,seasonal = FALSE)
fita
## Series: austa
## ARIMA(0,1,1) with drift
##
## Coefficients:
## ma1 drift
## 0.3006 0.1735
## s.e. 0.1647 0.0390
##
## sigma^2 estimated as 0.03376: log likelihood=10.62
## AIC=-15.24 AICc=-14.46 BIC=-10.57
tsdisplay(residuals(fita), lag.max = 45, main = "(ARIMA(0,1,1) model residuals" )
fita %>% forecast(h=10) %>% autoplot(include=80)
After removed the drift, the Forecasts shifted down 0.1735.
#remvoe the drift
austa_b<-austa-0.1735
fitb<-auto.arima(austa_b,seasonal = FALSE)
fitb %>% forecast(h=10) %>% autoplot(include=80)
ARIMA(2,1,3) is a autoregression, a random walk, a 3-moving average sequences combination. The model is
y(t) = c + 0.0004 * y(t-1) + 0.9996 * y(t-2) + 0.4633 e(t-1) - 0.9893 * e(t-2) - 0.4625 * e(t-3)
fitc<-arima(austa,order = c(2,1,3),method="ML")
fitc
##
## Call:
## arima(x = austa, order = c(2, 1, 3), method = "ML")
##
## Coefficients:
## ar1 ar2 ma1 ma2 ma3
## 0.0004 0.9996 0.4633 -0.9893 -0.4625
## s.e. 0.0031 0.0031 0.2283 0.0329 0.2261
##
## sigma^2 estimated as 0.03059: log likelihood = 9.24, aic = -6.48
fitc %>% forecast(h=10) %>% autoplot(include=80)
After remove the constanct( mean ), arima(2,1,3) keeps the same shape and shift down.
#mean is constant
austa3<-austa-mean(austa)
fitc_2<-arima(austa3,order = c(2,1,3),method="ML")
fitc_2
##
## Call:
## arima(x = austa3, order = c(2, 1, 3), method = "ML")
##
## Coefficients:
## ar1 ar2 ma1 ma2 ma3
## 0.0006 0.9994 0.4534 -0.9878 -0.4538
## s.e. 0.0053 0.0053 0.2302 0.0371 0.2254
##
## sigma^2 estimated as 0.03069: log likelihood = 9.23, aic = -6.47
fitc_2 %>% forecast(h=10) %>% autoplot(include=80)
fitd<-arima(austa,order = c(0,0,1),method="ML")
fitd
##
## Call:
## arima(x = austa, order = c(0, 0, 1), method = "ML")
##
## Coefficients:
## ma1 intercept
## 1.0000 3.5515
## s.e. 0.0907 0.3090
##
## sigma^2 estimated as 0.8827: log likelihood = -50.64, aic = 107.28
fitd %>% forecast(h=10) %>% autoplot(include=80)
Plot after remove the MA term.
fitd_2<-arima(austa,order = c(0,0,0),method="ML")
fitd_2
##
## Call:
## arima(x = austa, order = c(0, 0, 0), method = "ML")
##
## Coefficients:
## intercept
## 3.5414
## s.e. 0.2972
##
## sigma^2 estimated as 3.179: log likelihood = -71.9, aic = 147.8
fitd_2 %>% forecast(h=10) %>% autoplot(include=80)
fite<-arima(austa3,order = c(0,2,1),method="ML")
fite
##
## Call:
## arima(x = austa3, order = c(0, 2, 1), method = "ML")
##
## Coefficients:
## ma1
## -0.7262
## s.e. 0.2277
##
## sigma^2 estimated as 0.03853: log likelihood = 6.74, aic = -9.48
fite %>% forecast(h=10) %>% autoplot(include=80)