Hi, I am using the arima.sim function to generate some AR time series. However, the function does not seem to produce exactly the same time series when I specify the innov parameter. For example> r <- rnorm(300) > x <- arima.sim(300, model=list(order=c(1,0,0),ar=c(.96)), innov=r, n.start=10) > y <- arima.sim(300, model=list(order=c(1,0,0),ar=c(.96)), innov=r, n.start=10)> x[1:10][1] 3.194806 4.214894 5.168017 7.925152 8.810817 9.131695 [7] 7.521283 8.266911 8.923429 9.651293> y[1:10][1] -0.7202632 0.4564274 1.5598893 4.4613486 [5] 5.4855660 5.9394547 4.4567320 5.3249417 [9] 6.0991390 6.9399748 Given the fact that I have provided the innovations shouldn't the time series be exactly the same? Any help would be greatly appreciated. All the best, Sam. [[alternative HTML version deleted]]
Kemp S E (Comp) wrote:> Hi, > > I am using the arima.sim function to generate some AR time series. However, the function does not seem to produce exactly the same time series when I specify the innov parameter. For example > > >>r <- rnorm(300) >>x <- arima.sim(300, model=list(order=c(1,0,0),ar=c(.96)), innov=r, n.start=10) >>y <- arima.sim(300, model=list(order=c(1,0,0),ar=c(.96)), innov=r, n.start=10) > > >>x[1:10] > > [1] 3.194806 4.214894 5.168017 7.925152 8.810817 9.131695 > [7] 7.521283 8.266911 8.923429 9.651293 > > >>y[1:10] > > [1] -0.7202632 0.4564274 1.5598893 4.4613486 > [5] 5.4855660 5.9394547 4.4567320 5.3249417 > [9] 6.0991390 6.9399748 > > Given the fact that I have provided the innovations shouldn't the time series be exactly the same? > > Any help would be greatly appreciated. > > All the best, > > Sam. >Not a bug, but a difference in seeds. Try: set.seed(1) r <- rnorm(300) m <- list(order = c(1,0,0), ar = c(.96)) set.seed(1) x <- arima.sim(300, model = m, innov = r, n.start = 10) set.seed(1) y <- arima.sim(300, model = m, innov = r, n.start = 10) all.equal(x, y) # [1] TRUE HTH, --sundar
On Sun, 2 Oct 2005, Kemp S E (Comp) wrote:> Hi, > > I am using the arima.sim function to generate some AR time series. > However, the function does not seem to produce exactly the same time > series when I specify the innov parameter. For example > >> r <- rnorm(300) >> x <- arima.sim(300, model=list(order=c(1,0,0),ar=c(.96)), innov=r, n.start=10) >> y <- arima.sim(300, model=list(order=c(1,0,0),ar=c(.96)), innov=r, n.start=10) > >> x[1:10] > [1] 3.194806 4.214894 5.168017 7.925152 8.810817 9.131695 > [7] 7.521283 8.266911 8.923429 9.651293 > >> y[1:10] > [1] -0.7202632 0.4564274 1.5598893 4.4613486 > [5] 5.4855660 5.9394547 4.4567320 5.3249417 > [9] 6.0991390 6.9399748 > > Given the fact that I have provided the innovations shouldn't the time > series be exactly the same?No. Hint: where does the randomness for the burn-in come from? -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595