[R] help with simulate AR(1) data
cathelf at hotmail.com
Tue Jul 22 21:52:54 CEST 2008
Hi, sorry for bothering your guys again.
I want to simulate 100 AR(1) data with cor(x_t, x_t-1)=rho=0.3. The mean of
the first 70 data (x_1 to x_70) is 0 and the mean of the last 30 data (x_71
to x_100) is 2. Can I do it in the following way?
x <- arima.sim(list=(ar=0.3), 100)
mean <- c(rep(0, 70), rep(2, 30))
xnew <- x+mean
If the above code to simulate 100 AR(1) data is right, what should I do if I
want to simulate 1000 independent group of this data? Each group contains
100 AR(1) data. So it is a matrix of 1000*100. Each row is a AR(1). I think
there should be a quicker way to do that? (the easies way is simulate ar(1)
1000 times, but it waste time, I think)
Thank you very much for your reply!
View this message in context: http://www.nabble.com/help-with-simulate-AR%281%29-data-tp18597351p18597351.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help