简体   繁体   中英

simulate AR time series data in r

I use arima.sim to simulate AR(1) process.

error.model = function(n){rnorm(n, sd = 1-0.3^2)}
X1 = arima.sim(list(order=c(1,0,0), ar = 0.3), n = 1e3, n.start = 2e2, start.innov = rnorm(200, sd = 0.3), rand.gen = error.model)

The variance X1 converges to 0.9. But theoretically, since the variance of white noise is 1-0.3^2 , the variance of X1 should be (1-0.3^2)/(1-ar^2)=1

I made a mistake. the sd should be sqrt(1-0.3^2) . So everything is fine now

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