[R] Null model for arima.sim().

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon May 24 19:18:05 CEST 2004


It's not really intended to work, but a small change makes it work.
(1:nstart is wrong for a null model.)

list(ar=numeric(0), ma=numeric(0)) might be a little clearer.


On Mon, 24 May 2004, Rolf Turner wrote:

> 
> In some time series simulations I'm doing, I occasionally want the
> model to be ``white noise'', i.e. no model at all.  I thought it
> would be nice if I could fit this into the arima.sim() context,
> without making an exceptional case.  I.e. one ***could*** do
> something to the effect
> 
> 	if(length(model)==0) x <- rnorm(n) else x <- arima.sim(model,n)
> 
> but it would be more suave if one could just use arima.sim() all the
> time.
> 
> Experimenting I found that arima.sim() accepts an empty list as the
> model, e.g.
> 
> 	x <- arima.sim(list(),100)
> 
> and the result appears to be white noise.  There are a couple of
> funnies, but.  One is that the resulting x is of length 99, rather
> than 100.  The other is that if I do
> 
> 	set.seed(42)
> 	x <- arima.sim(list(),101)
> 	set.seed(42)
> 	y <- rnorm(100)
> 
> the results are, modulo the order in which they appear, virtually
> identical.  But not ***quite*** identical!  If I do
> ``sort(x)-sort(y)'' I get  zeroes (to 9 decimal places) everywhere,
> except for entries 86 to 90, which are
> 
>     [86] -0.013709324 -0.087867933 -0.002327022 -0.015243692 -0.050845101
> 
> Perhaps arima.sim() is not really intended to accept an empty list
> as a model, and the fact that I'm getting something like the output
> of rnorm() by feeding it an empty list is just serendipity.  But
> it would seem that there may be something subtle going on here.
> Any ideas?


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




More information about the R-help mailing list