简体   繁体   English

"如何模拟高阶 AR(N) 过程?"

[英]How to simulate high order AR(N) process?

I need to simulate high order AR(N) series.我需要模拟高阶 AR(N) 系列。 I have no coefficients, only N is known.我没有系数,只有 N 是已知的。 II tried to use arima.sim, but i need to provide specific coefficients to make simulation, and unfortunetley it's imposible to randomly select valid coefficients which will keep stationarity condition. II 尝试使用 arima.sim,但我需要提供特定的系数来进行模拟,不幸的是,随机选择保持平稳性条件的有效系数是不可能的。 Any ideas?有任何想法吗? I need ANY AR(N) samples (lot of them).我需要任何 AR(N) 样本(很多)。 Thanks.谢谢。

"

A stationary AR(p) process will have characteristic equation with p roots outside the unit circle.一个平稳的 AR(p) 过程将具有在单位圆外具有 p 个根的特征方程。 Because the characteristic equation has real coefficients, these roots will be in conjugate pairs, and if p is odd, there will be one real root.因为特征方程有实系数,所以这些根是共轭对的,如果 p 是奇数,就会有一个实根。 So an efficient way to generate the coefficients is to first generate the roots, and then construct the characteristic polynomial, from which the coefficients are easily extracted.因此生成系数的一种有效方法是首先生成根,然后构造特征多项式,从中可以轻松提取系数。

Here is some code to do it.这是一些代码来做到这一点。

It is simpler to generate inverse roots within the unit circle, and then invert them.在单位圆内生成逆根,然后将它们取反更简单。

library(polynom)

# Order of AR polynomial
p <- 50
n_real_roots <- p %% 2
inv_real_roots <- runif(n_real_roots, -1, 1)
# Generate inverse complex roots in conjugate pairs
n_complex_roots <- (p - n_real_roots) / 2
r <- runif(n_complex_roots, -1, 1)
angle <- runif(n_complex_roots, -pi, pi)
inv_complex_roots <- c(complex(argument = angle, modulus = r), 
                       complex(argument = -angle, modulus = r))
# Find polynomial with these as roots
poly <- suppressWarnings(polynom::poly.calc(1/c(inv_real_roots, inv_complex_roots)))
# Scale to have constant 1
poly <- poly / poly[1]
phi <- -as.numeric(poly)[-1]

y <- arima.sim(n = 100, model=list(ar = -coefficients(poly)[-1]))
plot(y)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM