简体   繁体   中英

How to simulate high order AR(N) process?

I need to simulate high order AR(N) series. I have no coefficients, only N is known. 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. Any ideas? I need ANY AR(N) samples (lot of them). Thanks.

"

A stationary AR(p) process will have characteristic equation with p roots outside the unit circle. 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. 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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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