[R] Null model for arima.sim().
Rolf Turner
rolf at math.unb.ca
Mon May 24 17:20:12 CEST 2004
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?
cheers,
Rolf Turner
rolf at math.unb.ca
P. S.:
> version
_
platform i686-pc-linux-gnu
arch i686
os linux-gnu
system i686, linux-gnu
status
major 1
minor 9.0
year 2004
month 04
day 12
language R
More information about the R-help
mailing list