axjack's blog

### axjack is said to be an abbreviation for An eXistent JApanese Cool Klutz ###

統計学実践ワークブック 第27章 AR(1)過程

ワークブックp.243にある、AR(1)過程を4つ描画します。

AR(1)過程とは

時点t = 1,2, ... , T について

 \displaystyle Y_t = c + \phi_1 Y_{t-1} + U_t

といったモデル。ここでは U_tはホワイトノイズ( WN(0,1))です。

ソースコード

# AR(1)過程を生成する
genAR1 <- function(Y,Y_1,constant,phi_1){
  Y[1] <- Y_1
  for (t in 2:length(Y)) {
    Y[t] <- constant + phi_1 * Y[t - 1] + rnorm(1,0,1)
  }
  Y
}


# 描画
dev.off()
par(mfrow=c(2,2))
Y <- numeric(100)
genAR1(Y,0,0,phi_1 = -0.6) |> plot(type="l", main="phi_1 = -0.6", xlab="", ylab="")
genAR1(Y,0,0,phi_1 = 0)    |> plot(type="l", main="phi_1 =  0", xlab="", ylab="")
genAR1(Y,0,0,phi_1 = 0.4)  |> plot(type="l", main="phi_1 =  0.4", xlab="", ylab="")
genAR1(Y,0,0,phi_1 = 0.9)  |> plot(type="l", main="phi_1 =  0.9", xlab="", ylab="")

描画結果

f:id:axjack:20211216201224p:plain

考察

  • 係数が負の時とゼロの時の違い
    • 負の時は、上下上下という規則に見える
    • 0の時は、負の時に比べれば上下上下の規則性が感じられない
  • 係数が0.4の時、
    • 隣接項がある程度似ている
  • 係数が0.9の時、
    • 滑らか
axjack is said to be an abbreviation for An eXistent JApanese Cool Klutz.