我需要帮助生成一个AR(2)模型在R和我是新的软件。
我有以下AR(2)过程:
yt = phi_1 * yt-1 + phi_2 * yt-2 + et,其中et ~ N(0,2)
如何生成一系列yt?
感谢您的帮助,非常感谢!
发布于 2022-04-12 19:51:21
你可以这样做:
set.seed(123)
n <- 200
phi_1 <- 0.9
phi_2 <- 0.7
e <- rnorm(n, 0, 2)
y <- vector("numeric", n)
y[1:2] <- c(0, 1)
for (t in 3:n) {
y[t] <- phi_1 * y[t - 1] + phi_2 * y[t - 2] + e[t]
}
plot(seq(n), y, type = "l")

https://stackoverflow.com/questions/71848270
复制相似问题