[R] help with simulate AR(1) data

From: cathelf <cathelf_at_hotmail.com>
Date: Tue, 22 Jul 2008 12:52:54 -0700 (PDT)

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!
Fang

-- 
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.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 22 Jul 2008 - 19:58:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Jul 2008 - 22:32:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive