ARモデルの推定と予測

Rで学ぶ時系列分析

David S. Matteson

Associate Professor at Cornell University

ARプロセス:インフレ率

  • 米国の月次インフレ率(パーセント、年率)。
  • 1950年から1990年までの月次観測値
data(Mishkin, package = "Ecdat")

inflation <- as.ts(Mishkin[, 1])
ts.plot(inflation) ; acf(inflation)

Rで学ぶ時系列分析

$$ (Today - Mean) = Slope * (Yesterday - Mean) + Noise $$

$$Y_t - \mu = \phi(Y_{t-1} - \mu) + \epsilon_t $$

$$\epsilon_t~ WhiteNoise(0, \sigma_{\epsilon}^2)$$

AR_inflation <- arima(inflation, order = c(1, 0, 0))

print(AR_inflation)
Coefficients:
        ar1  intercept
     0.5960     3.9745
s.e. 0.0364        0.3471
sigma^2 estimated as 9.713

ar1 = $ \hat{\phi}$, intercept = $ \hat{\mu} $, sigma^2 = $\hat{\sigma}^2_{\epsilon}$

Rで学ぶ時系列分析

ARプロセス:あてはめ値 - I

  • ARあてはめ値:

$$\hat{Y_t} = \hat{\mu} + \hat{\phi}(Y_{t-1} - \hat{\mu})$$

  • 残差 =

$$ \hat{\epsilon_t} = Y_t - \hat{Y_t}$$

Rで学ぶ時系列分析

ARプロセス:あてはめ値 - II

ts.plot(inflation)

AR_inflation_fitted <- inflation - residuals(AR_inflation)
points(AR_inflation_fitted, type = "l" col = "red", lty = 2)

Rで学ぶ時系列分析

予測

  • 1期先予測
predict(AR_inflation)$pred 
Jan
1991 1.605797
predict(AR_inflation)$se
Jan
1991 3.116526
Rで学ぶ時系列分析

予測(続き)

  • hステップ先予測
predict(AR_inflation, n.ahead = 6)$pred
           Jan       Feb       Mar       Apr       May       Jun
1991  1.605797  2.562810  3.133165  3.473082  3.675664  3.796398
predict(AR_inflation, n.ahead = 6)$se
           Jan       Feb       Mar       Apr       May       Jun
1991  3.116526  3.628023  3.793136  3.850077  3.870101  3.877188

Rで学ぶ時系列分析

練習しましょう!

Rで学ぶ時系列分析

Preparing Video For Download...