自己回帰和分移動平均モデル/ARIMA(Auto Regressive Integrated Moving Average)

Equation
ARIMA(1,1,1)
\Delta y_{t}=c+\phi_{1}\Delta y_{t-1}+u_{t}+\theta_{1}u_{t-1}

ARIMA(p,d,q)
\Delta^{d}y_{t}=c+\phi_{1}\Delta^{d}y_{t-1}+\cdots\phi_{p}\Delta^{d}y_{t-p}+u_{t}+\theta_{1}u_{t-1}+\cdots+\theta_{q}u_{t-q}

R
サンプル:2004年2月から2014年2月までのダウ・ジョーンズ工業平均月次データ。
※ARIMA(1,1,0)モデルを採用した場合の残差が正規分布しているとはいえない。
djiaacfdjia
arimadjiaforecastdjia
arimadjiaresidqqnormarimadjia

> library(tseries)
> library(forecast)

> dj <- ts(dataset$dj,start=c(2004,2),frequency=12)

> adf.test(dj)

        Augmented Dickey-Fuller Test

data:  dj
Dickey-Fuller = -1.8713, Lag order = 4, p-value = 0.63
alternative hypothesis: stationary

> adf.test(diff(dj))

        Augmented Dickey-Fuller Test

data:  diff(dj)
Dickey-Fuller = -3.5442, Lag order = 4, p-value = 0.04129
alternative hypothesis: stationary

> for(d in 0:1){
+ for(p in 0:2){
+ for(q in 0:2){
+ tmp <- arima(dj,order=c(p,d,q),method="ML")
+ cat("order=(",p,",",d,",",q,"),AIC=",tmp$aic,"\n")
+ }
+ }
+ }
order=( 0 , 0 , 0 ),AIC= 2170.04 
order=( 0 , 0 , 1 ),AIC= 2030.064 
order=( 0 , 0 , 2 ),AIC= 1951.81 
order=( 1 , 0 , 0 ),AIC= 1798.257 
order=( 1 , 0 , 1 ),AIC= 1794.753 
order=( 1 , 0 , 2 ),AIC= 1796.675 
order=( 2 , 0 , 0 ),AIC= 1794.488 
order=( 2 , 0 , 1 ),AIC= 1793.605 
order=( 2 , 0 , 2 ),AIC= 1798.361 
order=( 0 , 1 , 0 ),AIC= 1776.55 
order=( 0 , 1 , 1 ),AIC= 1773.553 
order=( 0 , 1 , 2 ),AIC= 1775.531 
order=( 1 , 1 , 0 ),AIC= 1773.465 
order=( 1 , 1 , 1 ),AIC= 1774.519 
order=( 1 , 1 , 2 ),AIC= 1776.035 
order=( 2 , 1 , 0 ),AIC= 1775.458 
order=( 2 , 1 , 1 ),AIC= 1776.857 
order=( 2 , 1 , 2 ),AIC= 1777.014 

> arima.dj <- arima(dj,order=c(1,1,0),method="ML")

> plot(dj,main="DJIA.Monthly.2004/2-2014/2",ylim=c(7000,17000),xlab="Date",ylab="DJIA")
> par(new=T)
> plot(dj-arima.dj$resid,main="",ylim=c(7000,17000),xlab="",ylab="",col=2)

> tsdisplay(dj)

> summary(arima.dj)
Series: dj 
ARIMA(1,1,0)                    

Coefficients:
         ar1
      0.2037
s.e.  0.0893

sigma^2 estimated as 148347:  log likelihood=-884.73
AIC=1773.47   AICc=1773.57   BIC=1779.04

Training set error measures:
                   ME     RMSE      MAE       MPE     MAPE     MASE
Training set 34.90971 383.5653 287.2903 0.2215049 2.542273 0.190097

> summary(arima.dj$resid)
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-1852.00  -187.20   103.00    34.91   266.00   849.30 

> plot(forecast(arima.dj,h=12,level=c(50,95)),main="DJIA.Forecasts by ARIMA(1,1,0).Prediction Interval:50%,95%")

> tsdiag(arima.dj)

> qqnorm(arima.dj$resid)

> qqline(arima.dj$resid,col=2)

> jarque.bera.test(arima.dj$resid)

        Jarque Bera Test

data:  arima.dj$resid
X-squared = 156.3545, df = 2, p-value < 2.2e-16

> Box.test(arima.dj$resid,lag=30,type="Ljung")

        Box-Ljung test

data:  arima.dj$resid
X-squared = 36.1664, df = 30, p-value = 0.2027

参考文献
廣松毅,浪花貞夫,高岡慎著(2006).『経済時系列分析』.多賀出版.404pp.
福地純一郎、伊藤有希(2011).『Rによる計量経済分析』.朝倉書店.186pp.
熊谷悦生、舟尾暢男(2008).『Rで学ぶデータマイニング Ⅱシミュレーション編』.オーム社.248pp.

アプリケーション

R Core Team (2013). R: A language and environment for statistical computing.
R Foundation for Statistical Computing, Vienna, Austria.
URL http://www.R-project.org/.